From 90b2c86a9fd8b0333220239fc1c001ac3d3f6ec6 Mon Sep 17 00:00:00 2001 From: LexManos Date: Wed, 9 Mar 2016 14:41:13 -0800 Subject: [PATCH] Added bypass functions to Defaulted registry, DO NOT USE THIS MODDERS FORGE INTERNAL ONLY. And some other fixups for running. --- .../minecraft/potion/PotionEffect.java.patch | 24 ++++++++----------- ...egistryNamespacedDefaultedByKey.java.patch | 14 +++++++++++ .../FMLControlledNamespacedRegistry.java | 2 +- .../debug/ForgeBlockStatesLoaderDebug.java | 4 ++-- 4 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 patches.mcp/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java.patch diff --git a/patches.mcp/minecraft/net/minecraft/potion/PotionEffect.java.patch b/patches.mcp/minecraft/net/minecraft/potion/PotionEffect.java.patch index dd9931e56..c89501ebf 100644 --- a/patches.mcp/minecraft/net/minecraft/potion/PotionEffect.java.patch +++ b/patches.mcp/minecraft/net/minecraft/potion/PotionEffect.java.patch @@ -9,16 +9,7 @@ public PotionEffect(Potion p_i46811_1_) { -@@ -42,6 +44,8 @@ - this.amplifier = p_i46814_3_; - this.isAmbient = p_i46814_4_; - this.field_188421_h = p_i46814_5_; -+ this.curativeItems = new java.util.ArrayList(); -+ this.curativeItems.add(new net.minecraft.item.ItemStack(net.minecraft.init.Items.milk_bucket)); - } - - public PotionEffect(PotionEffect other) -@@ -51,6 +55,7 @@ +@@ -51,6 +53,7 @@ this.amplifier = other.amplifier; this.isAmbient = other.isAmbient; this.field_188421_h = other.field_188421_h; @@ -26,7 +17,7 @@ } public void combine(PotionEffect other) -@@ -200,7 +205,7 @@ +@@ -200,7 +203,7 @@ public static PotionEffect readCustomPotionEffectFromNBT(NBTTagCompound nbt) { @@ -35,7 +26,7 @@ Potion potion = Potion.func_188412_a(i); if (potion == null) -@@ -240,4 +245,53 @@ +@@ -240,4 +243,58 @@ { return this.isPotionDurationMax; } @@ -47,6 +38,11 @@ + */ + public java.util.List getCurativeItems() + { ++ if (this.curativeItems == null) //Lazy load this so that we don't create a circular dep on Items. ++ { ++ this.curativeItems = new java.util.ArrayList(); ++ this.curativeItems.add(new net.minecraft.item.ItemStack(net.minecraft.init.Items.milk_bucket)); ++ } + return this.curativeItems; + } + @@ -57,7 +53,7 @@ + */ + public boolean isCurativeItem(net.minecraft.item.ItemStack stack) + { -+ for (net.minecraft.item.ItemStack curativeItem : this.curativeItems) ++ for (net.minecraft.item.ItemStack curativeItem : this.getCurativeItems()) + { + if (curativeItem.isItemEqual(stack)) + { @@ -85,7 +81,7 @@ + { + if (!this.isCurativeItem(stack)) + { -+ this.curativeItems.add(stack); ++ this.getCurativeItems().add(stack); + } + } } diff --git a/patches.mcp/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java.patch b/patches.mcp/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java.patch new file mode 100644 index 000000000..ad6c8d499 --- /dev/null +++ b/patches.mcp/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java.patch @@ -0,0 +1,14 @@ +--- ../src-base/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java ++++ ../src-work/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java +@@ -57,4 +57,11 @@ + V v = super.func_186801_a(p_186801_1_); + return (V)(v == null ? this.defaultValue : v); + } ++ ++ //Bypass functions to allow querying this registry WITHOUT getting the defaulted value. ++ // MODDERS DO NOT USE THIS IS FOR FORGE INTERNAL CHECKS ++ public int getIDForObjectBypass(V bypass) { return super.getIDForObject(bypass); } ++ public K getNameForObjectBypass(V value) { return super.getNameForObject(value); } ++ public V getObjectBypass(K name) { return super.getObject(name); } ++ public V getObjectByIdBypass(int id){ return super.getObjectById(id); } + } diff --git a/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java index b18c2cf51..95145a0fd 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java @@ -276,7 +276,7 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul */ public int getId(I thing) { - return getIDForObject(thing); + return getIDForObjectBypass(thing); } /** diff --git a/src/test/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java b/src/test/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java index 9c34e9fca..f8de9ec2f 100644 --- a/src/test/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java +++ b/src/test/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java @@ -122,8 +122,8 @@ public class ForgeBlockStatesLoaderDebug { } public static enum CustomVariant implements IStringSerializable { - TypeA, - TypeB; + type_a, + type_b; public String getName() { return this.toString(); }; }