use of me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine in project pnc-repressurized by TeamPneumatic.
the class WailaPneumaticHandler method getNBTData.
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
TileEntity teInfo;
if (te instanceof IInfoForwarder) {
teInfo = ((IInfoForwarder) te).getInfoTileEntity();
if (teInfo != null) {
tag.setInteger("infoX", teInfo.getPos().getX());
tag.setInteger("infoY", teInfo.getPos().getY());
tag.setInteger("infoZ", teInfo.getPos().getZ());
}
} else {
teInfo = te;
}
if (teInfo instanceof IPneumaticMachine) {
tag.setFloat("pressure", ((IPneumaticMachine) teInfo).getAirHandler(null).getPressure());
}
return tag;
}
use of me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine in project pnc-repressurized by TeamPneumatic.
the class ModuleRegulatorTube method renderPreview.
@SideOnly(Side.CLIENT)
private void renderPreview() {
if (!hasTicked) {
TileEntityPneumaticBase tile = (TileEntityPneumaticBase) getTube();
NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(tile.getPos()));
TileEntity neighbor = tile.getWorld().getTileEntity(tile.getPos().offset(dir));
inLine = neighbor instanceof IPneumaticMachine;
if (inLine) {
IAirHandler neighborHandler = ((IPneumaticMachine) neighbor).getAirHandler(dir);
inverted = neighborHandler != null && neighborHandler.getPressure() > tile.getAirHandler(null).getPressure();
NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(neighbor.getPos()));
}
hasTicked = true;
}
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (inLine && !inverted) {
GL11.glColor4d(0, 1, 0, 0.3);
} else {
GL11.glColor4d(1, 0, 0, 0.3);
}
GL11.glPushMatrix();
GL11.glTranslated(0, 1, 0.2 + ClientTickHandler.TICKS % 20 * 0.015);
GL11.glRotated(90, 1, 0, 0);
RenderUtils.render3DArrow();
// 0.5 because we're rendering a preview
GL11.glColor4d(1, 1, 1, 0.5);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_BLEND);
}
use of me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine in project pnc-repressurized by TeamPneumatic.
the class WailaPneumaticHandler method addTipToMachine.
private static void addTipToMachine(List<String> currenttip, IWailaDataAccessor accessor) {
NBTTagCompound tag = accessor.getNBTData();
TileEntity te = accessor.getTileEntity();
if (te instanceof IInfoForwarder) {
BlockPos infoPos = new BlockPos(tag.getInteger("infoX"), tag.getInteger("infoY"), tag.getInteger("infoZ"));
te = accessor.getWorld().getTileEntity(infoPos);
}
if (te instanceof IPneumaticMachine) {
addTipToMachine(currenttip, (IPneumaticMachine) te, tag.getFloat("pressure"));
}
}
use of me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine in project pnc-repressurized by TeamPneumatic.
the class ItemManometer method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (world.isRemote)
return EnumActionResult.PASS;
ItemStack iStack = player.getHeldItem(hand);
if (((IPressurizable) iStack.getItem()).getPressure(iStack) > 0F) {
TileEntity te = world.getTileEntity(pos);
IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
List<ITextComponent> curInfo = new ArrayList<>();
List<String> info = new ArrayList<>();
if (machine != null && machine.getAirHandler(side) != null) {
machine.getAirHandler(side).printManometerMessage(player, info);
}
if (te instanceof IManoMeasurable) {
((IManoMeasurable) te).printManometerMessage(player, info);
}
for (String s : info) curInfo.add(new TextComponentTranslation(s));
if (te instanceof IHeatExchanger) {
IHeatExchangerLogic exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(side);
if (exchanger != null) {
curInfo.add(new TextComponentTranslation("waila.temperature", (int) exchanger.getTemperature() - 273));
} else {
for (EnumFacing d : EnumFacing.VALUES) {
exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(d);
if (exchanger != null) {
curInfo.add(new TextComponentTranslation("waila.temperature." + d.toString().toLowerCase(), (int) exchanger.getTemperature() - 273));
}
}
}
}
if (curInfo.size() > 0) {
((IPressurizable) iStack.getItem()).addAir(iStack, -30);
for (ITextComponent s : curInfo) {
player.sendStatusMessage(s, false);
}
return EnumActionResult.SUCCESS;
}
} else {
player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "The Manometer doesn't have any charge!"), false);
return EnumActionResult.FAIL;
}
return EnumActionResult.PASS;
}
use of me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine in project pnc-repressurized by TeamPneumatic.
the class BlockPneumaticCraft method addProbeInfo.
@Override
@Optional.Method(modid = "theoneprobe")
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
TileEntity te = world.getTileEntity(data.getPos());
if (te instanceof IInfoForwarder) {
te = ((IInfoForwarder) te).getInfoTileEntity();
}
if (te instanceof IPneumaticMachine) {
TOPCallback.handlePneumatic(mode, probeInfo, (IPneumaticMachine) te);
}
if (te instanceof IHeatExchanger) {
TOPCallback.handleHeat(mode, probeInfo, (IHeatExchanger) te);
}
if (ConfigHandler.client.topShowsFluids && te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, data.getSideHit())) {
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, data.getSideHit());
TOPCallback.handleFluidTanks(mode, probeInfo, handler);
}
if (te instanceof TileEntityBase) {
TOPCallback.handleRedstoneMode(mode, probeInfo, (TileEntityBase) te);
}
if (te instanceof TileEntityPressureTube) {
TOPCallback.handlePressureTube(mode, probeInfo, (TileEntityPressureTube) te, data.getSideHit());
}
}
Aggregations