Search in sources :

Example 1 with IGreenhouseComponent

use of forestry.api.multiblock.IGreenhouseComponent in project ForestryMC by ForestryMC.

the class ItemGreenhouseScreen method handleSneaking.

private EnumActionResult handleSneaking(World world, BlockPos pos, EntityPlayer player, ItemStack itemStack, BlockPos itemPos) {
    IGreenhouseComponent component = MultiblockUtil.getComponent(world, pos, IGreenhouseComponent.class);
    if (component != null) {
        IGreenhouseController controller = component.getMultiblockLogic().getController();
        if (!controller.isAssembled()) {
            if (!world.isRemote) {
                player.sendStatusMessage(new TextComponentTranslation("for.message.greenhouse_screen.notassembled"), true);
            }
            return EnumActionResult.PASS;
        }
        itemStack.setTagInfo(GREENHOUSE_KEY, NBTUtil.createPosTag(pos));
        if (!world.isRemote) {
            player.sendStatusMessage(new TextComponentTranslation("for.message.greenhouse_screen.position"), true);
        }
    } else {
        if (itemPos == null) {
            if (!world.isRemote) {
                player.sendStatusMessage(new TextComponentTranslation("for.message.greenhouse_screen.fail"), true);
            }
            return EnumActionResult.PASS;
        }
        if (!world.isBlockLoaded(pos)) {
            if (!world.isRemote) {
                player.sendStatusMessage(new TextComponentTranslation("for.message.greenhouse_screen.away"), true);
            }
            return EnumActionResult.PASS;
        }
        IGreenhouseController controller = MultiblockUtil.getController(world, itemPos, IGreenhouseComponent.class);
        if (controller == null || !controller.isAssembled()) {
            return EnumActionResult.PASS;
        }
        controller.setCenterCoordinates(pos);
        if (!world.isRemote) {
            player.sendStatusMessage(new TextComponentTranslation("for.message.greenhouse_screen.center", pos), true);
        }
    }
    return EnumActionResult.PASS;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IGreenhouseController(forestry.api.multiblock.IGreenhouseController) IGreenhouseComponent(forestry.api.multiblock.IGreenhouseComponent)

Aggregations

IGreenhouseComponent (forestry.api.multiblock.IGreenhouseComponent)1 IGreenhouseController (forestry.api.multiblock.IGreenhouseController)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1