Search in sources :

Example 51 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project RFToolsDimensions by McJty.

the class LiquidAbsorberBlock method getWailaBody.

@SideOnly(Side.CLIENT)
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    super.getWailaBody(itemStack, currenttip, accessor, config);
    LiquidAbsorberTileEntity tileEntity = (LiquidAbsorberTileEntity) accessor.getTileEntity();
    if (tileEntity != null && tileEntity.getBlock() != null) {
        Block block = tileEntity.getBlock();
        Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
        if (fluid != null) {
            int absorbing = tileEntity.getAbsorbing();
            int pct = ((DimletConstructionConfiguration.maxLiquidAbsorbtion - absorbing) * 100) / DimletConstructionConfiguration.maxLiquidAbsorbtion;
            currenttip.add(TextFormatting.GREEN + "Liquid: " + new FluidStack(fluid, 1).getLocalizedName() + " (" + pct + "%)");
        }
    }
    return currenttip;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) Block(net.minecraft.block.Block) GenericRFToolsBlock(mcjty.rftoolsdim.blocks.GenericRFToolsBlock) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 52 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class EntityRenderChemthrowerShot method doRender.

@Override
public void doRender(Entity entity, double x, double y, double z, float f0, float f1) {
    FluidStack f = ((EntityChemthrowerShot) entity).getFluid();
    if (f == null) {
        f = ((EntityChemthrowerShot) entity).getFluidSynced();
        if (f == null)
            return;
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    GlStateManager.enableRescaleNormal();
    Tessellator tessellator = ClientUtils.tes();
    GlStateManager.disableCull();
    GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    TextureAtlasSprite sprite = ClientUtils.mc().getTextureMapBlocks().getAtlasSprite(f.getFluid().getStill(f).toString());
    if (sprite != null) {
        int colour = f.getFluid().getColor(f);
        float a = (colour >> 24 & 255) / 255f;
        float r = (colour >> 16 & 255) / 255f;
        float g = (colour >> 8 & 255) / 255f;
        float b = (colour & 255) / 255f;
        ClientUtils.bindAtlas();
        GlStateManager.scale(.25f, .25f, .25f);
        VertexBuffer worldrenderer = ClientUtils.tes().getBuffer();
        worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldrenderer.pos(-.25, -.25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(4)).color(r, g, b, a).endVertex();
        worldrenderer.pos(.25, -.25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(4)).color(r, g, b, a).endVertex();
        worldrenderer.pos(.25, .25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).color(r, g, b, a).endVertex();
        worldrenderer.pos(-.25, .25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(0)).color(r, g, b, a).endVertex();
        tessellator.draw();
    }
    GlStateManager.enableCull();
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) FluidStack(net.minecraftforge.fluids.FluidStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EntityChemthrowerShot(blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot)

Example 53 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class EntityChemthrowerShot method getGravity.

@Override
public double getGravity() {
    if (getFluid() != null) {
        FluidStack fluidStack = getFluid();
        boolean isGas = fluidStack.getFluid().isGaseous(fluidStack) || ChemthrowerHandler.isGas(fluidStack.getFluid());
        return (isGas ? .025f : .05F) * (fluidStack.getFluid().getDensity(fluidStack) < 0 ? -1 : 1);
    }
    return super.getGravity();
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack)

Example 54 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class EntityChemthrowerShot method onImpact.

@Override
public void onImpact(RayTraceResult mop) {
    if (!this.worldObj.isRemote && getFluid() != null) {
        FluidStack fluidStack = getFluid();
        Fluid fluid = fluidStack.getFluid();
        ChemthrowerEffect effect = ChemthrowerHandler.getEffect(fluid);
        boolean fire = fluid.getTemperature(fluidStack) > 1000;
        if (effect != null) {
            ItemStack thrower = null;
            EntityPlayer shooter = (EntityPlayer) this.getShooter();
            if (shooter != null)
                thrower = shooter.getHeldItem(EnumHand.MAIN_HAND);
            if (mop.typeOfHit == Type.ENTITY)
                effect.applyToEntity((EntityLivingBase) mop.entityHit, shooter, thrower, fluidStack);
            else if (mop.typeOfHit == Type.BLOCK)
                effect.applyToBlock(worldObj, mop, shooter, thrower, fluidStack);
        } else if (mop.entityHit != null && fluid.getTemperature(fluidStack) > 500) {
            int tempDiff = fluid.getTemperature(fluidStack) - 300;
            int damage = Math.abs(tempDiff) / 500;
            if (mop.entityHit.attackEntityFrom(DamageSource.lava, damage))
                mop.entityHit.hurtResistantTime = (int) (mop.entityHit.hurtResistantTime * .75);
        }
        if (mop.entityHit != null) {
            int f = this.isBurning() ? this.fire : fire ? 3 : 0;
            if (f > 0) {
                mop.entityHit.setFire(f);
                if (mop.entityHit.attackEntityFrom(DamageSource.inFire, 2))
                    mop.entityHit.hurtResistantTime = (int) (mop.entityHit.hurtResistantTime * .75);
            }
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) IEFluid(blusunrize.immersiveengineering.common.util.IEFluid) Fluid(net.minecraftforge.fluids.Fluid) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ChemthrowerEffect(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect)

Example 55 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class TileEntityWoodenBarrel method interact.

@Override
public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) {
    FluidStack f = FluidUtil.getFluidContained(heldItem);
    boolean metal = this instanceof TileEntityMetalBarrel;
    if (f != null)
        if (!metal && f.getFluid().isGaseous(f)) {
            ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO + "noGasAllowed"));
            return true;
        } else if (!metal && f.getFluid().getTemperature(f) >= TileEntityWoodenBarrel.IGNITION_TEMPERATURE) {
            ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO + "tooHot"));
            return true;
        }
    if (FluidUtil.interactWithFluidHandler(heldItem, tank, player)) {
        this.markDirty();
        this.markContainingBlockForUpdate(null);
        return true;
    }
    //		}
    return false;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) FluidStack(net.minecraftforge.fluids.FluidStack) TileEntityMetalBarrel(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMetalBarrel)

Aggregations

FluidStack (net.minecraftforge.fluids.FluidStack)188 ItemStack (net.minecraft.item.ItemStack)63 TileEntity (net.minecraft.tileentity.TileEntity)30 Fluid (net.minecraftforge.fluids.Fluid)28 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)25 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)19 ArrayList (java.util.ArrayList)18 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)16 Block (net.minecraft.block.Block)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)10 Item (net.minecraft.item.Item)9 BlockPos (net.minecraft.util.math.BlockPos)9 HashMap (java.util.HashMap)6 FluidIdentifier (logisticspipes.utils.FluidIdentifier)6 StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 PipeFluidTransportLogistics (logisticspipes.transport.PipeFluidTransportLogistics)5 IBlockState (net.minecraft.block.state.IBlockState)5 EnumFacing (net.minecraft.util.EnumFacing)5