fix dragons

This commit is contained in:
Sen 2025-08-05 19:21:20 +02:00
parent da3dfaf37c
commit 9a31abbb41
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
20 changed files with 271 additions and 995 deletions

View file

@ -387,18 +387,6 @@ public class ClientPlayer implements IClientPlayer
entity.serverPosZ = packetIn.getZ();
entity.rotPitch = (float)(packetIn.getPitch() * 360) / 256.0F;
entity.rotYaw = (float)(packetIn.getYaw() * 360) / 256.0F;
Entity[] aentity = entity.getParts();
if (aentity != null)
{
int i = packetIn.getEntityID() - entity.getId();
for (int j = 0; j < aentity.length; ++j)
{
aentity[j].setId(aentity[j].getId() + i);
}
}
entity.setId(packetIn.getEntityID());
this.gm.addEntityToWorld(packetIn.getEntityID(), entity);
@ -930,18 +918,6 @@ public class ClientPlayer implements IClientPlayer
entitylivingbase.serverPosY = packetIn.getY();
entitylivingbase.serverPosZ = packetIn.getZ();
entitylivingbase.yawOffset = entitylivingbase.headYaw = (float)(packetIn.getHeadPitch() * 360) / 256.0F;
Entity[] aentity = entitylivingbase.getParts();
if (aentity != null)
{
int i = packetIn.getEntityID() - entitylivingbase.getId();
for (int j = 0; j < aentity.length; ++j)
{
aentity[j].setId(aentity[j].getId() + i);
}
}
entitylivingbase.setId(packetIn.getEntityID());
entitylivingbase.setPositionAndRotation(d0, d1, d2, f, f1);
entitylivingbase.motionX = (double)((float)packetIn.getVelocityX() / 8000.0F);

View file

@ -1,102 +1,17 @@
package client.renderer.entity;
import org.lwjgl.opengl.GL11;
import client.renderer.GlState;
import client.renderer.layers.LayerEnderDragonEyes;
import client.renderer.model.ModelDragon;
import common.entity.animal.EntityDragon;
import common.util.ExtMath;
public class RenderDragon extends RenderLiving<EntityDragon>
{
private static final String enderDragonTextures = "textures/creature/dragon.png";
/** An instance of the dragon model in RenderDragon */
protected ModelDragon modelDragon;
public RenderDragon(RenderManager renderManagerIn)
{
super(renderManagerIn, new ModelDragon(0.0F));
this.modelDragon = (ModelDragon)this.mainModel;
this.addLayer(new LayerEnderDragonEyes(this));
// this.addLayer(new LayerEntityBreak());
}
protected void rotateCorpse(EntityDragon bat, float p_77043_2_, float p_77043_3_, float partialTicks)
{
float f = (float)bat.getMovementOffsets(7, partialTicks)[0];
float f1 = (float)(bat.getMovementOffsets(5, partialTicks)[1] - bat.getMovementOffsets(10, partialTicks)[1]);
GL11.glRotatef(-f, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(f1 * 10.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, 0.0F, 1.0F);
if (bat.deathTime > 0)
{
float f2 = ((float)bat.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F;
f2 = ExtMath.sqrtf(f2);
if (f2 > 1.0F)
{
f2 = 1.0F;
}
GL11.glRotatef(f2 * this.getDeathMaxRotation(bat), 0.0F, 0.0F, 1.0F);
}
}
/**
* Renders the model in RenderLiving
*/
protected void renderModel(EntityDragon entitylivingbaseIn, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float scaleFactor)
{
// if (entitylivingbaseIn.deathTicks > 0)
// {
// float f = (float)entitylivingbaseIn.deathTicks / 200.0F;
// GlState.depthFunc(GL11.GL_LEQUAL);
// GlState.enableAlpha();
// GlState.alphaFunc(GL11.GL_GREATER, f);
// this.bindTexture(enderDragonExplodingTextures);
// this.mainModel.render(entitylivingbaseIn, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
// GlState.alphaFunc(GL11.GL_GREATER, 0.1F);
// GlState.depthFunc(GL11.GL_EQUAL);
// }
this.bindEntityTexture(entitylivingbaseIn);
this.mainModel.render(entitylivingbaseIn, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
if (entitylivingbaseIn.hurtTime > 0)
{
GlState.depthFunc(GL11.GL_EQUAL);
GlState.disableTexture2D();
GlState.enableBlend();
GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlState.color(1.0F, 0.0F, 0.0F, 0.5F);
this.mainModel.render(entitylivingbaseIn, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
GlState.enableTexture2D();
GlState.disableBlend();
GlState.depthFunc(GL11.GL_LEQUAL);
}
}
// /**
// * Renders the desired {@code T} type Entity.
// */
// public void doRender(EntityDragon entity, double x, double y, double z, float entityYaw, float partialTicks)
// {
// BossStatus.setBossStatus(entity);
// super.doRender(entity, x, y, z, entityYaw, partialTicks);
//
//// if (entity.healingEnderCrystal != null)
//// {
//// this.drawRechargeRay(entity, x, y, z, partialTicks);
//// }
// }
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected String getEntityTexture(EntityDragon entity)
{
return enderDragonTextures;

View file

@ -1,46 +0,0 @@
package client.renderer.layers;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import client.renderer.GlState;
import client.renderer.entity.RenderDragon;
import common.entity.animal.EntityDragon;
public class LayerEnderDragonEyes implements LayerRenderer<EntityDragon>
{
private static final String TEXTURE = "textures/creature/dragon_eyes.png";
private final RenderDragon dragonRenderer;
public LayerEnderDragonEyes(RenderDragon dragonRendererIn)
{
this.dragonRenderer = dragonRendererIn;
}
public void doRenderLayer(EntityDragon entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale)
{
this.dragonRenderer.bindTexture(TEXTURE);
GlState.enableBlend();
GlState.disableAlpha();
GlState.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
GlState.disableLighting();
GlState.depthFunc(GL11.GL_EQUAL);
int i = 61680;
int j = i % 65536;
int k = i / 65536;
GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, (float)j / 1.0F, (float)k / 1.0F);
GlState.enableLighting();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
this.dragonRenderer.getMainModel().render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, scale);
this.dragonRenderer.setLightmap(entitylivingbaseIn, partialTicks);
GlState.disableBlend();
GlState.enableAlpha();
GlState.depthFunc(GL11.GL_LEQUAL);
}
public boolean shouldCombineTextures()
{
return false;
}
}

View file

@ -139,6 +139,9 @@ public class ModelDragon extends ModelBase
*/
public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
{
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.5F, 0.0F);
GL11.glScalef(0.35f, 0.35f, 0.35f);
GL11.glPushMatrix();
EntityDragon entitydragon = (EntityDragon)entityIn;
float f = entitydragon.prevAnimTime + (entitydragon.animTime - entitydragon.prevAnimTime) * this.partialTicks;
@ -150,9 +153,8 @@ public class ModelDragon extends ModelBase
float f2 = -30.0F;
float f4 = 0.0F;
float f5 = 1.5F;
double[] adouble = entitydragon.getMovementOffsets(6, this.partialTicks);
float f6 = this.updateRotations(entitydragon.getMovementOffsets(5, this.partialTicks)[0] - entitydragon.getMovementOffsets(10, this.partialTicks)[0]);
float f7 = this.updateRotations(entitydragon.getMovementOffsets(5, this.partialTicks)[0] + (double)(f6 / 2.0F));
float f6 = 0.0f;
float f7 = this.updateRotations(p_78088_5_ + (double)(f6 / 2.0F));
f2 = f2 + 2.0F;
float f8 = f * (float)Math.PI * 2.0F;
f2 = 20.0F;
@ -160,11 +162,10 @@ public class ModelDragon extends ModelBase
for (int i = 0; i < 5; ++i)
{
double[] adouble1 = entitydragon.getMovementOffsets(5 - i, this.partialTicks);
float f9 = (float)Math.cos((double)((float)i * 0.45F + f8)) * 0.15F;
this.spine.rotateAngleY = this.updateRotations(adouble1[0] - adouble[0]) * (float)Math.PI / 180.0F * f5;
this.spine.rotateAngleX = f9 + (float)(adouble1[1] - adouble[1]) * (float)Math.PI / 180.0F * f5 * 5.0F;
this.spine.rotateAngleZ = -this.updateRotations(adouble1[0] - (double)f7) * (float)Math.PI / 180.0F * f5;
this.spine.rotateAngleY = 0.0f * (float)Math.PI / 180.0F * f5;
this.spine.rotateAngleX = f9 + (float)(0.0f) * (float)Math.PI / 180.0F * f5 * 5.0F;
this.spine.rotateAngleZ = -this.updateRotations(p_78088_5_ - (double)f7) * (float)Math.PI / 180.0F * f5;
this.spine.rotationPointY = f2;
this.spine.rotationPointZ = f3;
this.spine.rotationPointX = f4;
@ -177,9 +178,8 @@ public class ModelDragon extends ModelBase
this.head.rotationPointY = f2;
this.head.rotationPointZ = f3;
this.head.rotationPointX = f4;
double[] adouble2 = entitydragon.getMovementOffsets(0, this.partialTicks);
this.head.rotateAngleY = this.updateRotations(adouble2[0] - adouble[0]) * (float)Math.PI / 180.0F * 1.0F;
this.head.rotateAngleZ = -this.updateRotations(adouble2[0] - (double)f7) * (float)Math.PI / 180.0F * 1.0F;
this.head.rotateAngleY = 0.0f * (float)Math.PI / 180.0F * 1.0F;
this.head.rotateAngleZ = -this.updateRotations(p_78088_5_ - (double)f7) * (float)Math.PI / 180.0F * 1.0F;
this.head.render(scale);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 1.0F, 0.0F);
@ -221,15 +221,13 @@ public class ModelDragon extends ModelBase
f2 = 10.0F;
f3 = 60.0F;
f4 = 0.0F;
adouble = entitydragon.getMovementOffsets(11, this.partialTicks);
for (int k = 0; k < 12; ++k)
{
adouble2 = entitydragon.getMovementOffsets(12 + k, this.partialTicks);
f10 = (float)((double)f10 + Math.sin((double)((float)k * 0.45F + f8)) * 0.05000000074505806D);
this.spine.rotateAngleY = (this.updateRotations(adouble2[0] - adouble[0]) * f5 + 180.0F) * (float)Math.PI / 180.0F;
this.spine.rotateAngleX = f10 + (float)(adouble2[1] - adouble[1]) * (float)Math.PI / 180.0F * f5 * 5.0F;
this.spine.rotateAngleZ = this.updateRotations(adouble2[0] - (double)f7) * (float)Math.PI / 180.0F * f5;
this.spine.rotateAngleY = (0.0f * f5 + 180.0F) * (float)Math.PI / 180.0F;
this.spine.rotateAngleX = f10 + (float)0.0f * (float)Math.PI / 180.0F * f5 * 5.0F;
this.spine.rotateAngleZ = this.updateRotations(p_78088_5_ - (double)f7) * (float)Math.PI / 180.0F * f5;
this.spine.rotationPointY = f2;
this.spine.rotationPointZ = f3;
this.spine.rotationPointX = f4;
@ -240,6 +238,7 @@ public class ModelDragon extends ModelBase
}
GL11.glPopMatrix();
GL11.glPopMatrix();
}
/**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -0,0 +1,73 @@
package common.ai;
import common.entity.projectile.EntityFireball;
import common.entity.types.EntityLiving;
import common.init.SoundEvent;
import common.util.BlockPos;
import common.util.Vec3;
import common.world.World;
public class AIFireAttack extends EntityAIBase
{
public final int power;
public final int delay;
public final double distance;
public final double velocity;
private final EntityLiving parentEntity;
public int attackTimer;
public AIFireAttack(EntityLiving entity, int power, int delay, double distance, double velocity)
{
this.parentEntity = entity;
this.power = power;
this.delay = delay;
this.distance = distance;
this.velocity = velocity;
// this.setMutexBits(3);
}
public boolean shouldExecute()
{
return this.parentEntity.getAttackTarget() != null;
}
public void startExecuting()
{
this.attackTimer = 0;
}
public void updateTask()
{
EntityLiving target = this.parentEntity.getAttackTarget();
if (target.getDistanceSqToEntity(this.parentEntity) < this.distance * this.distance && this.parentEntity.canEntityBeSeen(target))
{
World world = this.parentEntity.worldObj;
++this.attackTimer;
if (this.attackTimer == this.delay * 2)
{
this.parentEntity.playSound(SoundEvent.DRAGON_GROWL, 5.0f);
double d1 = 1.0D;
Vec3 vec3 = this.parentEntity.getLook(1.0F);
double d2 = target.posX - (this.parentEntity.posX + vec3.xCoord * d1);
double d3 = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - (this.parentEntity.posY + (double)this.parentEntity.getEyeHeight());
double d4 = target.posZ - (this.parentEntity.posZ + vec3.zCoord * d1);
world.playEffect(1008, new BlockPos(this.parentEntity), 0);
EntityFireball fireball = new EntityFireball(world, this.parentEntity, d2, d3, d4, this.velocity);
fireball.explosionPower = this.power;
fireball.damageBlocks = true;
fireball.posX = this.parentEntity.posX + vec3.xCoord * d1;
fireball.posY = this.parentEntity.posY + (double)this.parentEntity.getEyeHeight();
fireball.posZ = this.parentEntity.posZ + vec3.zCoord * d1;
world.spawnEntityInWorld(fireball);
this.attackTimer = -this.delay * this.parentEntity.getRNG().range(1, 4);
}
this.parentEntity.getLookHelper().setLookPositionWithEntity(target, 30.0f, 30.0f);
}
else if (this.attackTimer > 0)
{
--this.attackTimer;
}
}
}

View file

@ -70,13 +70,6 @@ public class AIFireballAttack extends EntityAIBase
double d4 = target.posZ - (this.parentEntity.posZ + vec3.zCoord * d1);
world.playEffect(1008, new BlockPos(this.parentEntity), 0);
EntityFireball fireball = new EntityFireball(world, this.parentEntity, d2, d3, d4, this.velocity);
// 0.0, 0.0, 0.0);
// fireball.setAcceleration(d2 + this.parentEntity.getRNG().gaussian() * 0.1D,
// d3 + this.parentEntity.getRNG().gaussian() * 0.1D,
// d4 + this.parentEntity.getRNG().gaussian() * 0.1D);
// fireball.accelerationX *= this.velocity;
// fireball.accelerationY *= this.velocity;
// fireball.accelerationZ *= this.velocity;
fireball.explosionPower = this.power;
fireball.posX = this.parentEntity.posX + vec3.xCoord * d1;
fireball.posY = this.parentEntity.posY + (double)this.parentEntity.getEyeHeight();

View file

@ -9,13 +9,13 @@ public class EntityAIHurtByTarget extends EntityAITarget
/** Store the previous revengeTimer value */
private int revengeTimerOld;
private final Class[] targetClasses;
private final Class[] ignore;
public EntityAIHurtByTarget(EntityLiving creatureIn, boolean entityCallsForHelpIn, Class... targetClassesIn)
public EntityAIHurtByTarget(EntityLiving creatureIn, boolean entityCallsForHelpIn, Class... ignore)
{
super(creatureIn, false);
this.entityCallsForHelp = entityCallsForHelpIn;
this.targetClasses = targetClassesIn;
this.ignore = ignore;
this.setMutexBits(1);
}
@ -40,24 +40,24 @@ public class EntityAIHurtByTarget extends EntityAITarget
{
double d0 = this.getTargetDistance();
for (EntityLiving entitycreature : this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), (new BoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D)).expand(d0, 10.0D, d0)))
for (EntityLiving ally : this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), (new BoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D)).expand(d0, 10.0D, d0)))
{
if (this.taskOwner != entitycreature && /* !(entitycreature.isPlayer()) && */ entitycreature.getAttackTarget() == null) // && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget()))
if (this.taskOwner != ally && /* !(entitycreature.isPlayer()) && */ ally.getAttackTarget() == null) // && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget()))
{
boolean flag = false;
boolean ignored = false;
for (Class oclass : this.targetClasses)
for (Class oclass : this.ignore)
{
if (entitycreature.getClass() == oclass)
if (ally.getClass() == oclass)
{
flag = true;
ignored = true;
break;
}
}
if (!flag)
if (!ignored)
{
this.setEntityAttackTarget(entitycreature, this.taskOwner.getAttackedBy());
this.setEntityAttackTarget(ally, this.taskOwner.getAttackedBy());
}
}
}

View file

@ -2154,22 +2154,6 @@ public abstract class Entity
this.fallDistance = 0.0F;
}
/**
* Return the Entity parts making up this Entity (currently only for dragons)
*/
public Entity[] getParts()
{
return null;
}
/**
* Returns true if Entity argument is equal to this Entity
*/
public boolean isEntityEqual(Entity entityIn)
{
return this == entityIn;
}
public float getRotationYawHead()
{
return 0.0F;

View file

@ -1,611 +1,90 @@
package common.entity.animal;
import java.util.List;
import common.collect.Lists;
import common.ai.AIFireAttack;
import common.ai.EntityAIHurtByTarget;
import common.ai.EntityAINearestAttackableTarget;
import common.ai.EntityAISwimming;
import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest;
import common.block.Block;
import common.effect.Effect;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.EntityType;
import common.entity.npc.Alignment;
import common.entity.npc.EntityNPC;
import common.entity.npc.EntityFlyingNPC.AILookAround;
import common.entity.npc.EntityFlyingNPC.AIRandomFly;
import common.entity.npc.EntityFlyingNPC.FlyMoveHelper;
import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving;
import common.entity.types.IEntityMultiPart;
import common.init.Items;
import common.init.SoundEvent;
import common.item.Item;
import common.item.ItemStack;
import common.util.BlockPos;
import common.util.Clientside;
import common.util.ExtMath;
import common.util.ParticleType;
import common.util.Vec3;
import common.vars.Vars;
import common.world.World;
public class EntityDragon extends EntityLiving implements IEntityMultiPart
{
public double targetX;
public double targetY;
public double targetZ;
public double[][] ringBuffer = new double[64][3];
public int ringBufferIndex = -1;
public EntityDragonPart[] dragonPartArray;
public EntityDragonPart dragonPartHead;
public EntityDragonPart dragonPartBody;
public EntityDragonPart dragonPartTail1;
public EntityDragonPart dragonPartTail2;
public EntityDragonPart dragonPartTail3;
public EntityDragonPart dragonPartWing1;
public EntityDragonPart dragonPartWing2;
public float prevAnimTime;
public float animTime;
public boolean forceNewTarget;
private Entity target;
public class EntityDragon extends EntityAnimal {
@Clientside
public float prevAnimTime;
@Clientside
public float animTime;
public EntityDragon(World worldIn)
{
super(worldIn);
this.dragonPartArray = new EntityDragonPart[] {this.dragonPartHead = new EntityDragonPart(this, "head", 6.0F, 6.0F), this.dragonPartBody = new EntityDragonPart(this, "body", 8.0F, 8.0F), this.dragonPartTail1 = new EntityDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartTail2 = new EntityDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartTail3 = new EntityDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartWing1 = new EntityDragonPart(this, "wing", 4.0F, 4.0F), this.dragonPartWing2 = new EntityDragonPart(this, "wing", 4.0F, 4.0F)};
this.setHealth(this.getMaxHealth());
this.setSize(16.0F, 8.0F);
this.noClip = true;
// this.fireImmune = true;
this.targetY = 100.0D;
this.noFrustumCheck = true;
this.xpValue = 12000;
}
public EntityDragon(World worldIn) {
super(worldIn);
this.setSize(2.0F, 1.5F);
this.moveHelper = new FlyMoveHelper(this);
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(5, new AIRandomFly(this));
this.tasks.addTask(7, new AILookAround(this));
this.tasks.addTask(7, new AIFireAttack(this, 4, 16, 64.0, 1.5));
this.tasks.addTask(8, new EntityAIWander(this, 1.0D));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
this.targets.addTask(1, new EntityAIHurtByTarget(this, false));
this.targets.addTask(2, new EntityAINearestAttackableTarget(this, EntityNPC.class, true));
this.xpValue = 12000;
}
public boolean isImmuneToFire()
{
return true;
}
public boolean isImmuneToFire() {
return true;
}
public boolean isPotionApplicable(Effect potion, int amplifier) {
return false;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.setMaxHealth(200);
}
// protected void entityInit()
// {
// super.entityInit();
// }
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.setMaxHealth(180);
this.setSpeedBase(0.25f);
}
public boolean allowLeashing() {
return false;
}
/**
* Returns a double[3] array with movement offsets, used to calculate trailing tail/neck positions. [0] = yaw
* offset, [1] = y offset, [2] = unused, always 0. Parameters: buffer index offset, partial ticks.
*/
public double[] getMovementOffsets(int p_70974_1_, float p_70974_2_)
{
if (this.getHealth() <= 0)
{
p_70974_2_ = 0.0F;
}
public void onLivingUpdate() {
if(this.worldObj.client) {
float f = ExtMath.cos(this.animTime * (float)Math.PI * 2.0F);
float f1 = ExtMath.cos(this.prevAnimTime * (float)Math.PI * 2.0F);
if(f1 <= -0.3F && f >= -0.3F)
this.worldObj.clientSound(SoundEvent.DRAGON_WINGS, this.posX, this.posY, this.posZ, 5.0F);
this.prevAnimTime = this.animTime;
if(this.getHealth() > 0) {
float f10 = 0.2F / (ExtMath.sqrtd(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F);
f10 = f10 * (float)Math.pow(2.0D, this.motionY);
this.animTime += Math.min(f10, 0.1f);
this.rotYaw = ExtMath.wrapf(this.rotYaw);
}
}
p_70974_2_ = 1.0F - p_70974_2_;
int i = this.ringBufferIndex - p_70974_1_ * 1 & 63;
int j = this.ringBufferIndex - p_70974_1_ * 1 - 1 & 63;
double[] adouble = new double[3];
double d0 = this.ringBuffer[i][0];
double d1 = ExtMath.wrapd(this.ringBuffer[j][0] - d0);
adouble[0] = d0 + d1 * (double)p_70974_2_;
d0 = this.ringBuffer[i][1];
d1 = this.ringBuffer[j][1] - d0;
adouble[1] = d0 + d1 * (double)p_70974_2_;
adouble[2] = this.ringBuffer[i][2] + (this.ringBuffer[j][2] - this.ringBuffer[i][2]) * (double)p_70974_2_;
return adouble;
}
public void onLivingUpdate()
{
if (this.worldObj.client)
{
float f = ExtMath.cos(this.animTime * (float)Math.PI * 2.0F);
float f1 = ExtMath.cos(this.prevAnimTime * (float)Math.PI * 2.0F);
super.onLivingUpdate();
}
if (f1 <= -0.3F && f >= -0.3F) // && !this.isSilent())
{
this.worldObj.clientSound(SoundEvent.DRAGON_WINGS, this.posX, this.posY, this.posZ, 5.0F);
}
}
public int getTrackingRange() {
return 160;
}
this.prevAnimTime = this.animTime;
if (this.getHealth() <= 0)
{
float f11 = (this.rand.floatv() - 0.5F) * 8.0F;
float f13 = (this.rand.floatv() - 0.5F) * 4.0F;
float f14 = (this.rand.floatv() - 0.5F) * 8.0F;
this.worldObj.clientParticle(ParticleType.EXPLOSION_LARGE, this.posX + (double)f11, this.posY + 2.0D + (double)f13, this.posZ + (double)f14, 100);
}
else
{
// this.updateDragonEnderCrystal();
float f10 = 0.2F / (ExtMath.sqrtd(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F);
f10 = f10 * (float)Math.pow(2.0D, this.motionY);
this.animTime += f10;
this.rotYaw = ExtMath.wrapf(this.rotYaw);
// if (this.isAIDisabled() ||
if(!this.worldObj.client && !Vars.mobTick) // )
{
this.animTime = 0.5F;
}
else
{
if (this.ringBufferIndex < 0)
{
for (int i = 0; i < this.ringBuffer.length; ++i)
{
this.ringBuffer[i][0] = (double)this.rotYaw;
this.ringBuffer[i][1] = this.posY;
}
}
if (++this.ringBufferIndex == this.ringBuffer.length)
{
this.ringBufferIndex = 0;
}
this.ringBuffer[this.ringBufferIndex][0] = (double)this.rotYaw;
this.ringBuffer[this.ringBufferIndex][1] = this.posY;
if (this.worldObj.client)
{
if (this.moveIncrements > 0)
{
double d10 = this.posX + (this.newX - this.posX) / (double)this.moveIncrements;
double d0 = this.posY + (this.newY - this.posY) / (double)this.moveIncrements;
double d1 = this.posZ + (this.newZ - this.posZ) / (double)this.moveIncrements;
double d2 = ExtMath.wrapd(this.newYaw - (double)this.rotYaw);
this.rotYaw = (float)((double)this.rotYaw + d2 / (double)this.moveIncrements);
this.rotPitch = (float)((double)this.rotPitch + (this.newPitch - (double)this.rotPitch) / (double)this.moveIncrements);
--this.moveIncrements;
this.setPosition(d10, d0, d1);
this.setRotation(this.rotYaw, this.rotPitch);
}
}
else
{
double d11 = this.targetX - this.posX;
double d12 = this.targetY - this.posY;
double d13 = this.targetZ - this.posZ;
double d14 = d11 * d11 + d12 * d12 + d13 * d13;
if (this.target != null)
{
this.targetX = this.target.posX;
this.targetZ = this.target.posZ;
double d3 = this.targetX - this.posX;
double d5 = this.targetZ - this.posZ;
double d7 = Math.sqrt(d3 * d3 + d5 * d5);
double d8 = 0.4000000059604645D + d7 / 80.0D - 1.0D;
if (d8 > 10.0D)
{
d8 = 10.0D;
}
this.targetY = this.target.getEntityBoundingBox().minY + d8;
}
else
{
this.targetX += this.rand.gaussian() * 2.0D;
this.targetZ += this.rand.gaussian() * 2.0D;
}
if (this.forceNewTarget || d14 < 100.0D || d14 > 22500.0D || this.collidedHorizontally || this.collidedVertically)
{
this.setNewTarget();
}
d12 = d12 / (double)ExtMath.sqrtd(d11 * d11 + d13 * d13);
float f17 = 0.6F;
d12 = ExtMath.clampd(d12, (double)(-f17), (double)f17);
this.motionY += d12 * 0.10000000149011612D;
this.rotYaw = ExtMath.wrapf(this.rotYaw);
double d4 = 180.0D - ExtMath.atan2(d11, d13) * 180.0D / Math.PI;
double d6 = ExtMath.wrapd(d4 - (double)this.rotYaw);
if (d6 > 50.0D)
{
d6 = 50.0D;
}
if (d6 < -50.0D)
{
d6 = -50.0D;
}
Vec3 vec3 = (new Vec3(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ)).normalize();
double d15 = (double)(-ExtMath.cos(this.rotYaw * (float)Math.PI / 180.0F));
Vec3 vec31 = (new Vec3((double)ExtMath.sin(this.rotYaw * (float)Math.PI / 180.0F), this.motionY, d15)).normalize();
float f5 = ((float)vec31.dotProduct(vec3) + 0.5F) / 1.5F;
if (f5 < 0.0F)
{
f5 = 0.0F;
}
this.randomYawVelo *= 0.8F;
float f6 = ExtMath.sqrtd(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F;
double d9 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D;
if (d9 > 40.0D)
{
d9 = 40.0D;
}
this.randomYawVelo = (float)((double)this.randomYawVelo + d6 * (0.699999988079071D / d9 / (double)f6));
this.rotYaw += this.randomYawVelo * 0.1F;
float f7 = (float)(2.0D / (d9 + 1.0D));
float f8 = 0.06F;
this.moveFlying(0.0F, -1.0F, f8 * (f5 * f7 + (1.0F - f7)));
this.moveEntity(this.motionX, this.motionY, this.motionZ);
Vec3 vec32 = (new Vec3(this.motionX, this.motionY, this.motionZ)).normalize();
float f9 = ((float)vec32.dotProduct(vec31) + 1.0F) / 2.0F;
f9 = 0.8F + 0.15F * f9;
this.motionX *= (double)f9;
this.motionZ *= (double)f9;
this.motionY *= 0.9100000262260437D;
}
this.yawOffset = this.rotYaw;
this.dragonPartHead.width = this.dragonPartHead.height = 3.0F;
this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F;
this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F;
this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F;
this.dragonPartBody.height = 3.0F;
this.dragonPartBody.width = 5.0F;
this.dragonPartWing1.height = 2.0F;
this.dragonPartWing1.width = 4.0F;
this.dragonPartWing2.height = 3.0F;
this.dragonPartWing2.width = 4.0F;
float f12 = (float)(this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float)Math.PI;
float f2 = ExtMath.cos(f12);
float f15 = -ExtMath.sin(f12);
float f3 = this.rotYaw * (float)Math.PI / 180.0F;
float f16 = ExtMath.sin(f3);
float f4 = ExtMath.cos(f3);
this.dragonPartBody.onUpdate();
this.dragonPartBody.setLocationAndAngles(this.posX + (double)(f16 * 0.5F), this.posY, this.posZ - (double)(f4 * 0.5F), 0.0F, 0.0F);
this.dragonPartWing1.onUpdate();
this.dragonPartWing1.setLocationAndAngles(this.posX + (double)(f4 * 4.5F), this.posY + 2.0D, this.posZ + (double)(f16 * 4.5F), 0.0F, 0.0F);
this.dragonPartWing2.onUpdate();
this.dragonPartWing2.setLocationAndAngles(this.posX - (double)(f4 * 4.5F), this.posY + 2.0D, this.posZ - (double)(f16 * 4.5F), 0.0F, 0.0F);
if (!this.worldObj.client && this.hurtTime == 0)
{
this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D)));
this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D)));
if(Vars.damageMobs)
this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.getEntityBoundingBox().expand(1.0D, 1.0D, 1.0D)));
}
double[] adouble1 = this.getMovementOffsets(5, 1.0F);
double[] adouble = this.getMovementOffsets(0, 1.0F);
float f18 = ExtMath.sin(this.rotYaw * (float)Math.PI / 180.0F - this.randomYawVelo * 0.01F);
float f19 = ExtMath.cos(this.rotYaw * (float)Math.PI / 180.0F - this.randomYawVelo * 0.01F);
this.dragonPartHead.onUpdate();
this.dragonPartHead.setLocationAndAngles(this.posX + (double)(f18 * 5.5F * f2), this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double)(f15 * 5.5F), this.posZ - (double)(f19 * 5.5F * f2), 0.0F, 0.0F);
for (int j = 0; j < 3; ++j)
{
EntityDragonPart entitydragonpart = null;
if (j == 0)
{
entitydragonpart = this.dragonPartTail1;
}
if (j == 1)
{
entitydragonpart = this.dragonPartTail2;
}
if (j == 2)
{
entitydragonpart = this.dragonPartTail3;
}
double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F);
float f20 = this.rotYaw * (float)Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float)Math.PI / 180.0F * 1.0F;
float f21 = ExtMath.sin(f20);
float f22 = ExtMath.cos(f20);
float f23 = 1.5F;
float f24 = (float)(j + 1) * 2.0F;
entitydragonpart.onUpdate();
entitydragonpart.setLocationAndAngles(this.posX - (double)((f16 * f23 + f21 * f24) * f2), this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double)((f24 + f23) * f15) + 1.5D, this.posZ + (double)((f4 * f23 + f22 * f24) * f2), 0.0F, 0.0F);
}
}
}
}
// private void updateDragonEnderCrystal()
// {
// if (this.healingEnderCrystal != null)
// {
// if (this.healingEnderCrystal.dead)
// {
// if (!this.worldObj.client)
// {
// this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion)null), 10);
// }
//
// this.healingEnderCrystal = null;
// }
// else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth())
// {
// this.setHealth(this.getHealth() + 1);
// }
// }
//
// if (this.rand.chance(10))
// {
// float f = 32.0F;
// List<EntityCrystal> list = this.worldObj.<EntityCrystal>getEntitiesWithinAABB(EntityCrystal.class, this.getEntityBoundingBox().expand((double)f, (double)f, (double)f));
// EntityCrystal entityendercrystal = null;
// double d0 = Double.MAX_VALUE;
//
// for (EntityCrystal entityendercrystal1 : list)
// {
// double d1 = entityendercrystal1.getDistanceSqToEntity(this);
//
// if (d1 < d0)
// {
// d0 = d1;
// entityendercrystal = entityendercrystal1;
// }
// }
//
// this.healingEnderCrystal = entityendercrystal;
// }
// }
private void collideWithEntities(List<Entity> p_70970_1_)
{
double d0 = (this.dragonPartBody.getEntityBoundingBox().minX + this.dragonPartBody.getEntityBoundingBox().maxX) / 2.0D;
double d1 = (this.dragonPartBody.getEntityBoundingBox().minZ + this.dragonPartBody.getEntityBoundingBox().maxZ) / 2.0D;
for (Entity entity : p_70970_1_)
{
if (entity instanceof EntityLiving)
{
double d2 = entity.posX - d0;
double d3 = entity.posZ - d1;
double d4 = d2 * d2 + d3 * d3;
entity.addKnockback(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);
}
}
}
private void attackEntitiesInList(List<Entity> p_70971_1_)
{
for (int i = 0; i < p_70971_1_.size(); ++i)
{
Entity entity = (Entity)p_70971_1_.get(i);
if (entity instanceof EntityLiving)
{
entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10);
this.applyEnchantments(this, entity);
}
}
}
/**
* Sets a new target for the flight AI. It can be a random coordinate or a nearby player.
*/
private void setNewTarget()
{
this.forceNewTarget = false;
List<EntityNPC> list = Lists.newArrayList(this.worldObj.players);
// Iterator<EntityNPC> iterator = list.iterator();
//
// while (iterator.hasNext())
// {
// if (((EntityNPC)iterator.next()).isSpectator())
// {
// iterator.remove();
// }
// }
if (this.rand.chance(2) && !list.isEmpty())
{
this.target = this.rand.pick(list);
}
else
{
while (true)
{
this.targetX = 0.0D;
this.targetY = (double)(70.0F + this.rand.floatv() * 50.0F);
this.targetZ = 0.0D;
this.targetX += (double)(this.rand.floatv() * 120.0F - 60.0F);
this.targetZ += (double)(this.rand.floatv() * 120.0F - 60.0F);
double d0 = this.posX - this.targetX;
double d1 = this.posY - this.targetY;
double d2 = this.posZ - this.targetZ;
boolean flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D;
if (flag)
{
break;
}
}
this.target = null;
}
}
private float simplifyAngle(double p_70973_1_)
{
return (float)ExtMath.wrapd(p_70973_1_);
}
public boolean attackEntityFromPart(EntityDragonPart dragonPart, DamageSource source, int amount)
{
if (dragonPart != this.dragonPartHead)
{
amount = amount / 4 + 1;
}
float f = this.rotYaw * (float)Math.PI / 180.0F;
float f1 = ExtMath.sin(f);
float f2 = ExtMath.cos(f);
this.targetX = this.posX + (double)(f1 * 5.0F) + (double)((this.rand.floatv() - 0.5F) * 2.0F);
this.targetY = this.posY + (double)(this.rand.floatv() * 3.0F) + 1.0D;
this.targetZ = this.posZ - (double)(f2 * 5.0F) + (double)((this.rand.floatv() - 0.5F) * 2.0F);
this.target = null;
// if ((source.getEntity() != null && source.getEntity().isPlayer()) || source.isExplosion())
// {
this.attackEntityFrom(source, amount);
// }
return true;
}
// public boolean attackEntityFrom(DamageSource source, int amount)
// {
// if (source instanceof EntityDamageSource && ((EntityDamageSource)source).getIsThornsDamage())
// {
// this.attackDragonFrom(source, amount);
// }
//
// return false;
// }
// protected boolean attackDragonFrom(DamageSource source, int amount)
// {
// return super.attackEntityFrom(source, amount);
// }
// protected void onDeathUpdate()
// {
// super.onDeathUpdate();
// if (this.deathTime == 20)
// {
// float f = (this.rand.floatv() - 0.5F) * 8.0F;
// float f1 = (this.rand.floatv() - 0.5F) * 4.0F;
// float f2 = (this.rand.floatv() - 0.5F) * 8.0F;
// this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + (double)f, this.posY + 2.0D + (double)f1, this.posZ + (double)f2, 0.0D, 0.0D, 0.0D);
// }
// }
// private void generatePortal(BlockPos pos)
// {
// int i = 4;
// double d0 = 12.25D;
// double d1 = 6.25D;
//
// for (int j = -1; j <= 32; ++j)
// {
// for (int k = -4; k <= 4; ++k)
// {
// for (int l = -4; l <= 4; ++l)
// {
// double d2 = (double)(k * k + l * l);
//
// if (d2 <= 12.25D)
// {
// BlockPos blockpos = pos.add(k, j, l);
//
// if (j < 0)
// {
// if (d2 <= 6.25D)
// {
// this.worldObj.setBlockState(blockpos, Blocks.obsidian.getDefaultState());
// }
// }
// else if (j > 0)
// {
// this.worldObj.setBlockState(blockpos, Blocks.air.getDefaultState());
// }
// else if (d2 > 6.25D)
// {
// this.worldObj.setBlockState(blockpos, Blocks.obsidian.getDefaultState());
// }
// else
// {
// this.worldObj.setBlockState(blockpos, Blocks.end_portal.getDefaultState());
// }
// }
// }
// }
// }
//
// this.worldObj.setBlockState(pos, Blocks.obsidian.getDefaultState());
// this.worldObj.setBlockState(pos.up(), Blocks.obsidian.getDefaultState());
// BlockPos blockpos1 = pos.up(2);
// this.worldObj.setBlockState(blockpos1, Blocks.obsidian.getDefaultState());
// this.worldObj.setBlockState(blockpos1.west(), Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.EAST));
// this.worldObj.setBlockState(blockpos1.east(), Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.WEST));
// this.worldObj.setBlockState(blockpos1.north(), Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH));
// this.worldObj.setBlockState(blockpos1.south(), Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH));
// this.worldObj.setBlockState(pos.up(3), Blocks.obsidian.getDefaultState());
// this.worldObj.setBlockState(pos.up(4), Blocks.dragon_egg.getDefaultState());
// }
// protected void despawnEntity()
// {
// }
public Entity[] getParts()
{
return this.dragonPartArray;
}
public boolean canBeCollidedWith()
{
return false;
}
public World getWorld()
{
return this.worldObj;
}
protected SoundEvent getLivingSound()
{
return SoundEvent.DRAGON_IDLE;
}
// protected Sounds getHurtSound()
// {
// return Sounds.MOB_DRAGON_HIT;
// }
//
// protected Sounds getDeathSound()
// {
// return Sounds.MOB_DRAGON_HIT;
// }
protected float getSoundVolume()
{
return 5.0F;
}
public int getTrackingRange() {
return 160;
}
public int getUpdateFrequency() {
return 3;
}
public boolean isSendingVeloUpdates() {
return true;
}
public int getColor() {
return 0xb900ff;
}
@ -617,12 +96,42 @@ public class EntityDragon extends EntityLiving implements IEntityMultiPart
public boolean getCanSpawnHere() {
return true;
}
public Alignment getAlignment() {
return Alignment.LAWFUL_EVIL;
}
public boolean isBreedingItem(ItemStack stack) {
return false;
}
public EntityDragon createChild(EntityLiving ageable) {
return new EntityDragon(this.worldObj);
}
protected Item getDropItem() {
return Items.charge_crystal;
}
public int getPathingRange() {
return 48;
}
public void fall(float distance, float damageMultiplier)
{
}
protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos)
{
}
public EntityType getType() {
return EntityType.ANIMAL;
public boolean isOnLadder()
{
return false;
}
public void moveEntityWithHeading(float strafe, float forward)
{
this.moveEntityWithHeadingFlying(strafe, forward);
}
}

View file

@ -1,74 +0,0 @@
package common.entity.animal;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.EntityType;
import common.entity.types.IEntityMultiPart;
import common.tags.TagObject;
public class EntityDragonPart extends Entity
{
/** The dragon entity this dragon part belongs to */
public final IEntityMultiPart entityDragonObj;
public final String partName;
public EntityDragonPart(IEntityMultiPart parent, String partName, float base, float sizeHeight)
{
super(parent.getWorld());
this.setSize(base, sizeHeight);
this.entityDragonObj = parent;
this.partName = partName;
}
protected void entityInit()
{
}
protected void readEntity(TagObject tagCompund)
{
}
protected void writeEntity(TagObject tagCompound)
{
}
/**
* Returns true if other Entities should be prevented from moving through this Entity.
*/
public boolean canBeCollidedWith()
{
return true;
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, int amount)
{
return /* this.isEntityInvulnerable(source) ? false : */ this.entityDragonObj.attackEntityFromPart(this, source, amount);
}
/**
* Returns true if Entity argument is equal to this Entity
*/
public boolean isEntityEqual(Entity entityIn)
{
return this == entityIn || this.entityDragonObj == entityIn;
}
public int getTrackingRange() {
return 0;
}
public int getUpdateFrequency() {
return 0;
}
public boolean isSendingVeloUpdates() {
return false;
}
public EntityType getType() {
return EntityType.ANIMAL;
}
}

View file

@ -63,62 +63,10 @@ public abstract class EntityFlyingNPC extends EntityNPC
public void moveEntityWithHeading(float strafe, float forward)
{
if(this.isPlayer()) {
if(this.isPlayer())
super.moveEntityWithHeading(strafe, forward);
return;
}
if (this.isInLiquid())
{
this.moveFlying(strafe, forward, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.800000011920929D;
this.motionY *= 0.800000011920929D;
this.motionZ *= 0.800000011920929D;
}
else if (this.isInMolten())
{
this.moveFlying(strafe, forward, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.5D;
this.motionY *= 0.5D;
this.motionZ *= 0.5D;
}
else
{
float f = 0.91F;
if (this.onGround)
{
f = this.worldObj.getState(new BlockPos(ExtMath.floord(this.posX), ExtMath.floord(this.getEntityBoundingBox().minY) - 1, ExtMath.floord(this.posZ))).getBlock().getSlipperiness() * 0.91F;
}
float f1 = 0.16277136F / (f * f * f);
this.moveFlying(strafe, forward, this.onGround ? 0.1F * f1 : 0.02F);
f = 0.91F;
if (this.onGround)
{
f = this.worldObj.getState(new BlockPos(ExtMath.floord(this.posX), ExtMath.floord(this.getEntityBoundingBox().minY) - 1, ExtMath.floord(this.posZ))).getBlock().getSlipperiness() * 0.91F;
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= (double)f;
this.motionY *= (double)f;
this.motionZ *= (double)f;
}
this.prevLswingAmount = this.lswingAmount;
double d1 = this.posX - this.prevX;
double d0 = this.posZ - this.prevZ;
float f2 = ExtMath.sqrtd(d1 * d1 + d0 * d0) * 4.0F;
if (f2 > 1.0F)
{
f2 = 1.0F;
}
this.lswingAmount += (f2 - this.lswingAmount) * 0.4F;
this.limbSwing += this.lswingAmount;
else
this.moveEntityWithHeadingFlying(strafe, forward);
}
public boolean isOnLadder()
@ -130,11 +78,11 @@ public abstract class EntityFlyingNPC extends EntityNPC
return (potion != Effect.FLYING || amplifier > 0) && super.isPotionApplicable(potion, amplifier);
}
static class AILookAround extends EntityAIBase
public static class AILookAround extends EntityAIBase
{
private EntityFlyingNPC parentEntity;
private EntityLiving parentEntity;
public AILookAround(EntityFlyingNPC entity)
public AILookAround(EntityLiving entity)
{
this.parentEntity = entity;
this.setMutexBits(2);
@ -166,11 +114,11 @@ public abstract class EntityFlyingNPC extends EntityNPC
}
}
static class AIRandomFly extends EntityAIBase
public static class AIRandomFly extends EntityAIBase
{
private EntityFlyingNPC parentEntity;
private EntityLiving parentEntity;
public AIRandomFly(EntityFlyingNPC entity)
public AIRandomFly(EntityLiving entity)
{
this.parentEntity = entity;
this.setMutexBits(1);
@ -209,12 +157,12 @@ public abstract class EntityFlyingNPC extends EntityNPC
}
}
static class FlyMoveHelper extends EntityMoveHelper
public static class FlyMoveHelper extends EntityMoveHelper
{
private EntityFlyingNPC parentEntity;
private EntityLiving parentEntity;
private int courseChangeCooldown;
public FlyMoveHelper(EntityFlyingNPC entity)
public FlyMoveHelper(EntityLiving entity)
{
super(entity);
this.parentEntity = entity;

View file

@ -35,7 +35,6 @@ import common.enchantment.EnchantmentHelper;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.EntityType;
import common.entity.animal.EntityDragonPart;
import common.entity.animal.EntityHorse;
import common.entity.animal.EntityPig;
import common.entity.item.EntityCart;
@ -46,7 +45,6 @@ import common.entity.projectile.EntityHook;
import common.entity.projectile.EntityPotion;
import common.entity.projectile.EntitySnowball;
import common.entity.types.EntityLiving;
import common.entity.types.IEntityMultiPart;
import common.init.DimensionRegistry;
import common.init.ItemRegistry;
import common.init.Items;
@ -375,7 +373,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
this.tasks.addTask(8, new EntityAIWander(this, 1.0D));
this.tasks.addTask(8, new EntityAIPlay(this, 1.1D));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
this.targets.addTask(1, new EntityAIHurtByTarget(this, false, /* EntityNPC.class, */ EntityLiving.class) {
this.targets.addTask(1, new EntityAIHurtByTarget(this, false) {
protected boolean isSuitableTarget(EntityLiving entity) {
if(entity != null && entity != EntityNPC.this && EntityNPC.this.shouldFlee(entity)) {
EntityNPC.this.setAttackTarget(null);
@ -3673,16 +3671,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
ItemStack itemstack = this.getHeldItem();
Entity entity = targetEntity;
if (targetEntity instanceof EntityDragonPart)
{
IEntityMultiPart ientitymultipart = ((EntityDragonPart)targetEntity).entityDragonObj;
if (ientitymultipart instanceof EntityLiving)
{
entity = (EntityLiving)ientitymultipart;
}
}
if (itemstack != null && entity instanceof EntityLiving)
{
itemstack.getItem().hitEntity(itemstack, (EntityLiving)entity, this);

View file

@ -10,6 +10,7 @@ import common.world.World;
public class EntityFireball extends EntityProjectile
{
public int explosionPower = 1;
public boolean damageBlocks = false;
public EntityFireball(World worldIn)
{
@ -42,8 +43,7 @@ public class EntityFireball extends EntityProjectile
this.applyEnchantments(this.shootingEntity, movingObject.entity);
}
boolean flag = Vars.mobGrief;
this.worldObj.newExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, (float)this.explosionPower, flag, false, true);
this.worldObj.newExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, (float)this.explosionPower, Vars.mobGrief, Vars.mobGrief && this.damageBlocks, true);
this.setDead();
}
}
@ -57,11 +57,13 @@ public class EntityFireball extends EntityProjectile
{
super.writeEntity(tagCompound);
tagCompound.setInt("ExplosionPower", this.explosionPower);
tagCompound.setBool("DamageBlocks", this.damageBlocks);
}
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
this.explosionPower = tagCompund.getInt("ExplosionPower");
this.damageBlocks = tagCompund.getBool("DamageBlocks");
}
}

View file

@ -150,7 +150,7 @@ public abstract class EntityProjectile extends Entity
{
Entity entity1 = (Entity)list.get(i);
if (entity1.canBeCollidedWith() && (!entity1.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25))
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 25))
{
float f = 0.3F;
BoundingBox axisalignedbb = entity1.getEntityBoundingBox().expand((double)f, (double)f, (double)f);

View file

@ -1648,18 +1648,67 @@ public abstract class EntityLiving extends Entity
}
}
}
this.prevLswingAmount = this.lswingAmount;
double d2 = this.posX - this.prevX;
double d3 = this.posZ - this.prevZ;
float f7 = ExtMath.sqrtd(d2 * d2 + d3 * d3) * 4.0F;
if (f7 > 1.0F)
this.updateLimbSwing();
}
public void moveEntityWithHeadingFlying(float strafe, float forward)
{
if (this.isInLiquid())
{
f7 = 1.0F;
this.moveFlying(strafe, forward, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.800000011920929D;
this.motionY *= 0.800000011920929D;
this.motionZ *= 0.800000011920929D;
}
else if (this.isInMolten())
{
this.moveFlying(strafe, forward, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.5D;
this.motionY *= 0.5D;
this.motionZ *= 0.5D;
}
else
{
float f = 0.91F;
if (this.onGround)
{
f = this.worldObj.getState(new BlockPos(ExtMath.floord(this.posX), ExtMath.floord(this.getEntityBoundingBox().minY) - 1, ExtMath.floord(this.posZ))).getBlock().getSlipperiness() * 0.91F;
}
float f1 = 0.16277136F / (f * f * f);
this.moveFlying(strafe, forward, this.onGround ? 0.1F * f1 : 0.02F);
f = 0.91F;
if (this.onGround)
{
f = this.worldObj.getState(new BlockPos(ExtMath.floord(this.posX), ExtMath.floord(this.getEntityBoundingBox().minY) - 1, ExtMath.floord(this.posZ))).getBlock().getSlipperiness() * 0.91F;
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= (double)f;
this.motionY *= (double)f;
this.motionZ *= (double)f;
}
this.lswingAmount += (f7 - this.lswingAmount) * 0.4F;
this.updateLimbSwing();
}
private void updateLimbSwing() {
this.prevLswingAmount = this.lswingAmount;
double dx = this.posX - this.prevX;
double dz = this.posZ - this.prevZ;
float dist = ExtMath.sqrtd(dx * dx + dz * dz) * 4.0F;
if (dist > 1.0F)
{
dist = 1.0F;
}
this.lswingAmount += (dist - this.lswingAmount) * 0.4F;
this.limbSwing += this.lswingAmount;
}

View file

@ -1,12 +0,0 @@
package common.entity.types;
import common.entity.DamageSource;
import common.entity.animal.EntityDragonPart;
import common.world.World;
public interface IEntityMultiPart
{
World getWorld();
boolean attackEntityFromPart(EntityDragonPart dragonPart, DamageSource source, int p_70965_3_);
}

View file

@ -71,7 +71,7 @@ public enum SoundEvent {
COW_HIT("cow_hurt1", "cow_hurt2", "cow_hurt3"),
COW_IDLE("cow_say1", "cow_say2", "cow_say3", "cow_say4"),
DRAGON_IDLE("dragon_growl1", "dragon_growl2", "dragon_growl3", "dragon_growl4"),
DRAGON_GROWL("dragon_growl1", "dragon_growl2", "dragon_growl3", "dragon_growl4"),
DRAGON_WINGS("dragon_wings1", "dragon_wings2", "dragon_wings3", "dragon_wings4", "dragon_wings5", "dragon_wings6"),
HORSE_ANGRY("horse_angry"),

View file

@ -587,22 +587,8 @@ public abstract class Chunk {
if(!this.entities[y].isEmpty()) {
for(Entity entity : this.entities[y]) {
if(entity.getEntityBoundingBox().intersectsWith(bb) && entity != exclude) {
if(pred == null || pred.test(entity)) {
if(pred == null || pred.test(entity))
list.add(entity);
}
Entity[] parts = entity.getParts();
if(parts != null) {
for(int l = 0; l < parts.length; ++l) {
entity = parts[l];
if(entity != exclude && entity.getEntityBoundingBox().intersectsWith(bb)
&& (pred == null || pred.test(entity))) {
list.add(entity);
}
}
}
}
}
}

View file

@ -877,25 +877,11 @@ public final class WorldServer extends AWorldServer {
protected void onEntityAdded(Entity entityIn) {
this.trackEntity(entityIn);
this.entityIds.addKey(entityIn.getId(), entityIn);
Entity[] aentity = entityIn.getParts();
if(aentity != null) {
for(int i = 0; i < aentity.length; ++i) {
this.entityIds.addKey(aentity[i].getId(), aentity[i]);
}
}
}
protected void onEntityRemoved(Entity entityIn) {
this.untrackEntity(entityIn);
this.entityIds.removeObject(entityIn.getId());
Entity[] aentity = entityIn.getParts();
if(aentity != null) {
for(int i = 0; i < aentity.length; ++i) {
this.entityIds.removeObject(aentity[i].getId());
}
}
}
public void strikeLightning(double x, double y, double z, int color, int damage, boolean fire, EntityLiving summoner) {