From d684a4e066d236672e2dda9e7b3ad0383663d6da Mon Sep 17 00:00:00 2001 From: cpw Date: Tue, 31 Mar 2015 15:29:51 -0400 Subject: [PATCH] And fix itemblocks being removed, leaving behind a residual block. This is a legitimate action - use the missing mapping event to let the mod tell us about it --- .../fml/common/event/FMLMissingMappingsEvent.java | 12 +++++++++++- .../java/cpw/mods/fml/common/registry/GameData.java | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/fml/src/main/java/cpw/mods/fml/common/event/FMLMissingMappingsEvent.java b/fml/src/main/java/cpw/mods/fml/common/event/FMLMissingMappingsEvent.java index 94ea8e3eaa..8b9dc04d30 100644 --- a/fml/src/main/java/cpw/mods/fml/common/event/FMLMissingMappingsEvent.java +++ b/fml/src/main/java/cpw/mods/fml/common/event/FMLMissingMappingsEvent.java @@ -52,7 +52,11 @@ public class FMLMissingMappingsEvent extends FMLEvent { /** * Remap this name to a new name (add a migration mapping) */ - REMAP + REMAP, + /** + * Allow a block to exist without itemblock anymore + */ + BLOCKONLY } public static class MissingMapping { public final GameRegistry.Type type; @@ -138,6 +142,12 @@ public class FMLMissingMappingsEvent extends FMLEvent { this.target = target; } + public void skipItemBlock() + { + if (type != GameRegistry.Type.ITEM) throw new IllegalArgumentException("Cannot skip an item that is a block"); + if (GameData.getBlockRegistry().getRaw(id) == null) throw new IllegalArgumentException("Cannot skip an ItemBlock that doesn't have a Block"); + action = Action.BLOCKONLY; + } // internal public Action getAction() diff --git a/fml/src/main/java/cpw/mods/fml/common/registry/GameData.java b/fml/src/main/java/cpw/mods/fml/common/registry/GameData.java index b4c59f189f..ec1f30801d 100644 --- a/fml/src/main/java/cpw/mods/fml/common/registry/GameData.java +++ b/fml/src/main/java/cpw/mods/fml/common/registry/GameData.java @@ -632,6 +632,12 @@ public class GameData { remaps.put(newName, new Integer[] { currId, newId }); } } + else if (action == FMLMissingMappingsEvent.Action.BLOCKONLY) + { + // Pulled out specifically so the block doesn't get reassigned a new ID just because it's + // Item block has gone away + FMLLog.fine("The ItemBlock %s is no longer present in the game. The residual block will remain", remap.name); + } else { // block item missing, warn as requested and block the id