From 62dd445f7cb912223bd98f9be51823bb9ebb49ad Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 17 Jun 2016 20:50:11 -0400 Subject: [PATCH] Fix Old Sign Conversion 1) Sign loading code was trying to parse the JSON before the check for oldSign. That code could then skip the old sign converting code if it triggers a JSON parse exception. 2) New Mojang Schematic system has Tile Entities in the new converted format, but missing the Bukkit.isConverted flag This causes Igloos and such to render broken signs. We fix this by ignoring sign conversion for Defined Structures diff --git a/src/main/java/net/minecraft/server/DefinedStructure.java b/src/main/java/net/minecraft/server/DefinedStructure.java index 65910508f..002b74175 100644 --- a/src/main/java/net/minecraft/server/DefinedStructure.java +++ b/src/main/java/net/minecraft/server/DefinedStructure.java @@ -88,7 +88,7 @@ public class DefinedStructure { } private void a(World world, BlockPosition blockposition, BlockPosition blockposition1) { - List list = world.a(Entity.class, new AxisAlignedBB(blockposition, blockposition1), (entity) -> { + List list = world.a(Entity.class, new AxisAlignedBB(blockposition, blockposition1),(Predicate) (entity) -> { // Paper - decompile fix return !(entity instanceof EntityHuman); }); @@ -218,9 +218,11 @@ public class DefinedStructure { definedstructure_blockinfo1.c.setInt("x", blockposition1.getX()); definedstructure_blockinfo1.c.setInt("y", blockposition1.getY()); definedstructure_blockinfo1.c.setInt("z", blockposition1.getZ()); + tileentity.isLoadingStructure = true; // Paper tileentity.load(definedstructure_blockinfo1.c); tileentity.a(definedstructureinfo.b()); tileentity.a(definedstructureinfo.c()); + tileentity.isLoadingStructure = false; // Paper } } @@ -285,21 +287,27 @@ public class DefinedStructure { voxelshapebitset.a(blockposition3.getX() - i2, blockposition3.getY() - j2, blockposition3.getZ() - l1, true, true); } - voxelshapebitset.a((enumdirection, i, j, k) -> { - BlockPosition blockposition = new BlockPosition(l + i, i1 + j, j1 + k); - BlockPosition blockposition1 = blockposition.shift(enumdirection); - IBlockData iblockdata = generatoraccess.getType(blockposition); + // Paper start - decompile fixes + int finalL = l; + int finalI = i1; + int finalJ = j1; + int finalK = k1; + voxelshapebitset.a((enumdirection, i_, j_, k_) -> { + BlockPosition innerBlockposition = new BlockPosition(finalL + i_, finalI + j_, finalJ + k_); + BlockPosition blockposition1 = innerBlockposition.shift(enumdirection); + IBlockData iblockdata = generatoraccess.getType(innerBlockposition); IBlockData iblockdata1 = generatoraccess.getType(blockposition1); - IBlockData iblockdata2 = iblockdata.updateState(enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + IBlockData iblockdata2 = iblockdata.updateState(enumdirection, iblockdata1, generatoraccess, innerBlockposition, blockposition1); if (iblockdata != iblockdata2) { - generatoraccess.setTypeAndData(blockposition, iblockdata2, k1 & -2 | 16); + generatoraccess.setTypeAndData(innerBlockposition, iblockdata2, finalK & -2 | 16); } - IBlockData iblockdata3 = iblockdata1.updateState(enumdirection.opposite(), iblockdata2, generatoraccess, blockposition1, blockposition); + IBlockData iblockdata3 = iblockdata1.updateState(enumdirection.opposite(), iblockdata2, generatoraccess, blockposition1, innerBlockposition); if (iblockdata1 != iblockdata3) { - generatoraccess.setTypeAndData(blockposition1, iblockdata3, k1 & -2 | 16); + generatoraccess.setTypeAndData(blockposition1, iblockdata3, finalK & -2 | 16); + // Paper end - decompile fixes } }); @@ -734,7 +742,7 @@ public class DefinedStructure { public IBlockData a(int i) { IBlockData iblockdata = (IBlockData) this.b.fromId(i); - return iblockdata == null ? DefinedStructure.a.a : iblockdata; + return iblockdata == null ? a : iblockdata; // Paper - decompile error - Blocks.AIR.getBlockData() } public Iterator iterator() { diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java index 8cab71c0e..2cfe2202e 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.InventoryHolder; // CraftBukkit public abstract class TileEntity implements KeyedObject { public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper + boolean isLoadingStructure = false; // Paper private static final Logger a = LogManager.getLogger(); private final TileEntityTypes e; public TileEntityTypes getTileEntityType() { return e; } // Paper - OBFHELPER protected World world; diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java index 939d8790f..335a4d27f 100644 --- a/src/main/java/net/minecraft/server/TileEntitySign.java +++ b/src/main/java/net/minecraft/server/TileEntitySign.java @@ -49,13 +49,14 @@ public class TileEntitySign extends TileEntity implements ICommandListener { } try { - IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s); + //IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s); // Paper - move down - the old format might throw a json error - if (oldSign) { + if (oldSign && !isLoadingStructure) { // Paper - saved structures will be in the new format, but will not have isConverted lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0]; continue; } // CraftBukkit end + IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s); // Paper - after old sign if (this.world instanceof WorldServer) { try { -- 2.18.0