Railcraft

Railcraft

34M Downloads

SIlk touch drops

bookerthegeek opened this issue ยท 11 comments

commented

Heyo

[05:07:29] [Client thread/ERROR] [railcraft]: Cannot initialize silk touch drops
[05:07:29] [Client thread/ERROR] [railcraft]: java.lang.NoSuchMethodException: net.minecraft.block.Block.getSilkTouchDrop(net.minecraft.block.state.IBlockState)
[05:07:29] [Client thread/ERROR] [railcraft]: java.lang.Class.getDeclaredMethod(Unknown Source)
[05:07:29] [Client thread/ERROR] [railcraft]: mods.railcraft.common.plugins.forge.HarvestPlugin.<clinit>(HarvestPlugin.java:53)
[05:07:29] [Client thread/ERROR] [railcraft]: mods.railcraft.common.items.ItemSteelAxe.initializeDefinition(ItemSteelAxe.java:41)

To Reproduce

  1. Install forge-1.12.2-14.23.5.2796-universal
  2. Install railcraft-12.0.0-alpha-9
  3. Look in the logs

Environment

  • railcraft-12.0.0-alpha-9
  • forge-1.12.2-14.23.5.2796-universal
commented

This thing is intended for tunnel bores to mine with silk touch enchantment. Should not impact your daily lives by too much in theory.

commented

What is this stuff? I see references to #1314 #1323

static {
String methodName = Game.DEVELOPMENT_ENVIRONMENT ? "getSilkTouchDrop" : "func_180643_i";
MethodHandle handle = null;
try {
Method method = Block.class.getDeclaredMethod(methodName, IBlockState.class);
boolean oldAccessible = method.isAccessible();
method.setAccessible(true);
handle = MethodHandles.lookup().unreflect(method);
method.setAccessible(oldAccessible);
} catch (Throwable throwable) {
Game.logThrowable("Cannot initialize silk touch drops", throwable);
}
GET_SILK_TOUCH_DROP_METHOD = handle;
}

Couldn't you do this with an AT?

commented

Hmm, is Game.DEVELOPMENT_ENVIRONMENT initialized incorrectly? This cannot be done with access transformers because this method is protected (overriding methods cannot be all transformed to be public).

commented

I think it looks at the name of Entity.world. I don't know if its current.

commented

The reflection helper does not cache the method or method handle, making it inefficient.

The reflection helper is deprecated as well. Looking for Entity.world is fine because mods can only run under searge name (playing) or mcp name (dev env).

commented

Ah spotted the fix. Should use Game.OBFUSCATED instead

commented

Uh, made a fix on github.

commented

The reflection helper is deprecated as well.

Says who?

commented

Oh, because that class is loaded by another class loader which is not the launch classloader.

commented

I see, it does however appear to have been properly replaced by ObfuscationReflectionHelper. As for the caching issue... do that yourself, you already are. Stop reinventing the wheel.