Search in sources :

Example 1 with IPneumaticMachine

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPneumaticMachine(me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine) Nonnull(javax.annotation.Nonnull)

Example 2 with IPneumaticMachine

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) PacketDescriptionPacketRequest(me.desht.pneumaticcraft.common.network.PacketDescriptionPacketRequest) IPneumaticMachine(me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine) TileEntityPneumaticBase(me.desht.pneumaticcraft.common.tileentity.TileEntityPneumaticBase) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with IPneumaticMachine

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"));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPneumaticMachine(me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with IPneumaticMachine

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;
}
Also used : IPressurizable(me.desht.pneumaticcraft.api.item.IPressurizable) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IManoMeasurable(me.desht.pneumaticcraft.api.tileentity.IManoMeasurable) EnumFacing(net.minecraft.util.EnumFacing) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString) TileEntity(net.minecraft.tileentity.TileEntity) IHeatExchanger(me.desht.pneumaticcraft.api.tileentity.IHeatExchanger) IPneumaticMachine(me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine) ItemStack(net.minecraft.item.ItemStack) IHeatExchangerLogic(me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)

Example 5 with IPneumaticMachine

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());
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IHeatExchanger(me.desht.pneumaticcraft.api.tileentity.IHeatExchanger) IPneumaticMachine(me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine) IInfoForwarder(me.desht.pneumaticcraft.common.thirdparty.waila.IInfoForwarder) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Aggregations

IPneumaticMachine (me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine)6 TileEntity (net.minecraft.tileentity.TileEntity)6 IAirHandler (me.desht.pneumaticcraft.api.tileentity.IAirHandler)2 IHeatExchanger (me.desht.pneumaticcraft.api.tileentity.IHeatExchanger)2 EnumFacing (net.minecraft.util.EnumFacing)2 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 IHeatExchangerLogic (me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)1 IPressurizable (me.desht.pneumaticcraft.api.item.IPressurizable)1 IManoMeasurable (me.desht.pneumaticcraft.api.tileentity.IManoMeasurable)1 PacketDescriptionPacketRequest (me.desht.pneumaticcraft.common.network.PacketDescriptionPacketRequest)1 IInfoForwarder (me.desht.pneumaticcraft.common.thirdparty.waila.IInfoForwarder)1 TileEntityPneumaticBase (me.desht.pneumaticcraft.common.tileentity.TileEntityPneumaticBase)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 BlockPos (net.minecraft.util.math.BlockPos)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1