use of net.minecraft.entity.item.EntityFallingBlock in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class VSWorldEventListener method onEntityAdded.
// TODO: Fix conflicts with EventsCommon.onEntityJoinWorldEvent()
@Override
public void onEntityAdded(Entity entity) {
// This is really only here because Sponge doesn't call the entity join event for some reason :/
// So I basically just copied the event code here as well.
World world = worldObj;
BlockPos posAt = new BlockPos(entity);
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, posAt);
if (!worldObj.isRemote && physicsObject.isPresent() && !(entity instanceof EntityFallingBlock)) {
if (entity instanceof EntityArmorStand || entity instanceof EntityPig || entity instanceof EntityBoat) {
EntityMountable entityMountable = new EntityMountable(world, entity.getPositionVector(), CoordinateSpaceType.SUBSPACE_COORDINATES, posAt);
world.spawnEntity(entityMountable);
entity.startRiding(entityMountable);
}
world.getChunk(entity.getPosition().getX() >> 4, entity.getPosition().getZ() >> 4).removeEntity(entity);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transform(entity, TransformType.SUBSPACE_TO_GLOBAL, false);
world.getChunk(entity.getPosition().getX() >> 4, entity.getPosition().getZ() >> 4).addEntity(entity);
}
}
use of net.minecraft.entity.item.EntityFallingBlock in project BetterWithAddons by DaedalusGame.
the class BlockChandelier method checkAndDrop.
public void checkAndDrop(World worldIn, BlockPos pos) {
if (!worldIn.isRemote && !canBlockStay(worldIn, pos) && worldIn.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32))) {
EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, worldIn.getBlockState(pos));
entityfallingblock.shouldDropItem = true;
entityfallingblock.setHurtEntities(true);
worldIn.spawnEntity(entityfallingblock);
}
}
use of net.minecraft.entity.item.EntityFallingBlock in project BetterWithAddons by DaedalusGame.
the class FallingPlatformHandler method dropPlatform.
private void dropPlatform(World world, BlockPos pos) {
BlockPos anchorpos = pos.down();
IBlockState blockstate = world.getBlockState(anchorpos);
Block block = blockstate.getBlock();
if (!world.isRemote && block == BWMBlocks.ANCHOR && !isAnchorSupported(world, anchorpos)) {
EnumFacing facing = blockstate.getValue(DirUtils.FACING);
HashSet<BlockPos> platformBlocks = new HashSet<>();
boolean success = findPlatformPart(world, anchorpos, platformBlocks);
if (success)
for (BlockPos plat : platformBlocks) {
EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) plat.getX() + 0.5D, (double) plat.getY(), (double) plat.getZ() + 0.5D, world.getBlockState(plat));
entityfallingblock.setHurtEntities(true);
world.spawnEntity(entityfallingblock);
}
}
}
use of net.minecraft.entity.item.EntityFallingBlock in project MorePlanets by SteveKunG.
the class EntityBlackHole method spawnFallingBlock.
private void spawnFallingBlock() {
int blockPosX = MathHelper.floor(this.posX);
int blockPosY = MathHelper.floor(this.posY);
int blockPosZ = MathHelper.floor(this.posZ);
int radius = 1 + this.spawnBlockRadiusTick;
for (int x = -radius; x < radius; x++) {
for (int y = -radius; y < radius; y++) {
for (int z = -radius; z < radius; z++) {
double dist = MathHelper.sqrt(x * x + y * y + z * z);
if (dist <= radius) {
BlockPos pos = new BlockPos(blockPosX + x, blockPosY + y, blockPosZ + z);
IBlockState state = this.world.getBlockState(pos);
Block block = state.getBlock();
if (!block.isAir(state, this.world, pos)) {
this.world.setBlockToAir(pos);
EntityFallingBlock fallingBlock = new EntityFallingBlock(this.world, blockPosX + x, blockPosY + y, blockPosZ + z, state);
fallingBlock.fallTime = 1;
fallingBlock.shouldDropItem = false;
fallingBlock.motionY += 0.5D;
fallingBlock.setLocationAndAngles(blockPosX + x + 0.5D, blockPosY + y, blockPosZ + z + 0.5D, 0.0F, 0.0F);
this.world.spawnEntity(fallingBlock);
}
}
}
}
}
}
use of net.minecraft.entity.item.EntityFallingBlock in project Galacticraft by micdoodle8.
the class FreefallHandler method tickFreefallEntity.
/**
* Call this on every freefalling non-player entity in a dimension
* either at the end of the world tick (ideal) or else during the
* start of the next world tick (e.g. during updateWeather())
*
* May require iteration through the world's loadedEntityList
* See SpinManager.updateSpin() for an example
* @param e
*/
public static void tickFreefallEntity(Entity e) {
if (e.world.provider instanceof IZeroGDimension)
((IZeroGDimension) e.world.provider).setInFreefall(e);
// Undo deceleration applied at the end of the previous tick
boolean warnLog = false;
if (e instanceof EntityLivingBase) {
ZeroGravityEvent zeroGEvent = new ZeroGravityEvent.InFreefall((EntityLivingBase) e);
MinecraftForge.EVENT_BUS.post(zeroGEvent);
if (!zeroGEvent.isCanceled()) {
// 0.91F;
e.motionX /= (double) 0.91F;
// 0.91F;
e.motionZ /= (double) 0.91F;
e.motionY /= (e instanceof EntityFlying) ? 0.91F : 0.9800000190734863D;
if (e.motionX > 10D) {
warnLog = true;
e.motionX = 10D;
} else if (e.motionX < -10D) {
warnLog = true;
e.motionX = -10D;
}
if (e.motionY > 10D) {
warnLog = true;
e.motionY = 10D;
} else if (e.motionY < -10D) {
warnLog = true;
e.motionY = -10D;
}
if (e.motionZ > 10D) {
warnLog = true;
e.motionZ = 10D;
} else if (e.motionZ < -10D) {
warnLog = true;
e.motionZ = -10D;
}
}
} else if (e instanceof EntityFallingBlock) {
e.motionY /= 0.9800000190734863D;
// e.lastTickPosY += 0.03999999910593033D;
if (e.motionY > 10D) {
warnLog = true;
e.motionY = 10D;
} else if (e.motionY < -10D) {
warnLog = true;
e.motionY = -10D;
}
} else {
e.motionX /= 0.9800000190734863D;
e.motionY /= 0.9800000190734863D;
e.motionZ /= 0.9800000190734863D;
if (e.motionX > 10D) {
warnLog = true;
e.motionX = 10D;
} else if (e.motionX < -10D) {
warnLog = true;
e.motionX = -10D;
}
if (e.motionY > 10D) {
warnLog = true;
e.motionY = 10D;
} else if (e.motionY < -10D) {
warnLog = true;
e.motionY = -10D;
}
if (e.motionZ > 10D) {
warnLog = true;
e.motionZ = 10D;
} else if (e.motionZ < -10D) {
warnLog = true;
e.motionZ = -10D;
}
}
if (warnLog)
GCLog.debug(e.getName() + " moving too fast");
}
Aggregations