diff --git a/patches/minecraft/net/minecraft/world/chunk/BlockStateContainer.java.patch b/patches/minecraft/net/minecraft/world/chunk/BlockStateContainer.java.patch deleted file mode 100644 index 4f02a5ce8e..0000000000 --- a/patches/minecraft/net/minecraft/world/chunk/BlockStateContainer.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/chunk/BlockStateContainer.java -+++ ../src-work/minecraft/net/minecraft/world/chunk/BlockStateContainer.java -@@ -123,7 +123,12 @@ - - for (int i = 0; i < 4096; ++i) - { -- int j = Block.field_176229_d.func_148747_b(this.func_186015_a(i)); -+ IBlockState state = this.func_186015_a(i); -+ int j = Block.field_176229_d.func_148747_b(state); -+ //Forge: Because some blocks place weirdly to things that don't match serializeable states -+ if (j == -1 && state != null) -+ j = Block.field_176229_d.func_148747_b(state.func_177230_c().func_176203_a(state.func_177230_c().func_176201_c(state))); -+ - int k = i & 15; - int l = i >> 8 & 15; - int i1 = i >> 4 & 15; diff --git a/src/main/java/net/minecraftforge/fml/common/registry/GameData.java b/src/main/java/net/minecraftforge/fml/common/registry/GameData.java index 7d36b9fec5..438da4be44 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/GameData.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/GameData.java @@ -290,12 +290,23 @@ public class GameData public void onAdd(Block block, int blockId, Map slaves) { ClearableObjectIntIdentityMap blockstateMap = (ClearableObjectIntIdentityMap)slaves.get(BLOCKSTATE_TO_ID); + + //So, due to blocks having more in-world states then metadata allows, we have to turn the map into a semi-milti-bimap. + //We can do this however because the implementation of the map is last set wins. So we can add all states, then fix the meta bimap. + //Multiple states -> meta. But meta to CORRECT state. + + final boolean[] usedMeta = new boolean[16]; //Hold a list of known meta from all states. for (IBlockState state : block.getBlockState().getValidStates()) { - final int meta = block.getMetaFromState(state); // meta value the block assigns for the state - final int bsmeta = blockId << 4 | meta; // computed blockstateid for that meta - final IBlockState blockState = block.getStateFromMeta(meta); // state that the block assigns for the meta value - blockstateMap.put(blockState, bsmeta); // store assigned state with computed blockstateid + final int meta = block.getMetaFromState(state); + blockstateMap.put(state, blockId << 4 | meta); //Add ALL the things! + usedMeta[meta] = true; + } + + for (int meta = 0; meta < 16; meta++) + { + if (usedMeta[meta]) + blockstateMap.put(block.getStateFromMeta(meta), blockId << 4 | meta); // Put the CORRECT thing! } } @@ -329,7 +340,20 @@ public class GameData @Override public void onCreate(Map slaveset, BiMap> registries) { - final ClearableObjectIntIdentityMap idMap = new ClearableObjectIntIdentityMap(); + final ClearableObjectIntIdentityMap idMap = new ClearableObjectIntIdentityMap() + { + @SuppressWarnings("deprecation") + @Override + public int get(IBlockState key) + { + Integer integer = (Integer)this.identityMap.get(key); + // There are some cases where this map is queried to serialize a state that is valid, + //but somehow not in this list, so attempt to get real metadata. Doing this hear saves us 7 patches + if (integer == null && key != null) + integer = this.identityMap.get(key.getBlock().getStateFromMeta(key.getBlock().getMetaFromState(key))); + return integer == null ? -1 : integer.intValue(); + } + }; ((Map)slaveset).put(BLOCKSTATE_TO_ID, idMap); final HashBiMap map = HashBiMap.create(); ((Map)slaveset).put(BLOCK_TO_ITEM, map);