Search in sources :

Example 1 with ItemTubeModule

use of pneumaticCraft.common.item.ItemTubeModule in project PneumaticCraft by MineMaarten.

the class BlockPressureTube method tryPlaceModule.

public boolean tryPlaceModule(EntityPlayer player, World world, int x, int y, int z, int par6, boolean simulate) {
    if (player.getCurrentEquippedItem() != null) {
        if (player.getCurrentEquippedItem().getItem() instanceof ItemTubeModule) {
            TileEntityPressureTube pressureTube = ModInteractionUtils.getInstance().getTube(world.getTileEntity(x, y, z));
            if (pressureTube.modules[par6] == null && ModInteractionUtils.getInstance().occlusionTest(boundingBoxes[par6], world.getTileEntity(x, y, z))) {
                TubeModule module = ModuleRegistrator.getModule(((ItemTubeModule) player.getCurrentEquippedItem().getItem()).moduleName);
                if (simulate)
                    module.markFake();
                pressureTube.setModule(module, ForgeDirection.getOrientation(par6));
                if (!simulate) {
                    onNeighborBlockChange(world, x, y, z, this);
                    world.notifyBlocksOfNeighborChange(x, y, z, this, ForgeDirection.getOrientation(par6).getOpposite().ordinal());
                    if (!player.capabilities.isCreativeMode)
                        player.getCurrentEquippedItem().stackSize--;
                    world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Block.soundTypeGlass.getStepResourcePath(), Block.soundTypeGlass.getVolume() * 5.0F, Block.soundTypeGlass.getPitch() * .9F);
                }
                return true;
            }
        } else if (player.getCurrentEquippedItem().getItem() == Itemss.advancedPCB && !simulate) {
            TubeModule module = BlockPressureTube.getLookedModule(world, x, y, z, player);
            if (module != null && !module.isUpgraded() && module.canUpgrade()) {
                if (!world.isRemote) {
                    module.upgrade();
                    if (!player.capabilities.isCreativeMode)
                        player.getCurrentEquippedItem().stackSize--;
                }
                return true;
            }
        }
    }
    return false;
}
Also used : TubeModule(pneumaticCraft.common.block.tubes.TubeModule) ItemTubeModule(pneumaticCraft.common.item.ItemTubeModule) TileEntityPressureTube(pneumaticCraft.common.tileentity.TileEntityPressureTube) ItemTubeModule(pneumaticCraft.common.item.ItemTubeModule)

Aggregations

TubeModule (pneumaticCraft.common.block.tubes.TubeModule)1 ItemTubeModule (pneumaticCraft.common.item.ItemTubeModule)1 TileEntityPressureTube (pneumaticCraft.common.tileentity.TileEntityPressureTube)1