Skip to content

Commit

Permalink
Merge branch 'master' into changeling-master
Browse files Browse the repository at this point in the history
  • Loading branch information
asanetargoss committed Mar 1, 2020
2 parents 45fa5a4 + 5af1f4d commit 2f03d59
Show file tree
Hide file tree
Showing 19 changed files with 221 additions and 182 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ out
*.iws
*.iml
.idea
classes/

# gradle
build
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# Metamorph Change Log

## Metamorph 1.1.10

This is a small patch update with a couple of bug fixes (mainly by asanetargoss).

**Compatible** with McLib `1.0.4`. It doesn't mean that future versions of McLib would be incompatible, but older versions are most likely incompatible.

* Fixed acquired morphs getting overwritten by canMerge
* Fixed crash when `null` sound proceeds in `SoundHandler` (fixed by asanetargoss)
* Fixed wrong air HUD when demorphed from air breathing mob (fixed by asanetargoss)

## Metamorph 1.1.9

This is a small patch update with lots of awesome bug fixes pull requests from asanetargoss and Johni0702!

**Compatible** with McLib `1.0.3`. It doesn't mean that future versions of McLib would be incompatible, but older versions are most likely incompatible.

* Fixed increasing health when morphing with modifier, and other cases. Fixed by **asanetargoss**
* Fixed small morphs suffocating in ceiling. Fixed by **asanetargoss**
* Fixed player having multiple chicken morphs. Fixed by **asanetargoss**
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Metamorph gradle properties
mclib=1.0.2
version=1.1.10
mclib=1.0.4
version=1.2

mc_version=1.10.2
forge_version=12.18.3.2511
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/mchorse/metamorph/api/Morph.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public Morph(AbstractMorph morph)
this.morph = morph;
}

public boolean isEmpty()
{
return this.morph == null;
}

public boolean set(AbstractMorph morph, boolean isRemote)
{
if (this.morph == null || !this.morph.canMerge(morph, isRemote))
Expand Down
101 changes: 14 additions & 87 deletions src/main/java/mchorse/metamorph/api/morphs/AbstractMorph.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
*/
public abstract class AbstractMorph
{
/* Abilities */

/**
* Morph settings
*/
public MorphSettings settings = MorphSettings.DEFAULT;

/* Meta information */

/**
Expand All @@ -49,10 +42,12 @@ public abstract class AbstractMorph
*/
public boolean favorite = false;

/* Abilities */

/**
* Health when the player morphed into this morph
* Morph settings
*/
protected float lastHealth;
public MorphSettings settings = MorphSettings.DEFAULT;

/* Rendering */

Expand All @@ -63,6 +58,15 @@ public abstract class AbstractMorph
@SideOnly(Side.CLIENT)
public Render<? extends Entity> renderer;

/* Clone code */

public static void copyBase(AbstractMorph from, AbstractMorph to)
{
to.name = from.name;
to.favorite = from.favorite;
to.settings = from.settings;
}

/* Render methods */

/**
Expand Down Expand Up @@ -94,11 +98,6 @@ public boolean renderHand(EntityPlayer player, EnumHand hand)
*/
public void update(EntityLivingBase target, IMorphing cap)
{
if (!Metamorph.proxy.config.disable_health)
{
this.setMaxHealth(target, this.settings.health);
}

if (this.settings.speed != 0.1F)
{
target.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(this.settings.speed);
Expand All @@ -120,9 +119,6 @@ public void update(EntityLivingBase target, IMorphing cap)
*/
public void morph(EntityLivingBase target)
{
this.lastHealth = (float)target.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue();
this.setHealth(target, this.settings.health);

for (IAbility ability : this.settings.abilities)
{
ability.onMorph(target);
Expand All @@ -137,9 +133,6 @@ public void morph(EntityLivingBase target)
*/
public void demorph(EntityLivingBase target)
{
/* 20 is default player's health */
this.setHealth(target, this.lastHealth <= 0.0F ? 20.0F : this.lastHealth);

for (IAbility ability : this.settings.abilities)
{
ability.onDemorph(target);
Expand Down Expand Up @@ -190,68 +183,6 @@ public static void updateSizeDefault(EntityLivingBase target, float width, float
}
}

/* Adjusting health */

/**
* Set player's health proportional to the current health with given max
* health.
*
* @author asanetargoss
*/
protected void setHealth(EntityLivingBase target, float health)
{
if (Metamorph.proxy.config.disable_health)
{
return;
}

float maxHealth = target.getMaxHealth();
float currentHealth = target.getHealth();
float ratio = currentHealth / maxHealth;

// A sanity check to prevent "healing" health when morphing to and from
// a mob
// with essentially zero health
if (target instanceof EntityPlayer)
{
IMorphing capability = Morphing.get((EntityPlayer) target);
if (capability != null)
{
// Check if a health ratio makes sense for the old health value
if (maxHealth > IMorphing.REASONABLE_HEALTH_VALUE)
{
// If it makes sense, store that ratio in the capability
capability.setLastHealthRatio(ratio);
}
else if (health > IMorphing.REASONABLE_HEALTH_VALUE)
{
// If it doesn't make sense, BUT the new max health makes
// sense, retrieve the
// ratio from the capability and use that instead
ratio = capability.getLastHealthRatio();
}
}
}

this.setMaxHealth(target, health);
// We need to retrieve the max health of the target after modifiers are
// applied
// to get a sensible value
float proportionalHealth = target.getMaxHealth() * ratio;
target.setHealth(proportionalHealth <= 0.0F ? Float.MIN_VALUE : proportionalHealth);
}

/**
* Set player's max health
*/
protected void setMaxHealth(EntityLivingBase target, float health)
{
if (target.getMaxHealth() != health)
{
target.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(health);
}
}

/* Safe shortcuts for activating action and attack */

/**
Expand Down Expand Up @@ -281,9 +212,7 @@ public void attack(Entity target, EntityLivingBase source)
*
* <p>
* <b>IMPORTANT</b>: when you subclass other morphs, don't forget to override
* their method with your own, because otherwise its going to create
* another {@link CustomMorph} instance, for example, instead of
* MyCustomMorph instance.
* their method with your own.
* </p>
*/
public abstract AbstractMorph clone(boolean isRemote);
Expand Down Expand Up @@ -404,7 +333,6 @@ public void reset()
public void toNBT(NBTTagCompound tag)
{
tag.setString("Name", this.name);
tag.setFloat("LastHealth", this.lastHealth);

if (this.favorite) tag.setBoolean("Favorite", this.favorite);
}
Expand All @@ -417,7 +345,6 @@ public void fromNBT(NBTTagCompound tag)
this.reset();

this.name = tag.getString("Name");
this.lastHealth = tag.getFloat("LastHealth");

if (tag.hasKey("Favorite")) this.favorite = tag.getBoolean("Favorite");
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/mchorse/metamorph/api/morphs/EntityMorph.java
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,7 @@ public AbstractMorph clone(boolean isRemote)
{
EntityMorph morph = new EntityMorph();

morph.name = this.name;
morph.settings = this.settings;
AbstractMorph.copyBase(this, morph);
morph.entityData = this.entityData.copy();

return morph;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/mchorse/metamorph/bodypart/BodyPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public void render(EntityLivingBase entity, float partialTicks)
}

@Override
@SideOnly(Side.CLIENT)
public void update(EntityLivingBase entity, IMorphing cap)
{
if (this.part != null) this.part.update(entity, cap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public void initBodyParts()
/**
* Update body limbs
*/
@SideOnly(Side.CLIENT)
public void updateBodyLimbs(EntityLivingBase target, IMorphing cap)
{
for (BodyPart part : this.parts)
Expand Down
54 changes: 27 additions & 27 deletions src/main/java/mchorse/metamorph/bodypart/GuiBodyPartEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,33 @@
@SideOnly(Side.CLIENT)
public class GuiBodyPartEditor extends GuiMorphPanel<AbstractMorph, GuiAbstractMorph> implements IInventoryPicker
{
private GuiBodyPartListElement bodyParts;
private GuiButtonElement<GuiButton> pickMorph;
private GuiButtonElement<GuiCheckBox> useTarget;
private GuiCreativeMorphs morphPicker;

private GuiButtonElement<GuiButton> addPart;
private GuiButtonElement<GuiButton> removePart;

private GuiTrackpadElement tx;
private GuiTrackpadElement ty;
private GuiTrackpadElement tz;
private GuiTrackpadElement sx;
private GuiTrackpadElement sy;
private GuiTrackpadElement sz;
private GuiTrackpadElement rx;
private GuiTrackpadElement ry;
private GuiTrackpadElement rz;

private GuiStringListElement limbs;
private GuiElements<IGuiElement> elements = new GuiElements<IGuiElement>();

private BodyPartManager parts;
private BodyPart part;

private GuiInventory inventory;
private GuiSlot[] slots = new GuiSlot[6];
private GuiSlot active;
protected GuiBodyPartListElement bodyParts;
protected GuiButtonElement<GuiButton> pickMorph;
protected GuiButtonElement<GuiCheckBox> useTarget;
protected GuiCreativeMorphs morphPicker;

protected GuiButtonElement<GuiButton> addPart;
protected GuiButtonElement<GuiButton> removePart;

protected GuiTrackpadElement tx;
protected GuiTrackpadElement ty;
protected GuiTrackpadElement tz;
protected GuiTrackpadElement sx;
protected GuiTrackpadElement sy;
protected GuiTrackpadElement sz;
protected GuiTrackpadElement rx;
protected GuiTrackpadElement ry;
protected GuiTrackpadElement rz;

protected GuiStringListElement limbs;
protected GuiElements<IGuiElement> elements = new GuiElements<IGuiElement>();

protected BodyPartManager parts;
protected BodyPart part;

protected GuiInventory inventory;
protected GuiSlot[] slots = new GuiSlot[6];
protected GuiSlot active;

public GuiBodyPartEditor(Minecraft mc, GuiAbstractMorph editor)
{
Expand Down
1 change: 0 additions & 1 deletion src/main/java/mchorse/metamorph/bodypart/IBodyPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public interface IBodyPart
@SideOnly(Side.CLIENT)
public void render(EntityLivingBase entity, float partialTicks);

@SideOnly(Side.CLIENT)
public void update(EntityLivingBase entity, IMorphing cap);

public boolean canMerge(IBodyPart part, boolean isRemote);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/mchorse/metamorph/bodypart/MorphBodyPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class MorphBodyPart implements IBodyPart
public float[] rotate = new float[] {180F, 0F, 0F};
public boolean useTarget = false;

@SideOnly(Side.CLIENT)
private EntityLivingBase entity;

@Override
Expand Down Expand Up @@ -97,7 +96,6 @@ public void render(EntityLivingBase entity, float partialTicks)
}

@Override
@SideOnly(Side.CLIENT)
public void update(EntityLivingBase entity, IMorphing cap)
{
entity = this.useTarget ? entity : this.entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ public interface IMorphing
*/
public void setSquidAir(int squidAir);

/**
* Get last health
*/
public float getLastHealth();

/**
* Set last health
*/
public void setLastHealth(float lastHealth);

/**
* Update the player
*/
Expand Down
Loading

0 comments on commit 2f03d59

Please sign in to comment.