diff --git a/patches/cpw/mods/fml/common/registry/ItemStackHolderRef.java.patch b/patches/cpw/mods/fml/common/registry/ItemStackHolderRef.java.patch index 124fc6f8..e8e25e7d 100644 --- a/patches/cpw/mods/fml/common/registry/ItemStackHolderRef.java.patch +++ b/patches/cpw/mods/fml/common/registry/ItemStackHolderRef.java.patch @@ -1,19 +1,31 @@ --- ../src-base/minecraft/cpw/mods/fml/common/registry/ItemStackHolderRef.java +++ ../src-work/minecraft/cpw/mods/fml/common/registry/ItemStackHolderRef.java -@@ -1,5 +1,7 @@ +@@ -1,19 +1,15 @@ package cpw.mods.fml.common.registry; -+import java.lang.invoke.MethodHandle; -+import java.lang.invoke.MethodHandles; - import java.lang.reflect.Field; - import java.lang.reflect.Method; - import java.lang.reflect.Modifier; -@@ -40,20 +42,26 @@ - private static Object reflectionFactory; - private static Method newFieldAccessor; - private static Method fieldAccessorSet; -+ private static MethodHandle fieldSetter; // Crucible - lwjgl3ify field - private static void makeWritable(Field f) +-import java.lang.reflect.Field; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +- +-import net.minecraft.item.ItemStack; +- +-import org.apache.logging.log4j.Level; +- + import com.google.common.base.Throwables; +- + import cpw.mods.fml.common.FMLLog; + import cpw.mods.fml.common.registry.GameRegistry.ItemStackHolder; ++import net.minecraft.item.ItemStack; ++import org.apache.logging.log4j.Level; + ++import java.lang.reflect.Field; ++import java.lang.reflect.Method; + ++ + /** + * Internal class used in tracking {@link ItemStackHolder} references + * +@@ -44,16 +40,19 @@ { try { @@ -39,13 +51,11 @@ +// } +// modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL); + f.setAccessible(true); -+ fieldSetter = MethodHandles.lookup() -+ .unreflectSetter(f); + // Crucible end } catch (Exception e) { throw Throwables.propagate(e); -@@ -62,23 +70,53 @@ +@@ -62,23 +61,53 @@ public void apply() { @@ -94,7 +104,7 @@ - Object fieldAccessor = newFieldAccessor.invoke(reflectionFactory, field, false); - fieldAccessorSet.invoke(fieldAccessor, null, is); + try { -+ fieldSetter.invoke(is); ++ field.set(null, is); + } catch (Throwable e) { + FMLLog.getLogger() + .log( diff --git a/patches/cpw/mods/fml/common/registry/ObjectHolderRef.java.patch b/patches/cpw/mods/fml/common/registry/ObjectHolderRef.java.patch index 9f8c09f3..a4907437 100644 --- a/patches/cpw/mods/fml/common/registry/ObjectHolderRef.java.patch +++ b/patches/cpw/mods/fml/common/registry/ObjectHolderRef.java.patch @@ -1,14 +1,29 @@ --- ../src-base/minecraft/cpw/mods/fml/common/registry/ObjectHolderRef.java +++ ../src-work/minecraft/cpw/mods/fml/common/registry/ObjectHolderRef.java -@@ -1,5 +1,7 @@ +@@ -1,17 +1,18 @@ package cpw.mods.fml.common.registry; -+import java.lang.invoke.MethodHandle; -+import java.lang.invoke.MethodHandles; - import java.lang.reflect.Field; - import java.lang.reflect.Method; - import java.lang.reflect.Modifier; -@@ -74,16 +76,19 @@ +-import java.lang.reflect.Field; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import org.apache.logging.log4j.Level; + import com.google.common.base.Throwables; + import cpw.mods.fml.common.FMLLog; + import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; + import net.minecraft.block.Block; + import net.minecraft.init.Blocks; + import net.minecraft.item.Item; ++import net.minecraft.util.RegistryNamespaced; ++import org.apache.logging.log4j.Level; + ++import java.lang.reflect.Field; ++import java.lang.reflect.Method; + ++ + /** + * Internal class used in tracking {@link ObjectHolder} references + * +@@ -74,16 +75,19 @@ { try { @@ -38,12 +53,11 @@ } catch (Exception e) { throw Throwables.propagate(e); -@@ -94,39 +99,80 @@ +@@ -94,39 +98,72 @@ { return isBlock || isItem; } + -+ private MethodHandle fieldSetter = null; // Crucible - needed by lwjgl3ify public void apply() { + // Crucible start - implement lwjgl3ify patch directly @@ -79,23 +93,16 @@ +// { +// FMLLog.log(Level.WARN, e, "Unable to set %s with value %s (%s)", this.field, thing, this.injectedObject); +// } -+ if (fieldSetter == null) { -+ try { -+ fieldSetter = MethodHandles.lookup() -+ .unreflectSetter(this.field); -+ } catch (IllegalAccessException e) { -+ throw new RuntimeException(e); -+ } -+ } Object thing; - if (isBlock) - { - thing = GameData.getBlockRegistry().getObject(injectedObject); - if (thing == Blocks.air) - { ++ RegistryNamespaced registry; + if (isBlock) { -+ thing = GameData.getBlockRegistry() -+ .getObject(injectedObject); ++ registry = GameData.getBlockRegistry(); ++ thing = registry.getObject(injectedObject); + if (thing == Blocks.air) { thing = null; } @@ -107,8 +114,8 @@ - else - { + } else if (isItem) { -+ thing = GameData.getItemRegistry() -+ .getObject(injectedObject); ++ registry = GameData.getItemRegistry(); ++ thing = registry.getObject(injectedObject); + } else { thing = null; } @@ -118,11 +125,11 @@ - FMLLog.getLogger().log(Level.DEBUG, "Unable to lookup {} for {}. This means the object wasn't registered. It's likely just mod options.", injectedObject, field); + if (thing == null) { + FMLLog.getLogger() -+ .log( -+ Level.DEBUG, -+ "Unable to lookup {} for {}. This means the object wasn't registered. It's likely just mod options.", -+ injectedObject, -+ field); ++ .log( ++ Level.DEBUG, ++ "Unable to lookup {} for {}. This means the object wasn't registered. It's likely just mod options.", ++ injectedObject, ++ field); return; } - try @@ -133,7 +140,7 @@ - catch (Exception e) - { + try { -+ fieldSetter.invoke(thing); ++ field.set(null, thing); + FMLLog.finer("Set field " + field.toString() + " to " + thing); + } catch (Throwable e) { FMLLog.log(Level.WARN, e, "Unable to set %s with value %s (%s)", this.field, thing, this.injectedObject);