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);
}
}
}
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);
}
}
}
}
}
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();
}
}
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();
}
}
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;
}
Aggregations