Java Code Examples for net.minecraftforge.fluids.FluidTank#getFluid()
The following examples show how to use
net.minecraftforge.fluids.FluidTank#getFluid() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SemiBlockLogistics.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound tag){ super.writeToNBT(tag); TileEntityBase.writeInventoryToNBT(tag, filters, "filters"); NBTTagList tagList = new NBTTagList(); for(int i = 0; i < fluidFilters.length; i++) { FluidTank filter = fluidFilters[i]; if(filter.getFluid() != null) { NBTTagCompound t = new NBTTagCompound(); t.setInteger("index", i); filter.writeToNBT(t); tagList.appendTag(t); } } tag.setTag("fluidFilters", tagList); tag.setBoolean("invisible", invisible); }
Example 2
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
private FluidStack getActualTankFluid() { FluidTank fluidTank = getActualFluidTank(); return fluidTank == null ? null : fluidTank.getFluid(); }
Example 3
Source File: BarrelModeFluid.java From ExNihiloAdscensio with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public void update(TileBarrel barrel) { // Fluids on top. if (barrel.getTank().getFluid() != null) { FluidTank tank = barrel.getTank(); if (tank.getFluid().amount != tank.getCapacity()) return; Fluid fluidInBarrel = tank.getFluid().getFluid(); BlockPos barrelPos = barrel.getPos(); BlockPos pos = new BlockPos(barrelPos.getX(), barrelPos.getY() + 1, barrelPos.getZ()); Block onTop = barrel.getWorld().getBlockState(pos).getBlock(); Fluid fluidOnTop = null; if (onTop instanceof BlockLiquid) { fluidOnTop = onTop.getMaterial(barrel.getWorld().getBlockState(pos)) == Material.WATER ? FluidRegistry.WATER : FluidRegistry.LAVA; } if (onTop != null && onTop instanceof IFluidBlock) { fluidOnTop = ((BlockFluidBase) onTop).getFluid(); } if (FluidOnTopRegistry.isValidRecipe(fluidInBarrel, fluidOnTop)) { ItemInfo info = FluidOnTopRegistry.getTransformedBlock(fluidInBarrel, fluidOnTop); tank.drain(tank.getCapacity(), true); barrel.setMode("block"); PacketHandler.sendToAllAround(new MessageBarrelModeUpdate("block", barrel.getPos()), barrel); barrel.getMode().addItem(info.getItemStack(), barrel); return; } // Fluid transforming time! if (FluidTransformRegistry.containsKey(barrel.getTank().getFluid().getFluid().getName())) { List<FluidTransformer> transformers = FluidTransformRegistry .getFluidTransformers(barrel.getTank().getFluid().getFluid().getName()); boolean found = false; for (int radius = 0; radius <= 2; radius++) { for (FluidTransformer transformer : transformers) { if (!BarrelLiquidBlacklistRegistry.isBlacklisted(barrel.getTier(), transformer.getOutputFluid()) && (Util.isSurroundingBlocksAtLeastOneOf(transformer.getTransformingBlocks(), barrel.getPos().add(0, -1, 0), barrel.getWorld(), radius) || Util.isSurroundingBlocksAtLeastOneOf(transformer.getTransformingBlocks(), barrel.getPos(), barrel.getWorld(), radius))) { // Time to start the process. FluidStack fstack = tank.getFluid(); tank.setFluid(null); barrel.setMode("fluidTransform"); BarrelModeFluidTransform mode = (BarrelModeFluidTransform) barrel.getMode(); mode.setTransformer(transformer); mode.setInputStack(fstack); mode.setOutputStack(FluidRegistry.getFluidStack(transformer.getOutputFluid(), 1000)); PacketHandler.sendNBTUpdate(barrel); found = true; } } if (found) break; } } } }
Example 4
Source File: SyncedField.java From Signals with GNU General Public License v3.0 | 4 votes |
@Override protected FluidStack retrieveValue(Field field, Object te) throws Exception{ FluidTank tank = (FluidTank)field.get(te); return tank.getFluid(); }
Example 5
Source File: TESRBTank.java From BetterChests with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void render(TileEntityBTank te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { FluidTank tank = te.getTank(); FluidStack stack = tank.getFluid(); if (stack != null) { float fillPercentage = ((float)stack.amount) / tank.getCapacity(); boolean gaseous = stack.getFluid().isGaseous(stack); GlStateManager.pushMatrix(); GL11.glEnable(GL11.GL_BLEND); ResourceLocation loc = stack.getFluid().getStill(stack); TextureAtlasSprite sprite = RenderHelper.getAtlasSprite(loc); RenderHelper.bindBlockTexture(); float minY = !gaseous ? 0 : 1 - fillPercentage; float maxY = gaseous ? 1 : fillPercentage; float minU = sprite.getMinU(); float maxU = sprite.getMaxU(); float minV = sprite.getMinV(); float maxV = sprite.getMaxV(); float minVHorizontal = minV + (maxV - minV) * minY; float maxVHorizontal = minV + (maxV - minV) * maxY; GlStateManager.translate(x, y, z); GlStateManager.translate(0.5, 0.5, 0.5); GlStateManager.scale(12/16D, 12/16D, 12/16D); GlStateManager.translate(-0.5, -0.5, -0.5); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder builder = tessellator.getBuffer(); //south builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); builder.pos(0, minY, 1).tex(minU, minVHorizontal).endVertex(); builder.pos(1, minY, 1).tex(maxU, minVHorizontal).endVertex(); builder.pos(1, maxY, 1).tex(maxU, maxVHorizontal).endVertex(); builder.pos(0, maxY, 1).tex(minU, maxVHorizontal).endVertex(); tessellator.draw(); //north builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); builder.pos(1, minY, 0).tex(minU, minVHorizontal).endVertex(); builder.pos(0, minY, 0).tex(maxU, minVHorizontal).endVertex(); builder.pos(0, maxY, 0).tex(maxU, maxVHorizontal).endVertex(); builder.pos(1, maxY, 0).tex(minU, maxVHorizontal).endVertex(); tessellator.draw(); //east builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); builder.pos(1, minY, 1).tex(minU, minVHorizontal).endVertex(); builder.pos(1, minY, 0).tex(maxU, minVHorizontal).endVertex(); builder.pos(1, maxY, 0).tex(maxU, maxVHorizontal).endVertex(); builder.pos(1, maxY, 1).tex(minU, maxVHorizontal).endVertex(); tessellator.draw(); //west builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); builder.pos(0, minY, 0).tex(minU, minVHorizontal).endVertex(); builder.pos(0, minY, 1).tex(maxU, minVHorizontal).endVertex(); builder.pos(0, maxY, 1).tex(maxU, maxVHorizontal).endVertex(); builder.pos(0, maxY, 0).tex(minU, maxVHorizontal).endVertex(); tessellator.draw(); //up builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); builder.pos(1, maxY, 0).tex(minU, minV).endVertex(); builder.pos(0, maxY, 0).tex(maxU, minV).endVertex(); builder.pos(0, maxY, 1).tex(maxU, maxV).endVertex(); builder.pos(1, maxY, 1).tex(minU, maxV).endVertex(); tessellator.draw(); //down builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); builder.pos(0, minY, 0).tex(minU, minV).endVertex(); builder.pos(1, minY, 0).tex(maxU, minV).endVertex(); builder.pos(1, minY, 1).tex(maxU, maxV).endVertex(); builder.pos(0, minY, 1).tex(minU, maxV).endVertex(); tessellator.draw(); GL11.glDisable(GL11.GL_BLEND); GlStateManager.popMatrix(); } }
Example 6
Source File: SyncedField.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override protected FluidStack retrieveValue(Field field, Object te) throws Exception{ FluidTank tank = (FluidTank)field.get(te); return tank.getFluid(); }