1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-12 11:10:29 +00:00

Fix TurtleCompareCommand throwing exceptions

Originally introduced in 173ea72001, but
the underlying cause has been happening for much longer.

 - Fix order of method name parameters. Looks like this has been broken
   since 1.11. Woops.
 - Catch RuntimeExceptions too, as Forge converts checked into unchecked
   ones.

Fixes #179
This commit is contained in:
SquidDev 2019-04-19 18:53:39 +01:00
parent f93da7ea51
commit 2e0ef6385d

View File

@ -53,19 +53,15 @@ public class TurtleCompareCommand implements ITurtleCommand
Block lookAtBlock = lookAtState.getBlock(); Block lookAtBlock = lookAtState.getBlock();
if( !lookAtBlock.isAir( lookAtState, world, newPosition ) ) if( !lookAtBlock.isAir( lookAtState, world, newPosition ) )
{ {
// Try createStackedBlock first // Try getSilkTouchDrop first
if( !lookAtBlock.hasTileEntity( lookAtState ) ) if( !lookAtBlock.hasTileEntity( lookAtState ) )
{ {
try try
{ {
Method method = ReflectionHelper.findMethod( Method method = ReflectionHelper.findMethod( Block.class, "getSilkTouchDrop", "func_180643_i", IBlockState.class );
Block.class,
"func_180643_i", "getSilkTouchDrop",
IBlockState.class
);
lookAtStack = (ItemStack) method.invoke( lookAtBlock, lookAtState ); lookAtStack = (ItemStack) method.invoke( lookAtBlock, lookAtState );
} }
catch( ReflectiveOperationException ignored ) catch( ReflectiveOperationException | RuntimeException ignored )
{ {
} }
} }