Skip to content

Commit

Permalink
Fix incorrect state for mobs like squid and guardian
Browse files Browse the repository at this point in the history
  • Loading branch information
mchorse committed Feb 18, 2017
1 parent 88a8339 commit 6706dad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Metamorph 1.1

A big update of Metamorph mod. This update introduces third-party morph support and public API. A lot of code was rewritten, and
A big update of Metamorph mod. This update introduces third-party morph support, improved GUIs and public API. A lot of code was rewritten, and there close to no morphs which use custom models (as in the first version).

* Added Public API (technical)
* `mchorse.metamorph.api.MorphAPI` class provides API static methods
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/mchorse/metamorph/api/morphs/EntityMorph.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public boolean renderHand(EntityPlayer player, EnumHand hand)
@SuppressWarnings({"unchecked", "rawtypes"})
public void render(EntityLivingBase entity, double x, double y, double z, float entityYaw, float partialTicks)
{
if (entity == null)
{
return;
}

Render render = this.renderer;

if (render == null)
Expand Down Expand Up @@ -242,6 +247,7 @@ public void setEntity(EntityLivingBase entity)
this.entity = entity;

entity.setHealth(entity.getMaxHealth());
entity.noClip = true;

if (this.health == 20)
{
Expand Down Expand Up @@ -330,9 +336,15 @@ public void update(EntityLivingBase target, IMorphing cap)
}

/* Injecting player's properties */
entity.posX = target.posX;
entity.posY = target.posY;
entity.posZ = target.posZ;
entity.setPosition(target.posX, target.posY, target.posZ);

entity.lastTickPosX = target.lastTickPosX;
entity.lastTickPosY = target.lastTickPosY;
entity.lastTickPosZ = target.lastTickPosZ;

entity.prevPosX = target.prevPosX;
entity.prevPosY = target.prevPosY;
entity.prevPosZ = target.prevPosZ;

entity.rotationYaw = target.rotationYaw;
entity.rotationPitch = target.rotationPitch;
Expand Down Expand Up @@ -360,6 +372,15 @@ public void update(EntityLivingBase target, IMorphing cap)
entity.prevSwingProgress = target.prevSwingProgress;
entity.prevLimbSwingAmount = target.prevLimbSwingAmount;

if (target instanceof EntityPlayer && ((EntityPlayer) target).isCreative())
{
entity.fallDistance = 0;
}
else
{
entity.fallDistance = target.fallDistance;
}

entity.setSneaking(target.isSneaking());
entity.setSprinting(target.isSprinting());
entity.onGround = target.onGround;
Expand Down

0 comments on commit 6706dad

Please sign in to comment.