mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-27 15:23:16 +00:00
add generic wrench handling to fully transparently support BC & COFH wrenches, and add a bonus IC2 wrench support.
This commit is contained in:
1 parent
d73796ad4d
commit
f6f7678f8b
15 files changed
+408
-124
No files matched your search
@@ -2,6 +2,7 @@ package mekanism.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.IMekWrench;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
@@ -10,6 +11,7 @@ import mekanism.common.base.ISustainedInventory;
|
||||
import mekanism.common.base.ITierItem;
|
||||
import mekanism.common.block.states.BlockStateFacing;
|
||||
import mekanism.common.block.states.BlockStateGasTank;
|
||||
import mekanism.common.integration.wrenches.Wrenches;
|
||||
import mekanism.common.security.ISecurityItem;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.TileEntityGasTank;
|
||||
@@ -149,34 +151,37 @@ public class BlockGasTank extends BlockContainer
|
||||
|
||||
if(!stack.isEmpty())
|
||||
{
|
||||
Item tool = stack.getItem();
|
||||
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, pos))
|
||||
IMekWrench wrenchHandler = Wrenches.getHandler(stack);
|
||||
if (wrenchHandler != null)
|
||||
{
|
||||
if(SecurityUtils.canAccess(entityplayer, tileEntity))
|
||||
RayTraceResult raytrace = new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos);
|
||||
if (wrenchHandler.canUseWrench(entityplayer, hand, stack, raytrace))
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
if (SecurityUtils.canAccess(entityplayer, tileEntity))
|
||||
{
|
||||
dismantleBlock(state, world, pos, false);
|
||||
|
||||
return true;
|
||||
wrenchHandler.wrenchUsed(entityplayer, hand, stack, raytrace);
|
||||
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
dismantleBlock(state, world, pos, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
int change = tileEntity.facing.rotateY().ordinal();
|
||||
|
||||
tileEntity.setFacing((short)change);
|
||||
world.notifyNeighborsOfStateChange(pos, this, true);
|
||||
}
|
||||
}
|
||||
|
||||
if(MekanismUtils.isBCWrench(tool))
|
||||
{
|
||||
((IToolWrench)tool).wrenchUsed(entityplayer, hand, stack, new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos));
|
||||
else {
|
||||
SecurityUtils.displayNoAccess(entityplayer);
|
||||
}
|
||||
|
||||
int change = tileEntity.facing.rotateY().ordinal();
|
||||
|
||||
tileEntity.setFacing((short)change);
|
||||
world.notifyNeighborsOfStateChange(pos, this, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
SecurityUtils.displayNoAccess(entityplayer);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user