update to minecraft 1.16.5
This commit is contained in:
		
							parent
							
								
									148bd5b6ad
								
							
						
					
					
						commit
						9162bfb48c
					
				@ -1,5 +1,5 @@
 | 
				
			|||||||
plugins {
 | 
					plugins {
 | 
				
			||||||
	id 'fabric-loom' version '0.2.6-SNAPSHOT'
 | 
						id 'fabric-loom' version '0.6-SNAPSHOT'
 | 
				
			||||||
	id 'maven-publish'
 | 
						id 'maven-publish'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -19,7 +19,7 @@ dependencies {
 | 
				
			|||||||
	mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
 | 
						mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
 | 
				
			||||||
	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
 | 
						modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
 | 
						modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
processResources {
 | 
					processResources {
 | 
				
			||||||
@ -76,4 +76,4 @@ publishing {
 | 
				
			|||||||
		// uncomment to publish to the local maven
 | 
							// uncomment to publish to the local maven
 | 
				
			||||||
		// mavenLocal()
 | 
							// mavenLocal()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,14 +1,15 @@
 | 
				
			|||||||
org.gradle.jvmargs  = -Xmx1G
 | 
					org.gradle.jvmargs  = -Xmx1G
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Fabric properties
 | 
					#Fabric properties
 | 
				
			||||||
minecraft_version   = 1.15.2
 | 
					minecraft_version=1.16.5
 | 
				
			||||||
yarn_mappings       = 1.15.2+build.15
 | 
					yarn_mappings=1.16.5+build.6
 | 
				
			||||||
loader_version      = 0.8.2+build.194
 | 
					loader_version=0.11.3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#Fabric api
 | 
				
			||||||
 | 
					fabric_version=0.32.5+1.16
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Mod properties
 | 
					#Mod properties
 | 
				
			||||||
mod_version         = 0.7.0
 | 
					mod_version         = 0.8.0
 | 
				
			||||||
maven_group         = quimufu.structure_item
 | 
					maven_group         = quimufu.structure_item
 | 
				
			||||||
archives_base_name  = structure_item
 | 
					archives_base_name  = structure_item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Dependencies
 | 
					 | 
				
			||||||
fabric_api_version  = 0.5.1+build.294-1.15
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,17 +1,13 @@
 | 
				
			|||||||
package quimufu.structure_item;
 | 
					package quimufu.structure_item;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.google.common.collect.Lists;
 | 
					import com.google.common.collect.Lists;
 | 
				
			||||||
import com.mojang.datafixers.Dynamic;
 | 
					 | 
				
			||||||
import net.minecraft.block.Block;
 | 
					import net.minecraft.block.Block;
 | 
				
			||||||
import net.minecraft.client.item.TooltipContext;
 | 
					import net.minecraft.client.item.TooltipContext;
 | 
				
			||||||
import net.minecraft.datafixer.NbtOps;
 | 
					 | 
				
			||||||
import net.minecraft.item.Item;
 | 
					import net.minecraft.item.Item;
 | 
				
			||||||
import net.minecraft.item.ItemGroup;
 | 
					import net.minecraft.item.ItemGroup;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.item.ItemUsageContext;
 | 
					import net.minecraft.item.ItemUsageContext;
 | 
				
			||||||
import net.minecraft.nbt.CompoundTag;
 | 
					import net.minecraft.nbt.*;
 | 
				
			||||||
import net.minecraft.nbt.ListTag;
 | 
					 | 
				
			||||||
import net.minecraft.nbt.Tag;
 | 
					 | 
				
			||||||
import net.minecraft.network.MessageType;
 | 
					import net.minecraft.network.MessageType;
 | 
				
			||||||
import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
 | 
					import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
 | 
				
			||||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
 | 
					import net.minecraft.server.network.ServerPlayNetworkHandler;
 | 
				
			||||||
@ -53,8 +49,8 @@ public class MyItem extends Item {
 | 
				
			|||||||
                    texts.add(new TranslatableText("item.structure_item.item.tooltip.allowed.on"));
 | 
					                    texts.add(new TranslatableText("item.structure_item.item.tooltip.allowed.on"));
 | 
				
			||||||
                    texts.add(new LiteralText("  " + tag.getString("allowedOn")));
 | 
					                    texts.add(new LiteralText("  " + tag.getString("allowedOn")));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (tag.contains("offset")) {
 | 
					                if (tag.contains("offset", 10)) {
 | 
				
			||||||
                    BlockPos offset = BlockPos.deserialize(new Dynamic<Tag>(NbtOps.INSTANCE, tag.get("offset")));
 | 
					                    BlockPos offset = NbtHelper.toBlockPos(tag.getCompound("offset"));
 | 
				
			||||||
                    texts.add(new TranslatableText("item.structure_item.item.tooltip.fixed.offset"));
 | 
					                    texts.add(new TranslatableText("item.structure_item.item.tooltip.fixed.offset"));
 | 
				
			||||||
                    Text c = new TranslatableText("item.structure_item.item.tooltip.xyz",
 | 
					                    Text c = new TranslatableText("item.structure_item.item.tooltip.xyz",
 | 
				
			||||||
                            new LiteralText(String.valueOf(offset.getX())),
 | 
					                            new LiteralText(String.valueOf(offset.getX())),
 | 
				
			||||||
@ -145,8 +141,8 @@ public class MyItem extends Item {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            BlockPos loc = c.getBlockPos().offset(c.getSide());
 | 
					            BlockPos loc = c.getBlockPos().offset(c.getSide());
 | 
				
			||||||
            if (tag.contains("offset")) {
 | 
					            if (tag.contains("offset", 10)) {
 | 
				
			||||||
                BlockPos offset = BlockPos.deserialize(new Dynamic<Tag>(NbtOps.INSTANCE, tag.get("offset")));
 | 
					                BlockPos offset = NbtHelper.toBlockPos(tag.getCompound("offset"));
 | 
				
			||||||
                loc = loc.add(offset);
 | 
					                loc = loc.add(offset);
 | 
				
			||||||
            } else if (c.getPlayer() != null) {
 | 
					            } else if (c.getPlayer() != null) {
 | 
				
			||||||
                Direction direction = Direction.getEntityFacingOrder(c.getPlayer())[0];
 | 
					                Direction direction = Direction.getEntityFacingOrder(c.getPlayer())[0];
 | 
				
			||||||
@ -176,11 +172,11 @@ public class MyItem extends Item {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            ps.setWorld(c.getWorld())
 | 
					            ps.setWorld(c.getWorld())
 | 
				
			||||||
                    .setSize(x.getSize())
 | 
					                    .setSize(x.getSize())
 | 
				
			||||||
                    .setMirrored(BlockMirror.NONE)
 | 
					                    .setMirror(BlockMirror.NONE)
 | 
				
			||||||
                    .setRotation(BlockRotation.NONE)
 | 
					                    .setRotation(BlockRotation.NONE)
 | 
				
			||||||
                    .setChunkPosition(null);
 | 
					                    .setChunkPosition(null);
 | 
				
			||||||
            boolean succes = x.method_15172(c.getWorld(), loc, ps, 2);
 | 
					            boolean success = x.place((ServerWorld)c.getWorld(), loc, loc, ps, c.getWorld().getRandom(), 2);
 | 
				
			||||||
            if (succes) {
 | 
					            if (success) {
 | 
				
			||||||
                c.getStack().decrement(1);
 | 
					                c.getStack().decrement(1);
 | 
				
			||||||
                return ActionResult.SUCCESS;
 | 
					                return ActionResult.SUCCESS;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -204,8 +200,8 @@ public class MyItem extends Item {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private static void sendPlayerChat(ServerPlayerEntity player, Text message) {
 | 
					    private static void sendPlayerChat(ServerPlayerEntity player, Text message) {
 | 
				
			||||||
        if (player != null)
 | 
					        if (player != null)
 | 
				
			||||||
            player.sendChatMessage(message, MessageType.SYSTEM);
 | 
					            player.sendMessage(message, false);
 | 
				
			||||||
        LOGGER.info(message.asFormattedString());
 | 
					        LOGGER.info(message.asString());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private BlockPos getDirectionalOffset(Direction direction, BlockPos size) {
 | 
					    private BlockPos getDirectionalOffset(Direction direction, BlockPos size) {
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,6 @@ import net.minecraft.structure.Structure;
 | 
				
			|||||||
import net.minecraft.structure.StructurePlacementData;
 | 
					import net.minecraft.structure.StructurePlacementData;
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
import net.minecraft.util.math.Box;
 | 
					import net.minecraft.util.math.Box;
 | 
				
			||||||
import net.minecraft.util.math.Vec3d;
 | 
					 | 
				
			||||||
import net.minecraft.world.World;
 | 
					import net.minecraft.world.World;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
@ -18,13 +17,12 @@ public class MyPlacementSettings extends StructurePlacementData {
 | 
				
			|||||||
    private World world;
 | 
					    private World world;
 | 
				
			||||||
    private BlockPos size;
 | 
					    private BlockPos size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public MyPlacementSettings forbidOverwrite(List<Block> blocks) {
 | 
					    public void forbidOverwrite(List<Block> blocks) {
 | 
				
			||||||
        if (blocks.size() == 0) {
 | 
					        if (blocks.size() == 0) {
 | 
				
			||||||
            blacklist = null;
 | 
					            blacklist = null;
 | 
				
			||||||
            return this;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        blacklist = Lists.newArrayList(blocks);
 | 
					        blacklist = Lists.newArrayList(blocks);
 | 
				
			||||||
        return this;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public MyPlacementSettings setWorld(World w) {
 | 
					    public MyPlacementSettings setWorld(World w) {
 | 
				
			||||||
@ -38,16 +36,16 @@ public class MyPlacementSettings extends StructurePlacementData {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<Structure.StructureBlockInfo> method_15121(List<List<Structure.StructureBlockInfo>> blocks, BlockPos pos) {
 | 
					    public Structure.PalettedBlockInfoList getRandomBlockInfos(List<Structure.PalettedBlockInfoList> blocks, BlockPos pos) {
 | 
				
			||||||
        if (world == null || pos == null || size == null) {
 | 
					        if (world == null || pos == null || size == null) {
 | 
				
			||||||
            return super.method_15121(blocks, pos);
 | 
					            return super.getRandomBlockInfos(blocks, pos);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<List<Structure.StructureBlockInfo>> eligibleStructures = new ArrayList<>();
 | 
					        List<Structure.PalettedBlockInfoList> eligibleStructures = new ArrayList<>();
 | 
				
			||||||
        if (blacklist == null) {
 | 
					        if (blacklist == null) {
 | 
				
			||||||
            eligibleStructures = blocks;
 | 
					            eligibleStructures = blocks;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            for (List<Structure.StructureBlockInfo> struct : blocks) {
 | 
					            for (Structure.PalettedBlockInfoList struct : blocks) {
 | 
				
			||||||
                if (isValid(struct, pos)) {
 | 
					                if (isValid(struct, pos)) {
 | 
				
			||||||
                    eligibleStructures.add(struct);
 | 
					                    eligibleStructures.add(struct);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -55,24 +53,24 @@ public class MyPlacementSettings extends StructurePlacementData {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        if (eligibleStructures.size() == 0)
 | 
					        if (eligibleStructures.size() == 0)
 | 
				
			||||||
            setIgnoreEntities(true);
 | 
					            setIgnoreEntities(true);
 | 
				
			||||||
        List<Structure.StructureBlockInfo> locs = super.method_15121(eligibleStructures, pos);
 | 
					        Structure.PalettedBlockInfoList randomBlockInfos = super.getRandomBlockInfos(eligibleStructures, pos);
 | 
				
			||||||
 | 
					        List<Structure.StructureBlockInfo> locs = randomBlockInfos.getAll();
 | 
				
			||||||
        if (!locs.isEmpty()) {
 | 
					        if (!locs.isEmpty()) {
 | 
				
			||||||
            List<Entity> entitiesWithinAABB = world.getNonSpectatingEntities(Entity.class, new Box(pos,pos.add(size)));
 | 
					            List<Entity> entitiesWithinAABB = world.getNonSpectatingEntities(Entity.class, new Box(pos,pos.add(size)));
 | 
				
			||||||
            for (Structure.StructureBlockInfo blockInfo : locs) {
 | 
					            for (Structure.StructureBlockInfo blockInfo : locs) {
 | 
				
			||||||
                BlockPos posToClean = blockInfo.pos.add(pos);
 | 
					                BlockPos posToClean = blockInfo.pos.add(pos);
 | 
				
			||||||
                for (Entity e : entitiesWithinAABB) {
 | 
					                for (Entity e : entitiesWithinAABB) {
 | 
				
			||||||
                    e.getBoundingBox().contains(new Vec3d(posToClean));
 | 
					 | 
				
			||||||
                    if (e.getBoundingBox().intersects(new Box(posToClean))) {
 | 
					                    if (e.getBoundingBox().intersects(new Box(posToClean))) {
 | 
				
			||||||
                        e.remove();
 | 
					                        e.remove();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return locs;
 | 
					        return randomBlockInfos;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean isValid(List<Structure.StructureBlockInfo> struct, BlockPos pos) {
 | 
					    private boolean isValid(Structure.PalettedBlockInfoList struct, BlockPos pos) {
 | 
				
			||||||
        for (Structure.StructureBlockInfo bi : struct) {
 | 
					        for (Structure.StructureBlockInfo bi : struct.getAll()) {
 | 
				
			||||||
            BlockPos posToCheck = bi.pos.add(pos);
 | 
					            BlockPos posToCheck = bi.pos.add(pos);
 | 
				
			||||||
            if (World.isValid(posToCheck)) {
 | 
					            if (World.isValid(posToCheck)) {
 | 
				
			||||||
                Block blockToCheck = world.getBlockState(posToCheck).getBlock();
 | 
					                Block blockToCheck = world.getBlockState(posToCheck).getBlock();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user