use of net.minecraft.entity.EntityLiving in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class RotationMatrices method applyTransform.
public static final void applyTransform(double[] wholeTransform, double[] rotationTransform, Entity ent) {
Vector entityPos = new Vector(ent.posX, ent.posY, ent.posZ);
Vector entityLook = new Vector(ent.getLook(1.0F));
Vector entityMotion = new Vector(ent.motionX, ent.motionY, ent.motionZ);
if (ent instanceof EntityFireball) {
EntityFireball ball = (EntityFireball) ent;
entityMotion.X = ball.accelerationX;
entityMotion.Y = ball.accelerationY;
entityMotion.Z = ball.accelerationZ;
}
applyTransform(wholeTransform, entityPos);
doRotationOnly(rotationTransform, entityLook);
doRotationOnly(rotationTransform, entityMotion);
entityLook.normalize();
// This is correct
ent.rotationPitch = (float) MathHelper.wrapDegrees(BigBastardMath.getPitchFromVec3d(entityLook));
ent.prevRotationPitch = ent.rotationPitch;
ent.rotationYaw = (float) MathHelper.wrapDegrees(BigBastardMath.getYawFromVec3d(entityLook, ent.rotationPitch));
ent.prevRotationYaw = ent.rotationYaw;
if (ent instanceof EntityLiving) {
EntityLiving living = (EntityLiving) ent;
living.rotationYawHead = ent.rotationYaw;
living.prevRotationYawHead = ent.rotationYaw;
}
if (ent instanceof EntityFireball) {
EntityFireball ball = (EntityFireball) ent;
ball.accelerationX = entityMotion.X;
ball.accelerationY = entityMotion.Y;
ball.accelerationZ = entityMotion.Z;
}
ent.motionX = entityMotion.X;
ent.motionY = entityMotion.Y;
ent.motionZ = entityMotion.Z;
ent.setPosition(entityPos.X, entityPos.Y, entityPos.Z);
}
use of net.minecraft.entity.EntityLiving in project Realistic-Terrain-Generation by Team-RTG.
the class DisruptionSpawn method disrupt.
@Override
public void disrupt(World world, BlockPos pos, List<EntityPlayer> players) {
if (!world.isRemote) {
EntityLivingBase entityliving = null;
try {
entityliving = entity.getConstructor(World.class).newInstance(world);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
e.printStackTrace();
}
if (entityliving != null) {
entityliving.setLocationAndAngles(pos.getX(), pos.getY() + 1, pos.getZ(), entityliving.rotationYaw, entityliving.rotationPitch);
((EntityLiving) entityliving).onInitialSpawn(world.getDifficultyForLocation(pos.up()), (IEntityLivingData) null);
world.spawnEntity(entityliving);
}
}
}
use of net.minecraft.entity.EntityLiving in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method affectEntity.
/**
* Makes an entity get affected by Red Matter.
*
* @Return True if explosion happened
*/
public boolean affectEntity(float radius, Entity entity, boolean doExplosion) {
//Ignore players that are in creative mode or can't be harmed
if (entity instanceof EntityPlayer && (((EntityPlayer) entity).capabilities.isCreativeMode || ((EntityPlayer) entity).capabilities.disableDamage)) {
return false;
}
//Ignore self
if (entity == this.controller) {
return false;
}
//Ignore entities that mark themselves are ignorable
if (entity instanceof IExplosiveIgnore) {
if (((IExplosiveIgnore) entity).canIgnore(this)) {
return false;
}
}
//Calculate different from center
double xDifference = entity.posX - position.xi() + 0.5;
double yDifference = entity.posY - position.yi() + 0.5;
double zDifference = entity.posZ - position.zi() + 0.5;
/** The percentage of the closeness of the entity. */
double xPercentage = 1 - (xDifference / radius);
double yPercentage = 1 - (yDifference / radius);
double zPercentage = 1 - (zDifference / radius);
double distancePercentage = this.position.distance(entity) / radius;
Pos entityPosition = new Pos(entity);
Pos centeredPosition = entityPosition.subtract(this.position);
centeredPosition = (Pos) centeredPosition.transform(new EulerAngle(1.5 * distancePercentage * Math.random(), 1.5 * distancePercentage * Math.random(), 1.5 * distancePercentage * Math.random()));
Location newPosition = this.position.add(centeredPosition);
// Orbit Velocity
entity.addVelocity(newPosition.x() - entityPosition.x(), 0, newPosition.z() - entityPosition.z());
// Gravity Velocity (0.015 is barely enough to overcome y gravity so do not lower)
entity.addVelocity(-xDifference * 0.015 * xPercentage, -yDifference * 0.015 * yPercentage, -zDifference * 0.015 * zPercentage);
boolean explosionCreated = false;
if (new Pos(entity.posX, entity.posY, entity.posZ).distance(position) < (ENTITY_DESTROY_RADIUS * (getRadius() / NORMAL_RADIUS))) {
if (entity instanceof EntityExplosion) {
if (((EntityExplosion) entity).getBlast() instanceof BlastAntimatter) {
if (doAudio) {
this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "explosion", 7.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
}
if (this.world().rand.nextFloat() > 0.85 && !this.world().isRemote) {
entity.setDead();
return explosionCreated;
}
} else if (((EntityExplosion) entity).getBlast() instanceof BlastRedmatter) {
//https://www.wolframalpha.com/input/?i=(4%2F3)pi+*+r%5E3+%3D+(4%2F3)pi+*+a%5E3+%2B+(4%2F3)pi+*+b%5E3
//We are going to merge both blasts together
double sizeA = this.getRadius();
sizeA = sizeA * sizeA * sizeA;
double sizeB = ((EntityExplosion) entity).getBlast().getRadius();
sizeB = sizeB * sizeB * sizeB;
float radiusNew = (float) Math.cbrt(sizeA + sizeB);
//Average out timer
this.callCount = (callCount + ((EntityExplosion) entity).getBlast().callCount) / 2;
//Destroy current instance
this.isAlive = false;
this.controller.setDead();
//Create new to avoid doing packet syncing
new BlastRedmatter(world(), entity, position.x(), position.y(), position.z(), radiusNew).explode();
}
//Kill explosion entity
((EntityExplosion) entity).getBlast().isAlive = false;
//Kill entity in the center of the ball
entity.setDead();
} else if (entity instanceof EntityExplosive) {
((EntityExplosive) entity).explode();
} else if (entity instanceof EntityLiving) {
((EntityLiving) entity).attackEntityFrom(DamageSource.outOfWorld, 99999999);
} else {
//Kill entity in the center of the ball
entity.setDead();
}
}
return explosionCreated;
}
use of net.minecraft.entity.EntityLiving in project ICBM-Classic by BuiltBrokenModding.
the class BlastMutation method doExplode.
@Override
public void doExplode() {
if (!this.world().isRemote) {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - this.getRadius(), position.y() - this.getRadius(), position.z() - this.getRadius(), position.x() + this.getRadius(), position.y() + this.getRadius(), position.z() + this.getRadius());
List<EntityLiving> entitiesNearby = world().getEntitiesWithinAABB(EntityLiving.class, bounds);
for (EntityLiving entity : entitiesNearby) {
if (entity instanceof EntityPig) {
EntityPigZombie newEntity = new EntityPigZombie(world());
newEntity.preventEntitySpawning = true;
newEntity.setPosition(entity.posX, entity.posY, entity.posZ);
entity.setDead();
} else if (entity instanceof EntityVillager) {
EntityZombie newEntity = new EntityZombie(world());
newEntity.preventEntitySpawning = true;
newEntity.setPosition(entity.posX, entity.posY, entity.posZ);
entity.setDead();
}
}
}
}
use of net.minecraft.entity.EntityLiving in project BetterWithAddons by DaedalusGame.
the class TileEntityLureTree method attractAnimals.
public boolean attractAnimals(int amt) {
Random random = world.rand;
Biome biome = world.getBiome(pos);
int spawned = 0;
if (biome != null) {
List<Biome.SpawnListEntry> spawnable = biome.getSpawnableList(EnumCreatureType.CREATURE);
if (!spawnable.isEmpty())
for (int i = 0; i < amt; i++) {
Biome.SpawnListEntry entry = WeightedRandom.getRandomItem(random, spawnable);
int x = pos.getX() + random.nextInt(InteractionBWA.RADIUS * 2 + 1) - InteractionBWA.RADIUS;
int z = pos.getZ() + random.nextInt(InteractionBWA.RADIUS * 2 + 1) - InteractionBWA.RADIUS;
if (!BLACKLIST.contains(entry.entityClass)) {
for (int y = pos.getY(); y > pos.getY() - 4; y--) {
BlockPos pos = new BlockPos(x, y, z);
if (world.isAirBlock(pos) && WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, world, pos)) {
EntityLiving entityliving;
try {
entityliving = entry.entityClass.getConstructor(new Class[] { World.class }).newInstance(new Object[] { world });
} catch (Exception exception) {
exception.printStackTrace();
continue;
}
entityliving.setLocationAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, random.nextFloat() * 360.0F, 0.0F);
world.spawnEntity(entityliving);
if (entityliving != null) {
entityliving.spawnExplosionParticle();
spawned++;
}
break;
} else if (world.isSideSolid(pos, EnumFacing.UP)) {
break;
}
}
}
}
}
return spawned > 0;
}
Aggregations