Search in sources :

Example 11 with EntityFallingBlock

use of net.minecraft.entity.item.EntityFallingBlock in project Galacticraft by micdoodle8.

the class SpinManager method updateSpin.

public void updateSpin() {
    if (!this.clientSide) {
        if (this.dataNotLoaded) {
            this.savefile = OrbitSpinSaveData.initWorldData(this.worldProvider.world);
            this.readFromNBT(this.savefile.datacompound);
            if (ConfigManagerCore.enableDebug) {
                GCLog.info("Loading data from save: " + this.savefile.datacompound.getFloat("omegaSky"));
            }
            this.dataNotLoaded = false;
        }
        if (this.doSpinning) {
            boolean updateNeeded = true;
            if (this.angularVelocityTarget < this.angularVelocityRadians) {
                float newAngle = this.angularVelocityRadians - this.angularVelocityAccel;
                if (newAngle < this.angularVelocityTarget) {
                    newAngle = this.angularVelocityTarget;
                }
                this.setSpinRate(newAngle);
                this.thrustersFiring = true;
            } else if (this.angularVelocityTarget > this.angularVelocityRadians) {
                float newAngle = this.angularVelocityRadians + this.angularVelocityAccel;
                if (newAngle > this.angularVelocityTarget) {
                    newAngle = this.angularVelocityTarget;
                }
                this.setSpinRate(newAngle);
                this.thrustersFiring = true;
            } else if (this.thrustersFiring) {
                this.thrustersFiring = false;
            } else {
                updateNeeded = false;
            }
            if (updateNeeded) {
                this.writeToNBT(this.savefile.datacompound);
                this.savefile.markDirty();
                List<Object> objList = new ArrayList<Object>();
                objList.add(Float.valueOf(this.angularVelocityRadians));
                objList.add(Boolean.valueOf(this.thrustersFiring));
                GalacticraftCore.packetPipeline.sendToDimension(new PacketSimple(PacketSimple.EnumSimplePacket.C_UPDATE_STATION_SPIN, GCCoreUtil.getDimensionID(this.worldProvider), objList), GCCoreUtil.getDimensionID(this.worldProvider));
            }
        }
        // Update entity positions if in freefall
        this.loadedEntities.clear();
        this.loadedEntities.addAll(this.worldProvider.world.loadedEntityList);
        for (Entity e : this.loadedEntities) {
            // TODO: What about vehicles from GC (buggies) and other mods?
            if ((e instanceof EntityItem || e instanceof EntityLivingBase && !(e instanceof EntityPlayer) || e instanceof EntityTNTPrimed || e instanceof EntityFallingBlock) && !e.onGround) {
                AxisAlignedBB entityBoundingBox = e.getEntityBoundingBox();
                boolean outsideStation = entityBoundingBox.maxX < this.ssBoundsMinX || entityBoundingBox.minX > this.ssBoundsMaxX || entityBoundingBox.maxY < this.ssBoundsMinY || entityBoundingBox.minY > this.ssBoundsMaxY || entityBoundingBox.maxZ < this.ssBoundsMinZ || entityBoundingBox.minZ > this.ssBoundsMaxZ;
                if (outsideStation || FreefallHandler.testEntityFreefall(this.worldProvider.world, entityBoundingBox)) {
                    if (this.doSpinning) {
                        this.moveRotatedEntity(e, this.spinCentreX, this.spinCentreZ, this.angularVelocityRadians);
                    }
                    FreefallHandler.tickFreefallEntity(e);
                    if (e instanceof ITumblable) {
                        ((ITumblable) e).setTumbling(3F);
                    }
                } else {
                    if (e instanceof ITumblable) {
                        ((ITumblable) e).setTumbling(0F);
                    }
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) EntityTNTPrimed(net.minecraft.entity.item.EntityTNTPrimed) ArrayList(java.util.ArrayList) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) ITumblable(micdoodle8.mods.galacticraft.core.entities.ITumblable) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityItem(net.minecraft.entity.item.EntityItem)

Example 12 with EntityFallingBlock

use of net.minecraft.entity.item.EntityFallingBlock in project BluePower by Qmunity.

the class BlockCrackedBasalt method spawnLava.

private void spawnLava(World world, int x, int y, int z, Random random) {
    if (DateEventHandler.isEvent(Event.NEW_YEAR)) {
        DateEventHandler.spawnFirework(world, x + 0.5, y + 0.5, z + 0.5);
    } else {
        EntityFallingBlock entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, DateEventHandler.isEvent(Event.HALLOWEEN) ? Blocks.lit_pumpkin : Blocks.flowing_lava);
        entity.motionY = 1 + random.nextDouble();
        entity.motionX = (random.nextDouble() - 0.5) * 0.8D;
        entity.motionZ = (random.nextDouble() - 0.5) * 0.8D;
        // make this field that keeps track of the ticks set to 1, so it doesn't kill itself when it searches for a lava
        entity.field_145812_b = 1;
        // block.
        // disable item drops when the falling block fails to place.
        entity.field_145813_c = false;
        world.spawnEntityInWorld(entity);
    }
}
Also used : EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock)

Example 13 with EntityFallingBlock

use of net.minecraft.entity.item.EntityFallingBlock in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ValkyrienWarfareWorldEventListener method onEntityAdded.

@Override
public void onEntityAdded(Entity entityIn) {
    int oldChunkX = MathHelper.floor_double(entityIn.posX / 16.0D);
    int oldChunkZ = MathHelper.floor_double(entityIn.posZ / 16.0D);
    BlockPos posAt = new BlockPos(entityIn);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldObj, posAt);
    if (!(entityIn instanceof EntityFallingBlock) && wrapper != null && wrapper.wrapping.coordTransform != null) {
        if (entityIn instanceof EntityMountingWeaponBase || entityIn instanceof EntityArmorStand || entityIn instanceof EntityPig || entityIn instanceof EntityBoat) {
            //				entity.startRiding(wrapper);
            wrapper.wrapping.fixEntity(entityIn, new Vector(entityIn));
            wrapper.wrapping.queueEntityForMounting(entityIn);
        }
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, entityIn);
        int newChunkX = MathHelper.floor_double(entityIn.posX / 16.0D);
        int newChunkZ = MathHelper.floor_double(entityIn.posZ / 16.0D);
        worldObj.getChunkFromChunkCoords(oldChunkX, oldChunkZ).removeEntity(entityIn);
        worldObj.getChunkFromChunkCoords(newChunkX, newChunkZ).addEntity(entityIn);
    }
    if (entityIn instanceof PhysicsWrapperEntity) {
        ValkyrienWarfareMod.physicsManager.onShipLoad((PhysicsWrapperEntity) entityIn);
    }
    if (entityIn.getEntityWorld().isRemote) {
        PhysicsWrapperEntity shipFixOnto = ValkyrienWarfareMod.physicsManager.getManagerForWorld(entityIn.worldObj).getShipFixedOnto(entityIn, true);
        if (shipFixOnto != null) {
            //				System.out.println("Ye");
            entityIn.startRiding(shipFixOnto, true);
        }
    }
}
Also used : EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPig(net.minecraft.entity.passive.EntityPig) EntityBoat(net.minecraft.entity.item.EntityBoat) BlockPos(net.minecraft.util.math.BlockPos) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) Vector(ValkyrienWarfareBase.API.Vector) EntityMountingWeaponBase(ValkyrienWarfareCombat.Entity.EntityMountingWeaponBase)

Example 14 with EntityFallingBlock

use of net.minecraft.entity.item.EntityFallingBlock in project MorePlanets by SteveKunG.

the class BlockCreep method checkFallable.

private void checkFallable(World world, BlockPos pos) {
    boolean north = world.getBlockState(pos.north()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(pos.north()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR;
    boolean east = world.getBlockState(pos.east()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(pos.east()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR;
    boolean south = world.getBlockState(pos.south()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(pos.south()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR;
    boolean west = world.getBlockState(pos.west()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(pos.west()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR;
    boolean up = world.getBlockState(pos.up()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(pos.up()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR;
    if ((world.isAirBlock(pos.down()) || world.getBlockState(pos.down()).getBlock() == MPBlocks.GRAVITY_CREEP_VINES || BlockFalling.canFallThrough(world.getBlockState(pos.down()))) && north && east && south && west && up && pos.getY() >= 0) {
        if (!fallInstantly && world.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32))) {
            if (!world.isRemote) {
                EntityFallingBlock block = new EntityFallingBlock(world, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, world.getBlockState(pos));
                this.onStartFalling(block);
                world.spawnEntity(block);
            }
        } else {
            IBlockState state = world.getBlockState(pos);
            world.setBlockToAir(pos);
            BlockPos blockpos;
            for (blockpos = pos.down(); (world.isAirBlock(blockpos) || world.getBlockState(blockpos.down()).getBlock() == MPBlocks.GRAVITY_CREEP_VINES || BlockFalling.canFallThrough(world.getBlockState(blockpos))) && world.getBlockState(blockpos.north()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(blockpos.east()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(blockpos.south()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(blockpos.west()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(blockpos.up()).getBlock() != MPBlocks.GRAVITY_CREEP_BLOCK && world.getBlockState(blockpos.north()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR && world.getBlockState(blockpos.east()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR && world.getBlockState(blockpos.south()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR && world.getBlockState(blockpos.west()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR && world.getBlockState(blockpos.up()).getBlock() != MPBlocks.GRAVITY_CREEP_EXTRACTOR && blockpos.getY() > 0; blockpos = blockpos.down()) {
            }
            if (blockpos.getY() > 0) {
                world.setBlockState(blockpos.up(), state);
            }
        }
    }
}
Also used : EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos)

Example 15 with EntityFallingBlock

use of net.minecraft.entity.item.EntityFallingBlock in project Armourers-Workshop by RiskyKen.

the class DollCraftingHandler method onEntityDestroy.

@Override
public void onEntityDestroy(Entity entity) {
    World world = entity.worldObj;
    if (!world.isRemote) {
        if (entity instanceof EntityFallingBlock) {
            if (((EntityFallingBlock) entity).func_145805_f() == Blocks.anvil) {
                int x = MathHelper.floor_double(entity.posX);
                int y = MathHelper.floor_double(entity.posY) - 1;
                int z = MathHelper.floor_double(entity.posZ);
                Block block = world.getBlock(x, y, z);
                if (block == ModBlocks.mannequin) {
                    ((BlockMannequin) block).convertToDoll(world, x, y, z);
                }
            }
        }
    }
}
Also used : BlockMannequin(riskyken.armourersWorkshop.common.blocks.BlockMannequin) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) Block(net.minecraft.block.Block) World(net.minecraft.world.World)

Aggregations

EntityFallingBlock (net.minecraft.entity.item.EntityFallingBlock)17 BlockPos (net.minecraft.util.math.BlockPos)8 Block (net.minecraft.block.Block)4 EntityArmorStand (net.minecraft.entity.item.EntityArmorStand)4 IBlockState (net.minecraft.block.state.IBlockState)3 Entity (net.minecraft.entity.Entity)3 EntityBoat (net.minecraft.entity.item.EntityBoat)3 EntityPig (net.minecraft.entity.passive.EntityPig)3 World (net.minecraft.world.World)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityItem (net.minecraft.entity.item.EntityItem)2 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (org.spongepowered.api.block.tileentity.TileEntity)2 Entity (org.spongepowered.api.entity.Entity)2 IMixinTileEntity (org.spongepowered.common.interfaces.block.tile.IMixinTileEntity)2 IMixinEntity (org.spongepowered.common.interfaces.entity.IMixinEntity)2 EntityMountable (org.valkyrienskies.mod.common.entity.EntityMountable)2 Vector (ValkyrienWarfareBase.API.Vector)1 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 EntityMountingWeaponBase (ValkyrienWarfareCombat.Entity.EntityMountingWeaponBase)1