add generic wrench handling to fully transparently support BC & COFH wrenches, and add a bonus IC2 wrench support.

This commit is contained in:
Xander Victory committed 2017-11-07 15:38:54 +08:00
1 parent d73796ad4d
commit f6f7678f8b
15 files changed
+408 -124

No files matched your search

@@ -0,0 +1,41 @@
package mekanism.common.integration.wrenches;
import mekanism.api.IMekWrench;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
/**
* Translates to IC2's wrench via reflection as it's an internal class.
*/
public class IC2Proxy implements MekWrenchProxy, IMekWrench
{
public static final String IC2_WRENCH_CLASS = "ic2.core.item.tool.ItemToolWrench";
private final Class<?> wrenchClass;
public IC2Proxy(){
Class<?> w = null;
try
{
w = Class.forName(IC2_WRENCH_CLASS);
}
catch(ClassNotFoundException e)
{
//no-op
}
this.wrenchClass = w;
}
@Override
public boolean canUseWrench(ItemStack stack, EntityPlayer player, BlockPos pos)
{
return this.wrenchClass != null && this.wrenchClass.isInstance(stack.getItem());
}
@Override
public IMekWrench get(ItemStack stack)
{
return this.wrenchClass != null && this.wrenchClass.isInstance(stack.getItem()) ? this : null;
}
}