Skip to content

Commit

Permalink
Merge pull request #99 from demonlexe/80-wyverns-ang-fishy-egg-problems
Browse files Browse the repository at this point in the history
Fix Egg Drops for `Wyvern` and `Fishy`
  • Loading branch information
IcarussOne authored Jan 1, 2024
2 parents bdc4787 + bfcd95d commit 8a309d3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/main/java/drzhark/mocreatures/entity/MoCEntityAnimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ public boolean isSwimming() {
return isInsideOfMaterial(Material.WATER);
}

// used to drop eggs in a legacy fashion
public void dropLegacyEgg() {
}
//used to drop armor, inventory, saddles, etc.
public void dropMyStuff() {
}
Expand Down Expand Up @@ -785,6 +788,7 @@ public float getAdjustedYOffset() {
public void onDeath(DamageSource damagesource) {
if (!this.world.isRemote) {
dropMyStuff();
dropLegacyEgg();
}

super.onDeath(damagesource);
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/drzhark/mocreatures/entity/MoCEntityAquatic.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ protected boolean canBeTrappedInNet() {
return (this instanceof IMoCTameable) && getIsTamed();
}

// used to drop eggs in a legacy fashion
public void dropLegacyEgg() {
}
protected void dropMyStuff() {
}

Expand Down Expand Up @@ -622,6 +625,15 @@ public float getAdjustedXOffset() {
return 0F;
}

@Override
public void onDeath(DamageSource damagesource) {
if (!this.world.isRemote) {
dropMyStuff();
dropLegacyEgg();
}

super.onDeath(damagesource);
}
@Override
public boolean isNotScared() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,11 @@ public void setHasEaten(boolean flag) {
}

@Override
protected void dropFewItems(boolean flag, int x) {
public void dropLegacyEgg() {
int i = this.rand.nextInt(100);
if (i < 70) {
//entityDropItem(new ItemStack(Items.FISH, 1, 0), 0.0F);
} else {
if (i < 30) {
int j = this.rand.nextInt(2);
for (int k = 0; k < j; k++) {
entityDropItem(new ItemStack(MoCItems.mocegg, 1, getType()), 0.0F);
}

entityDropItem(new ItemStack(MoCItems.mocegg, j, getType()), 0.0F);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,10 @@ public boolean attackEntityFrom(DamageSource damagesource, float i) {
}

@Override
protected void dropFewItems(boolean flag, int x) {
public void dropLegacyEgg() {
if (getAge() > 60) {
int j = this.rand.nextInt(3);
for (int l = 0; l < j; l++) {

entityDropItem(new ItemStack(MoCItems.mocegg, 1, getType() + 20), 0.0F);
}
entityDropItem(new ItemStack(MoCItems.mocegg, j, getType() + 20), 0.0F);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ public void makeEntityDive() {

// TODO: Remove this once wyvern eggs are overhauled
@Override
protected void dropFewItems(boolean flag, int x) {
public void dropLegacyEgg() {
int chance = MoCreatures.proxy.wyvernEggDropChance;
if (getType() == 5) { //mother wyverns drop eggs more frequently
chance = MoCreatures.proxy.motherWyvernEggDropChance;
Expand Down

0 comments on commit 8a309d3

Please sign in to comment.