From 9162bfb48c7787f469f5a96134578332abc704f2 Mon Sep 17 00:00:00 2001 From: QuImUfu Date: Wed, 31 Mar 2021 22:10:05 +0200 Subject: [PATCH] update to minecraft 1.16.5 --- build.gradle | 6 ++--- gradle.properties | 13 +++++----- .../java/quimufu/structure_item/MyItem.java | 24 ++++++++----------- .../structure_item/MyPlacementSettings.java | 24 +++++++++---------- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/build.gradle b/build.gradle index 4390a11..2a41cc9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.2.6-SNAPSHOT' + id 'fabric-loom' version '0.6-SNAPSHOT' id 'maven-publish' } @@ -19,7 +19,7 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" 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 { @@ -76,4 +76,4 @@ publishing { // uncomment to publish to the local maven // mavenLocal() } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 3aada4e..0554cfb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,15 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties -minecraft_version = 1.15.2 -yarn_mappings = 1.15.2+build.15 -loader_version = 0.8.2+build.194 +minecraft_version=1.16.5 +yarn_mappings=1.16.5+build.6 +loader_version=0.11.3 + +#Fabric api +fabric_version=0.32.5+1.16 #Mod properties -mod_version = 0.7.0 +mod_version = 0.8.0 maven_group = quimufu.structure_item archives_base_name = structure_item -#Dependencies -fabric_api_version = 0.5.1+build.294-1.15 diff --git a/src/main/java/quimufu/structure_item/MyItem.java b/src/main/java/quimufu/structure_item/MyItem.java index 83fce34..e56cb6e 100644 --- a/src/main/java/quimufu/structure_item/MyItem.java +++ b/src/main/java/quimufu/structure_item/MyItem.java @@ -1,17 +1,13 @@ package quimufu.structure_item; import com.google.common.collect.Lists; -import com.mojang.datafixers.Dynamic; import net.minecraft.block.Block; import net.minecraft.client.item.TooltipContext; -import net.minecraft.datafixer.NbtOps; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUsageContext; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.*; import net.minecraft.network.MessageType; import net.minecraft.network.packet.s2c.play.TitleS2CPacket; 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 LiteralText(" " + tag.getString("allowedOn"))); } - if (tag.contains("offset")) { - BlockPos offset = BlockPos.deserialize(new Dynamic(NbtOps.INSTANCE, tag.get("offset"))); + if (tag.contains("offset", 10)) { + BlockPos offset = NbtHelper.toBlockPos(tag.getCompound("offset")); texts.add(new TranslatableText("item.structure_item.item.tooltip.fixed.offset")); Text c = new TranslatableText("item.structure_item.item.tooltip.xyz", new LiteralText(String.valueOf(offset.getX())), @@ -145,8 +141,8 @@ public class MyItem extends Item { } BlockPos loc = c.getBlockPos().offset(c.getSide()); - if (tag.contains("offset")) { - BlockPos offset = BlockPos.deserialize(new Dynamic(NbtOps.INSTANCE, tag.get("offset"))); + if (tag.contains("offset", 10)) { + BlockPos offset = NbtHelper.toBlockPos(tag.getCompound("offset")); loc = loc.add(offset); } else if (c.getPlayer() != null) { Direction direction = Direction.getEntityFacingOrder(c.getPlayer())[0]; @@ -176,11 +172,11 @@ public class MyItem extends Item { } ps.setWorld(c.getWorld()) .setSize(x.getSize()) - .setMirrored(BlockMirror.NONE) + .setMirror(BlockMirror.NONE) .setRotation(BlockRotation.NONE) .setChunkPosition(null); - boolean succes = x.method_15172(c.getWorld(), loc, ps, 2); - if (succes) { + boolean success = x.place((ServerWorld)c.getWorld(), loc, loc, ps, c.getWorld().getRandom(), 2); + if (success) { c.getStack().decrement(1); return ActionResult.SUCCESS; } @@ -204,8 +200,8 @@ public class MyItem extends Item { private static void sendPlayerChat(ServerPlayerEntity player, Text message) { if (player != null) - player.sendChatMessage(message, MessageType.SYSTEM); - LOGGER.info(message.asFormattedString()); + player.sendMessage(message, false); + LOGGER.info(message.asString()); } private BlockPos getDirectionalOffset(Direction direction, BlockPos size) { diff --git a/src/main/java/quimufu/structure_item/MyPlacementSettings.java b/src/main/java/quimufu/structure_item/MyPlacementSettings.java index 27abfb5..95dd3f9 100644 --- a/src/main/java/quimufu/structure_item/MyPlacementSettings.java +++ b/src/main/java/quimufu/structure_item/MyPlacementSettings.java @@ -7,7 +7,6 @@ import net.minecraft.structure.Structure; import net.minecraft.structure.StructurePlacementData; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import java.util.ArrayList; @@ -18,13 +17,12 @@ public class MyPlacementSettings extends StructurePlacementData { private World world; private BlockPos size; - public MyPlacementSettings forbidOverwrite(List blocks) { + public void forbidOverwrite(List blocks) { if (blocks.size() == 0) { blacklist = null; - return this; + return; } blacklist = Lists.newArrayList(blocks); - return this; } public MyPlacementSettings setWorld(World w) { @@ -38,16 +36,16 @@ public class MyPlacementSettings extends StructurePlacementData { } @Override - public List method_15121(List> blocks, BlockPos pos) { + public Structure.PalettedBlockInfoList getRandomBlockInfos(List blocks, BlockPos pos) { if (world == null || pos == null || size == null) { - return super.method_15121(blocks, pos); + return super.getRandomBlockInfos(blocks, pos); } - List> eligibleStructures = new ArrayList<>(); + List eligibleStructures = new ArrayList<>(); if (blacklist == null) { eligibleStructures = blocks; } else { - for (List struct : blocks) { + for (Structure.PalettedBlockInfoList struct : blocks) { if (isValid(struct, pos)) { eligibleStructures.add(struct); } @@ -55,24 +53,24 @@ public class MyPlacementSettings extends StructurePlacementData { } if (eligibleStructures.size() == 0) setIgnoreEntities(true); - List locs = super.method_15121(eligibleStructures, pos); + Structure.PalettedBlockInfoList randomBlockInfos = super.getRandomBlockInfos(eligibleStructures, pos); + List locs = randomBlockInfos.getAll(); if (!locs.isEmpty()) { List entitiesWithinAABB = world.getNonSpectatingEntities(Entity.class, new Box(pos,pos.add(size))); for (Structure.StructureBlockInfo blockInfo : locs) { BlockPos posToClean = blockInfo.pos.add(pos); for (Entity e : entitiesWithinAABB) { - e.getBoundingBox().contains(new Vec3d(posToClean)); if (e.getBoundingBox().intersects(new Box(posToClean))) { e.remove(); } } } } - return locs; + return randomBlockInfos; } - private boolean isValid(List struct, BlockPos pos) { - for (Structure.StructureBlockInfo bi : struct) { + private boolean isValid(Structure.PalettedBlockInfoList struct, BlockPos pos) { + for (Structure.StructureBlockInfo bi : struct.getAll()) { BlockPos posToCheck = bi.pos.add(pos); if (World.isValid(posToCheck)) { Block blockToCheck = world.getBlockState(posToCheck).getBlock();