hovering, flying npc
This commit is contained in:
parent
5300c9e4fc
commit
103e4d35f5
7 changed files with 111 additions and 28 deletions
|
@ -43,8 +43,16 @@ public abstract class EntityFlyingNPC extends EntityNPC
|
|||
{
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void moveEntityWithHeading(float strafe, float forward)
|
||||
{
|
||||
if(this.isPlayer()) {
|
||||
super.moveEntityWithHeading(strafe, forward);
|
||||
return;
|
||||
}
|
||||
if (this.isInLiquid())
|
||||
{
|
||||
this.moveFlying(strafe, forward, 0.02F);
|
||||
|
|
|
@ -2,6 +2,7 @@ package game.entity.npc;
|
|||
|
||||
import game.entity.attributes.Attributes;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.packet.CPacketAction;
|
||||
import game.world.World;
|
||||
|
||||
public abstract class EntityHoveringNPC extends EntityNPC
|
||||
|
@ -9,6 +10,8 @@ public abstract class EntityHoveringNPC extends EntityNPC
|
|||
private float heightOffset = 0.5F;
|
||||
private int heightOffsetUpdateTime;
|
||||
|
||||
private boolean serverHoverState;
|
||||
|
||||
public EntityHoveringNPC(World worldIn)
|
||||
{
|
||||
super(worldIn);
|
||||
|
@ -33,6 +36,16 @@ public abstract class EntityHoveringNPC extends EntityNPC
|
|||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(32.0D);
|
||||
}
|
||||
|
||||
public boolean isHovering()
|
||||
{
|
||||
return this.getFlag(6);
|
||||
}
|
||||
|
||||
public void setHovering(boolean hover)
|
||||
{
|
||||
this.setFlag(6, hover);
|
||||
}
|
||||
|
||||
// protected void entityInit()
|
||||
// {
|
||||
|
@ -77,11 +90,45 @@ public abstract class EntityHoveringNPC extends EntityNPC
|
|||
// return 1.0F;
|
||||
// }
|
||||
|
||||
public void onUpdateWalkingPlayer()
|
||||
{
|
||||
boolean flag = this.isHovering();
|
||||
|
||||
if (flag != this.serverHoverState)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
this.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.START_HOVER));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.STOP_HOVER));
|
||||
}
|
||||
|
||||
this.serverHoverState = flag;
|
||||
}
|
||||
|
||||
super.onUpdateWalkingPlayer();
|
||||
}
|
||||
|
||||
public void onLivingUpdate()
|
||||
{
|
||||
if (!this.onGround && this.motionY < 0.0D)
|
||||
if(this.sendQueue != null) {
|
||||
if(this.gm.jump && this.gm.sprint && this.gm.moveForward == 0.0f && this.gm.moveStrafe == 0.0f)
|
||||
this.setHovering(true);
|
||||
if(this.isFlying() || (!this.gm.jump && this.gm.sneak && this.onGround))
|
||||
this.setHovering(false);
|
||||
}
|
||||
if (!this.onGround && this.motionY < 0.0D && (!this.isPlayer() || (!this.isFlying() && this.isHovering() && !this.jumping)))
|
||||
{
|
||||
this.motionY *= 0.6D;
|
||||
if(this.isPlayer() && this.isSneaking())
|
||||
this.motionY = -0.1D;
|
||||
else
|
||||
this.motionY *= 0.6D;
|
||||
}
|
||||
if (!this.onGround && this.isPlayer() && !this.isFlying() && !this.isSneaking() && this.isHovering())
|
||||
{
|
||||
this.motionY = this.jumping ? 0.1D : -0.025D;
|
||||
}
|
||||
|
||||
// if (this.worldObj.client)
|
||||
|
@ -100,6 +147,11 @@ public abstract class EntityHoveringNPC extends EntityNPC
|
|||
super.onLivingUpdate();
|
||||
}
|
||||
|
||||
protected float getJumpUpwardsMotion()
|
||||
{
|
||||
return !this.isPlayer() ? super.getJumpUpwardsMotion() : (super.getJumpUpwardsMotion());
|
||||
}
|
||||
|
||||
protected void updateAITasks()
|
||||
{
|
||||
// if (Config.blazeWaterDamage && this.isWet())
|
||||
|
|
|
@ -199,7 +199,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public NetHandlerPlayServer connection;
|
||||
public NetHandlerPlayClient sendQueue;
|
||||
private Game gm;
|
||||
protected Game gm;
|
||||
|
||||
public InventoryPlayer inventory;
|
||||
protected InventoryWarpChest warpChest;
|
||||
|
@ -4634,4 +4634,13 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
return super.getItem();
|
||||
}
|
||||
|
||||
public boolean isHovering()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setHovering(boolean hover)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue