Search in sources :

Example 1 with TubeModule

use of me.desht.pneumaticcraft.common.block.tubes.TubeModule in project pnc-repressurized by TeamPneumatic.

the class TOPCallback method handlePressureTube.

public static void handlePressureTube(ProbeMode mode, IProbeInfo probeInfo, TileEntityPressureTube te, EnumFacing face) {
    if (face != null) {
        TubeModule module = te.modules[face.ordinal()];
        if (module != null) {
            IProbeInfo vert = probeInfo.vertical(new LayoutStyle().borderColor(0xFF4040FF).spacing(3));
            List<String> currenttip = new ArrayList<>();
            module.addInfo(currenttip);
            for (String s : currenttip) vert.text(s);
        }
    }
}
Also used : LayoutStyle(mcjty.theoneprobe.apiimpl.styles.LayoutStyle) TubeModule(me.desht.pneumaticcraft.common.block.tubes.TubeModule) ArrayList(java.util.ArrayList)

Example 2 with TubeModule

use of me.desht.pneumaticcraft.common.block.tubes.TubeModule in project pnc-repressurized by TeamPneumatic.

the class WailaTubeModuleHandler method addModuleInfo.

private static void addModuleInfo(List<String> currenttip, TileEntityPressureTube tube, NBTTagCompound tubeTag, EnumFacing face) {
    if (face != null) {
        NBTTagList moduleList = tubeTag.getTagList("modules", 10);
        for (int i = 0; i < moduleList.tagCount(); i++) {
            NBTTagCompound moduleTag = moduleList.getCompoundTagAt(i);
            if (face == EnumFacing.getFront(moduleTag.getInteger("side"))) {
                if (tube != null && tube.modules[face.ordinal()] != null) {
                    TubeModule module = tube.modules[face.ordinal()];
                    module.readFromNBT(moduleTag);
                    module.addInfo(currenttip);
                }
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TubeModule(me.desht.pneumaticcraft.common.block.tubes.TubeModule)

Example 3 with TubeModule

use of me.desht.pneumaticcraft.common.block.tubes.TubeModule in project pnc-repressurized by TeamPneumatic.

the class TileEntityPressureTube method onNeighborBlockUpdate.

@Override
public void onNeighborBlockUpdate() {
    super.onNeighborBlockUpdate();
    updateConnections();
    for (TubeModule module : modules) {
        if (module != null)
            module.onNeighborBlockUpdate();
    }
}
Also used : TubeModule(me.desht.pneumaticcraft.common.block.tubes.TubeModule)

Example 4 with TubeModule

use of me.desht.pneumaticcraft.common.block.tubes.TubeModule in project pnc-repressurized by TeamPneumatic.

the class TileEntityPressureTube method readFromPacket.

@Override
public void readFromPacket(NBTTagCompound tag) {
    super.readFromPacket(tag);
    modules = new TubeModule[6];
    NBTTagList moduleList = tag.getTagList("modules", 10);
    for (int i = 0; i < moduleList.tagCount(); i++) {
        NBTTagCompound moduleTag = moduleList.getCompoundTagAt(i);
        TubeModule module = ModuleRegistrator.getModule(moduleTag.getString("type"));
        module.readFromNBT(moduleTag);
        setModule(module, EnumFacing.getFront(moduleTag.getInteger("side")));
    }
    if (hasWorld() && getWorld().isRemote) {
        rerenderTileEntity();
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TubeModule(me.desht.pneumaticcraft.common.block.tubes.TubeModule)

Example 5 with TubeModule

use of me.desht.pneumaticcraft.common.block.tubes.TubeModule in project pnc-repressurized by TeamPneumatic.

the class BlockPressureTube method rotateBlock.

@Override
public boolean rotateBlock(World world, EntityPlayer player, BlockPos pos, EnumFacing side) {
    TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(getTE(world, pos));
    if (player.isSneaking()) {
        TubeModule module = getLookedModule(world, pos, player);
        if (module != null) {
            // detach and drop the module as an item
            if (!player.capabilities.isCreativeMode) {
                List<ItemStack> drops = module.getDrops();
                for (ItemStack drop : drops) {
                    EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
                    entity.setItem(drop);
                    world.spawnEntity(entity);
                    entity.onCollideWithPlayer(player);
                }
            }
            tube.setModule(null, module.getDirection());
            neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
            world.notifyNeighborsOfStateChange(pos, this, true);
        } else {
            // drop the pipe as an item
            if (!player.capabilities.isCreativeMode)
                dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
            world.setBlockToAir(pos);
        }
    } else {
        // close (or reopen) this side of the pipe
        Pair<Boolean, EnumFacing> lookData = getLookedTube(world, pos, player);
        if (lookData != null) {
            boolean isCore = lookData.getLeft();
            EnumFacing sideHit = lookData.getRight();
            tube.sidesClosed[sideHit.ordinal()] = !tube.sidesClosed[sideHit.ordinal()];
            neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
            world.notifyNeighborsOfStateChange(pos, this, true);
        }
    }
    return true;
}
Also used : TubeModule(me.desht.pneumaticcraft.common.block.tubes.TubeModule) ItemTubeModule(me.desht.pneumaticcraft.common.item.ItemTubeModule) TileEntityPressureTube(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

TubeModule (me.desht.pneumaticcraft.common.block.tubes.TubeModule)12 ItemTubeModule (me.desht.pneumaticcraft.common.item.ItemTubeModule)5 TileEntityPressureTube (me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 TileEntity (net.minecraft.tileentity.TileEntity)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 ArrayList (java.util.ArrayList)1 LayoutStyle (mcjty.theoneprobe.apiimpl.styles.LayoutStyle)1 IAirHandler (me.desht.pneumaticcraft.api.tileentity.IAirHandler)1 PacketPlaySound (me.desht.pneumaticcraft.common.network.PacketPlaySound)1 EntityItem (net.minecraft.entity.item.EntityItem)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 Pair (org.apache.commons.lang3.tuple.Pair)1