mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #2099 from Lazzzycatwastaken/structur
fix for Ticking entity crash when spawning skeletors with guns
This commit is contained in:
commit
334cffe04e
@ -417,7 +417,7 @@ public class ModEventHandler {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
ItemStack bowReplacement = getSkelegun(soot, world.rand);
|
ItemStack bowReplacement = getSkelegun(soot, world.rand);
|
||||||
slotPools.put(0, createSlotPool(100, bowReplacement != null ? new Object[][]{{bowReplacement, 1}} : new Object[][]{}));
|
slotPools.put(0, createSlotPool(50, bowReplacement != null ? new Object[][]{{bowReplacement, 1}} : new Object[][]{}));
|
||||||
}
|
}
|
||||||
assignItemsToEntity(entity, slotPools);
|
assignItemsToEntity(entity, slotPools);
|
||||||
}
|
}
|
||||||
@ -429,15 +429,23 @@ public class ModEventHandler {
|
|||||||
entity.setCurrentItemOrArmor(1, new ItemStack(boots));
|
entity.setCurrentItemOrArmor(1, new ItemStack(boots));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<WeightedRandomObject> createSlotPool(int nullWeight, Object[][] items) { // nullWeight is the weight of the empty slot (no shit)
|
private List<WeightedRandomObject> createSlotPool(int nullWeight, Object[][] items) {
|
||||||
List<WeightedRandomObject> pool = new ArrayList<>();
|
List<WeightedRandomObject> pool = new ArrayList<>();
|
||||||
pool.add(new WeightedRandomObject(null, nullWeight));
|
pool.add(new WeightedRandomObject(null, nullWeight));
|
||||||
for (Object[] item : items) {
|
for (Object[] item : items) {
|
||||||
pool.add(new WeightedRandomObject(new ItemStack((Item) item[0]), (int) item[1]));
|
Object obj = item[0];
|
||||||
|
int weight = (int) item[1];
|
||||||
|
|
||||||
|
if (obj instanceof Item) {
|
||||||
|
pool.add(new WeightedRandomObject(new ItemStack((Item) obj), weight));
|
||||||
|
} else if (obj instanceof ItemStack) { //lol just make it pass ItemStack aswell
|
||||||
|
pool.add(new WeightedRandomObject(obj, weight));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void assignItemsToEntity(EntityLivingBase entity, Map<Integer, List<WeightedRandomObject>> slotPools) {
|
private void assignItemsToEntity(EntityLivingBase entity, Map<Integer, List<WeightedRandomObject>> slotPools) {
|
||||||
for (Map.Entry<Integer, List<WeightedRandomObject>> entry : slotPools.entrySet()) {
|
for (Map.Entry<Integer, List<WeightedRandomObject>> entry : slotPools.entrySet()) {
|
||||||
int slot = entry.getKey();
|
int slot = entry.getKey();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user