Search in sources :

Example 1 with EntityChemthrowerShot

use of blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot 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 2 with EntityChemthrowerShot

use of blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot in project ImmersiveEngineering by BluSunrize.

the class ItemChemthrower method onUsingTick.

@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {
    FluidStack fs = this.getFluid(stack);
    if (fs != null && fs.getFluid() != null) {
        int duration = getMaxItemUseDuration(stack) - count;
        int consumed = IEConfig.Tools.chemthrower_consumption;
        if (consumed * duration <= fs.amount) {
            Vec3d v = player.getLookVec();
            int split = 8;
            boolean isGas = fs.getFluid().isGaseous() || ChemthrowerHandler.isGas(fs.getFluid());
            float scatter = isGas ? .15f : .05f;
            float range = isGas ? .5f : 1f;
            if (getUpgrades(stack).getBoolean("focus")) {
                range += .25f;
                scatter -= .025f;
            }
            boolean ignite = ChemthrowerHandler.isFlammable(fs.getFluid()) && ItemNBTHelper.getBoolean(stack, "ignite");
            for (int i = 0; i < split; i++) {
                Vec3d vecDir = v.addVector(player.getRNG().nextGaussian() * scatter, player.getRNG().nextGaussian() * scatter, player.getRNG().nextGaussian() * scatter);
                EntityChemthrowerShot chem = new EntityChemthrowerShot(player.worldObj, player, vecDir.xCoord * 0.25, vecDir.yCoord * 0.25, vecDir.zCoord * 0.25, fs);
                chem.motionX = vecDir.xCoord * range;
                chem.motionY = vecDir.yCoord * range;
                chem.motionZ = vecDir.zCoord * range;
                if (ignite)
                    chem.setFire(10);
                if (!player.worldObj.isRemote)
                    player.worldObj.spawnEntityInWorld(chem);
            }
            if (count % 4 == 0) {
                if (ignite)
                    player.playSound(IESounds.sprayFire, .5f, 1.5f);
                else
                    player.playSound(IESounds.spray, .5f, .75f);
            }
        } else
            player.stopActiveHand();
    } else
        player.stopActiveHand();
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EntityChemthrowerShot(blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with EntityChemthrowerShot

use of blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot in project ImmersiveEngineering by BluSunrize.

the class TileEntityTurretChem method activate.

@Override
protected void activate() {
    FluidStack fs = this.tank.getFluid();
    if (fs != null && fs.getFluid() != null) {
        int consumed = IEConfig.Tools.chemthrower_consumption;
        int energy = IEConfig.Machines.turret_chem_consumption;
        if (consumed <= fs.amount && this.energyStorage.extractEnergy(energy, true) >= energy) {
            tank.drain(consumed, true);
            this.energyStorage.extractEnergy(energy, false);
            double dX = target.posX - (getPos().getX() + .5);
            double dY = target.posY - (getPos().getY() + .5);
            double dZ = target.posZ - (getPos().getZ() + .5);
            Vec3d v = new Vec3d(dX, dY, dZ).normalize();
            int split = 8;
            boolean isGas = fs.getFluid().isGaseous() || ChemthrowerHandler.isGas(fs.getFluid());
            float scatter = isGas ? .15f : .05f;
            float range = isGas ? .5f : 1f;
            //				if(getUpgrades(stack).getBoolean("focus"))
            //				{
            //					range += .25f;
            //					scatter -= .025f;
            //				}
            boolean ignite = ChemthrowerHandler.isFlammable(fs.getFluid()) && this.ignite;
            for (int i = 0; i < split; i++) {
                Vec3d vecDir = v.addVector(worldObj.rand.nextGaussian() * scatter, worldObj.rand.nextGaussian() * scatter, worldObj.rand.nextGaussian() * scatter);
                EntityChemthrowerShot chem = new EntityChemthrowerShot(worldObj, getPos().getX() + .5 + v.xCoord * 0.875, getPos().getY() + 1.5 + v.yCoord * 0.875, getPos().getZ() + .5 + v.zCoord * 0.875, 0, 0, 0, fs);
                chem.motionX = vecDir.xCoord * range;
                chem.motionY = vecDir.yCoord * range;
                chem.motionZ = vecDir.zCoord * range;
                if (ignite)
                    chem.setFire(10);
                if (!worldObj.isRemote)
                    worldObj.spawnEntityInWorld(chem);
            }
            if (tick % 4 == 0)
                if (ignite)
                    worldObj.playSound(null, getPos(), IESounds.sprayFire, SoundCategory.BLOCKS, .5F, 1.5F);
                else
                    worldObj.playSound(null, getPos(), IESounds.spray, SoundCategory.BLOCKS, .5F, .75F);
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EntityChemthrowerShot(blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

EntityChemthrowerShot (blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot)3 FluidStack (net.minecraftforge.fluids.FluidStack)3 Vec3d (net.minecraft.util.math.Vec3d)2 Tessellator (net.minecraft.client.renderer.Tessellator)1 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1