use of forestry.core.multiblock.MultiblockTileEntityForestry in project ForestryMC by ForestryMC.
the class BlockStructure method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (playerIn.isSneaking()) {
return false;
}
MultiblockTileEntityForestry part = TileUtil.getTile(worldIn, pos, MultiblockTileEntityForestry.class);
if (part == null) {
return false;
}
IMultiblockController controller = part.getMultiblockLogic().getController();
ItemStack heldItem = playerIn.getHeldItem(hand);
// multiblock-debugging message if the machine is not assembled.
if (heldItem.isEmpty()) {
if (controller != null) {
if (!controller.isAssembled()) {
String validationError = controller.getLastValidationError();
if (validationError != null) {
long tick = worldIn.getTotalWorldTime();
if (tick > previousMessageTick + 20) {
playerIn.sendMessage(new TextComponentString(validationError));
previousMessageTick = tick;
}
return true;
}
}
} else {
playerIn.sendMessage(new TextComponentTranslation("for.multiblock.error.notConnected"));
return true;
}
}
// Don't open the GUI if the multiblock isn't assembled
if (controller == null || !controller.isAssembled()) {
return false;
}
if (!worldIn.isRemote) {
part.openGui(playerIn);
}
return true;
}
use of forestry.core.multiblock.MultiblockTileEntityForestry in project ForestryMC by ForestryMC.
the class BlockGreenhouse method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (playerIn.isSneaking()) {
return false;
}
MultiblockTileEntityForestry part = TileUtil.getTile(worldIn, pos, MultiblockTileEntityForestry.class);
if (part == null) {
return false;
}
IMultiblockController controller = part.getMultiblockLogic().getController();
ItemStack mainHand = playerIn.getHeldItemMainhand();
if (mainHand.isEmpty()) {
if (playerIn.getHeldItemOffhand().isEmpty()) {
// multiblock-debugging message if the machine is not assembled.
if (!controller.isAssembled()) {
String validationError = controller.getLastValidationError();
if (validationError != null) {
long tick = worldIn.getTotalWorldTime();
if (tick > previousMessageTick + 20) {
playerIn.sendMessage(new TextComponentString(validationError));
previousMessageTick = tick;
}
return true;
}
}
}
}
// Don't open the GUI if the multiblock isn't assembled
if (!controller.isAssembled()) {
return false;
}
if (!worldIn.isRemote) {
part.openGui(playerIn);
}
return true;
}
Aggregations