Fix witch lootable

This commit is contained in:
ceze88 2023-10-09 17:43:32 +02:00
parent 95ce5bb8c2
commit 084d2c8348

View File

@ -126,9 +126,9 @@ public class LootablesManager {
boolean isCharged = entity instanceof Creeper && ((Creeper) entity).isPowered();
//Run main loot
for (Loot loot : lootable.getRegisteredLoot().stream().filter(loot -> loot.getMaterial() != null).collect(Collectors.toList())) {
for (Loot loot : lootable.getRegisteredLoot()) {
if (loot.isRequireCharged() && !isCharged) continue;
if (loot.getOnlyDropFor().size() != 0 && loot.getOnlyDropFor().stream().noneMatch(type -> entity.getKiller() != null && type == entity.getKiller().getType())) continue;
if (!loot.getOnlyDropFor().isEmpty() && loot.getOnlyDropFor().stream().noneMatch(type -> entity.getKiller() != null && type == entity.getKiller().getType())) continue;
int finalLooting = loot.isAllowLootingEnchant() ? looting : 0;
long max = (long) (((long) (loot.getMax() + finalLooting) * times) * (loot.getChance()/100 + (loot.isAllowLootingEnchant() ? extraChance : 0)));
@ -136,7 +136,7 @@ public class LootablesManager {
long amount = ThreadLocalRandom.current().nextLong((max - min) + 1) + min;
if (amount > 0) {
if (loot.getMaterial() != null && amount > 0) {
ItemStack item = entity.getFireTicks() > 0
? loot.getBurnedMaterial() != null ? loot.getBurnedMaterial().parseItem() : loot.getMaterial().parseItem()
: loot.getMaterial().parseItem();
@ -153,6 +153,7 @@ public class LootablesManager {
toDrop.add(new Drop(item));
}
//Run child loot //TODO: remove duplicated code
for (Loot child : loot.getChildLoot()) {
if (child.isRequireCharged() && !isCharged) continue;