Skip to content

Commit

Permalink
Add a chance for a slime to give multiple offspring a helmet
Browse files Browse the repository at this point in the history
Only happens if the drop chance is not 100%, meaning not items it picked up
  • Loading branch information
KnightMiner committed May 23, 2022
1 parent f8bc652 commit 0aadc85
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void remove(Entity.RemovalReason reason) {
}

// spawn all children
float dropChance = getEquipmentDropChance(EquipmentSlot.HEAD);
for(int i = 0; i < count; ++i) {
float x = ((i % 2) - 0.5F) * offset;
float z = ((i / 2) - 0.5F) * offset;
Expand All @@ -115,9 +116,10 @@ public void remove(Entity.RemovalReason reason) {
slime.setInvulnerable(invulnerable);
slime.setSize(newSize, true);
if (i == helmetIndex) {
slime.setItemSlot(EquipmentSlot.HEAD, helmet);
slime.setItemSlot(EquipmentSlot.HEAD, helmet.copy());
setItemSlot(EquipmentSlot.HEAD, ItemStack.EMPTY);
helmet = ItemStack.EMPTY;
} else if (dropChance < 1 && random.nextFloat() < 0.25) {
slime.setItemSlot(EquipmentSlot.HEAD, helmet.copy());
}
slime.moveTo(this.getX() + x, this.getY() + 0.5D, this.getZ() + z, this.random.nextFloat() * 360.0F, 0.0F);
this.level.addFreshEntity(slime);
Expand Down

0 comments on commit 0aadc85

Please sign in to comment.