use of blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IPlayerInteraction in project Immersive-Tech by FerroO2000.
the class BlockITTileProvider method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack heldItem = player.getHeldItem(hand);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof IConfigurableSides && Utils.isHammer(heldItem) && !world.isRemote) {
int iSide = player.isSneaking() ? side.getOpposite().ordinal() : side.ordinal();
if (((IConfigurableSides) tile).toggleSide(iSide, player))
return true;
}
if (tile instanceof IDirectionalTile && Utils.isHammer(heldItem) && ((IDirectionalTile) tile).canHammerRotate(side, hitX, hitY, hitZ, player) && !world.isRemote) {
EnumFacing f = ((IDirectionalTile) tile).getFacing();
int limit = ((IDirectionalTile) tile).getFacingLimitation();
if (limit == 0)
f = EnumFacing.VALUES[(f.ordinal() + 1) % EnumFacing.VALUES.length];
else if (limit == 1)
f = player.isSneaking() ? f.rotateAround(side.getAxis()).getOpposite() : f.rotateAround(side.getAxis());
else if (limit == 2 || limit == 5)
f = player.isSneaking() ? f.rotateYCCW() : f.rotateY();
((IDirectionalTile) tile).setFacing(f);
tile.markDirty();
world.notifyBlockUpdate(pos, state, state, 3);
world.addBlockEvent(tile.getPos(), tile.getBlockType(), 255, 0);
return true;
}
if (tile instanceof IHammerInteraction && Utils.isHammer(heldItem) && !world.isRemote) {
boolean b = ((IHammerInteraction) tile).hammerUseSide(side, player, hitX, hitY, hitZ);
if (b)
return b;
}
if (tile instanceof IPlayerInteraction) {
boolean b = ((IPlayerInteraction) tile).interact(side, player, hand, heldItem, hitX, hitY, hitZ);
if (b)
return b;
}
if (tile instanceof IGuiTile && hand == EnumHand.MAIN_HAND && !player.isSneaking()) {
TileEntity master = ((IGuiTile) tile).getGuiMaster();
if (((IGuiTile) tile).canOpenGui(player)) {
if (!world.isRemote && master != null)
CommonProxy.openGuiForTile(player, (TileEntity & IGuiTile) master);
return true;
}
}
return false;
}
Aggregations