Search in sources :

Example 1 with TileEntityFallenMeteor

use of micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor in project Galacticraft by micdoodle8.

the class BlockFallenMeteor method onEntityCollidedWithBlock.

@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, Entity entityIn) {
    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile instanceof TileEntityFallenMeteor) {
        TileEntityFallenMeteor meteor = (TileEntityFallenMeteor) tile;
        if (meteor.getHeatLevel() <= 0) {
            return;
        }
        if (entityIn instanceof EntityLivingBase) {
            final EntityLivingBase livingEntity = (EntityLivingBase) entityIn;
            worldIn.playSoundEffect(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
            for (int var5 = 0; var5 < 8; ++var5) {
                worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX() + Math.random(), pos.getY() + 0.2D + Math.random(), pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
            }
            if (!livingEntity.isBurning()) {
                livingEntity.setFire(2);
            }
            double var9 = pos.getX() + 0.5F - livingEntity.posX;
            double var7;
            for (var7 = livingEntity.posZ - pos.getZ(); var9 * var9 + var7 * var7 < 1.0E-4D; var7 = (Math.random() - Math.random()) * 0.01D) {
                var9 = (Math.random() - Math.random()) * 0.01D;
            }
            livingEntity.knockBack(livingEntity, 1, var9, var7);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityFallenMeteor(micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 2 with TileEntityFallenMeteor

use of micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor in project Galacticraft by micdoodle8.

the class BlockFallenMeteor method tryToFall.

private void tryToFall(World world, BlockPos pos, IBlockState state) {
    if (this.canFallBelow(world, pos.down()) && pos.getY() >= 0) {
        int prevHeatLevel = ((TileEntityFallenMeteor) world.getTileEntity(pos)).getHeatLevel();
        world.setBlockState(pos, Blocks.air.getDefaultState(), 3);
        BlockPos blockpos1;
        for (blockpos1 = pos.down(); this.canFallBelow(world, blockpos1) && blockpos1.getY() > 0; blockpos1 = blockpos1.down()) {
        }
        if (blockpos1.getY() >= 0) {
            world.setBlockState(blockpos1.up(), state, 3);
            ((TileEntityFallenMeteor) world.getTileEntity(blockpos1.up())).setHeatLevel(prevHeatLevel);
        }
    }
}
Also used : TileEntityFallenMeteor(micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor) BlockPos(net.minecraft.util.BlockPos)

Example 3 with TileEntityFallenMeteor

use of micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor in project Galacticraft by micdoodle8.

the class BlockFallenMeteor method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack itemStack) {
    world.setBlockState(pos, this.getDefaultState(), 3);
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityFallenMeteor) {
        ((TileEntityFallenMeteor) tile).setHeatLevel(0);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityFallenMeteor(micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor)

Example 4 with TileEntityFallenMeteor

use of micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor in project Galacticraft by micdoodle8.

the class BlockFallenMeteor method colorMultiplier.

@Override
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) {
    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile instanceof TileEntityFallenMeteor) {
        TileEntityFallenMeteor meteor = (TileEntityFallenMeteor) tile;
        Vector3 col = new Vector3(198, 108, 58);
        col.translate(200 - meteor.getScaledHeatLevel() * 200);
        col.x = Math.min(255, col.x);
        col.y = Math.min(255, col.y);
        col.z = Math.min(255, col.z);
        return ColorUtil.to32BitColor(255, (byte) col.x, (byte) col.y, (byte) col.z);
    }
    return super.colorMultiplier(worldIn, pos, renderPass);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityFallenMeteor(micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Aggregations

TileEntityFallenMeteor (micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor)4 TileEntity (net.minecraft.tileentity.TileEntity)3 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 BlockPos (net.minecraft.util.BlockPos)1