Search in sources :

Example 1 with TileEntityHeatSink

use of me.desht.pneumaticcraft.common.tileentity.TileEntityHeatSink in project pnc-repressurized by TeamPneumatic.

the class BlockHeatSink method onEntityCollidedWithBlock.

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof TileEntityHeatSink && entity instanceof EntityLivingBase) {
        IHeatExchangerLogic heat = ((TileEntityHeatSink) te).getHeatExchangerLogic(null);
        int temp = (int) ((TileEntityHeatSink) te).getHeatExchangerLogic(null).getTemperature();
        if (temp > 323) {
            // +50C
            entity.attackEntityFrom(DamageSource.HOT_FLOOR, 2);
            if (temp > 373) {
                // +100C
                entity.setFire(3);
            }
        } else if (temp < 243) {
            // -30C
            int durationSec = (243 - (int) heat.getTemperature()) / 10;
            int amplifier = (243 - (int) heat.getTemperature()) / 80;
            ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, durationSec * 20, amplifier));
            if (temp < 213) {
                // -60C
                entity.attackEntityFrom(DamageSourcePneumaticCraft.FREEZING, 2);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) TileEntityHeatSink(me.desht.pneumaticcraft.common.tileentity.TileEntityHeatSink) IHeatExchangerLogic(me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)

Example 2 with TileEntityHeatSink

use of me.desht.pneumaticcraft.common.tileentity.TileEntityHeatSink in project pnc-repressurized by TeamPneumatic.

the class ModuleAirGrate method coolHeatSinks.

private void coolHeatSinks(World world, BlockPos pos, int range) {
    if (grateRange > 2) {
        int curTeIndex = (int) (world.getTotalWorldTime() % 27);
        BlockPos curPos = pos.offset(dir, 2).add(-1 + curTeIndex % 3, -1 + curTeIndex / 3 % 3, -1 + curTeIndex / 9 % 3);
        TileEntity te = world.getTileEntity(curPos);
        if (te instanceof TileEntityHeatSink)
            heatSinks.add((TileEntityHeatSink) te);
        Iterator<TileEntityHeatSink> iterator = heatSinks.iterator();
        while (iterator.hasNext()) {
            TileEntityHeatSink heatSink = iterator.next();
            if (heatSink.isInvalid()) {
                iterator.remove();
            } else {
                for (int i = 0; i < 4; i++) heatSink.onFannedByAirGrate();
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos) TileEntityHeatSink(me.desht.pneumaticcraft.common.tileentity.TileEntityHeatSink)

Aggregations

TileEntityHeatSink (me.desht.pneumaticcraft.common.tileentity.TileEntityHeatSink)2 TileEntity (net.minecraft.tileentity.TileEntity)2 IHeatExchangerLogic (me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 PotionEffect (net.minecraft.potion.PotionEffect)1 BlockPos (net.minecraft.util.math.BlockPos)1