Skip to content

Commit

Permalink
Can adjust the drop of arrows from skeletons
Browse files Browse the repository at this point in the history
  • Loading branch information
OldSerpskiStalker committed Oct 14, 2024
1 parent f12d26a commit 4903725
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ private static JsonObject getJsonObject()
recordObject.addProperty("damage_spread_factor",
DataSkeletonDropItem.ConfigDataSkeletonDrop.instance.getDamageSpreadFactor());

recordObject.addProperty("arrows_to_drops",
DataSkeletonDropItem.ConfigDataSkeletonDrop.instance.getArrowsToDrops());

return recordObject;
}

Expand Down Expand Up @@ -170,6 +173,12 @@ public void loadFromFile()
DataSkeletonDropItem.ConfigDataSkeletonDrop.instance.
setDamageSpreadFactor(jsonObjectSkeletonDrop.get("damage_spread_factor").getAsFloat());
}

if (jsonObjectSkeletonDrop.has("arrows_to_drops"))
{
DataSkeletonDropItem.ConfigDataSkeletonDrop.instance.
setArrowsToDrops(jsonObjectSkeletonDrop.get("arrows_to_drops").getAsByte());
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.imesense.dynamicspawncontrol.debug.CodeGenericUtils;

import javax.annotation.Nonnull;
import java.util.Random;

/**
*
Expand Down Expand Up @@ -59,6 +60,11 @@ public static final class ConfigDataSkeletonDrop
*/
private Float damageSpreadFactor = 0.2f;

/**
*
*/
private Byte arrowsToDrops = (byte)(1 + new Random().nextInt(3));

/**
*
* @param category
Expand Down Expand Up @@ -132,6 +138,15 @@ public void setDamageSpreadFactor(Float damageSpreadFactor)
this.damageSpreadFactor = damageSpreadFactor;
}

/**
*
* @param arrowsToDrops
*/
public void setArrowsToDrops(Byte arrowsToDrops)
{
this.arrowsToDrops = arrowsToDrops;
}

/**
*
* @return
Expand Down Expand Up @@ -195,6 +210,15 @@ public Float getDamageSpreadFactor()
return this.damageSpreadFactor;
}

/**
*
* @return
*/
public Byte getArrowsToDrops()
{
return this.arrowsToDrops;
}

/**
*
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public synchronized void onUpdateLivingDropsEvent_0(LivingDropsEvent event)

addDamagedItemToDrops(skeleton, drops, skeleton.getHeldItemMainhand(),
DataSkeletonDropItem.ConfigDataSkeletonDrop.instance.getHandItemDamageFactor());

addArrowsToDrops(skeleton, drops,
DataSkeletonDropItem.ConfigDataSkeletonDrop.instance.getArrowsToDrops());
}
}

Expand Down Expand Up @@ -116,5 +119,17 @@ private void addDamagedItemToDrops(EntitySkeleton skeleton, List<EntityItem> dro
drops.add(new EntityItem(skeleton.world, skeleton.posX, skeleton.posY, skeleton.posZ, damagedItem));
}
}

/**
*
* @param skeleton
* @param drops
* @param arrowCount
*/
private void addArrowsToDrops(EntitySkeleton skeleton, List<EntityItem> drops, byte arrowCount)
{
ItemStack arrows = new ItemStack(Items.ARROW, arrowCount);
drops.add(new EntityItem(skeleton.world, skeleton.posX, skeleton.posY, skeleton.posZ, arrows));
}
}

0 comments on commit 4903725

Please sign in to comment.