9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-29 20:19:06 +00:00

Fixed Loot tables acting like a cucumber in the sun

- Fixed loot chests containing the exact same loot
- Fixed chests having nothing if a roll fails
- Fixed rolls always being done in the same order
- Added method to BlockPosition to get a unique long from 3 integers (x, y z)
This commit is contained in:
StrangeOne101
2021-07-05 04:24:13 +12:00
parent 3aa085f17e
commit 5103d91db0
6 changed files with 52 additions and 30 deletions

View File

@@ -1,5 +1,6 @@
package com.volmit.iris.object;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.volmit.iris.util.ArrayType;
@@ -56,35 +57,21 @@ public class IrisLootTable extends IrisRegistrant
KList<ItemStack> lootf = new KList<>();
int m = 0;
int mx = rng.i(getMinPicked(), getMaxPicked());
for(IrisLoot i : loot)
{
if(i.getSlotTypes().equals(slot))
while (m < mx) {
int num = rng.i(loot.size());
IrisLoot l = loot.get(num);
if(l.getSlotTypes() == slot)
{
ItemStack item = i.get(debug, false, this, rng, x, y, z);
ItemStack item = l.get(debug, false, this, rng, x, y, z);
if(item != null)
{
lootf.add(item);
}
}
m++;
if(m > maxPicked)
{
break;
}
}
if(lootf.size() < getMinPicked())
{
for(int i = 0; i < getMinPicked() - lootf.size(); i++)
{
ItemStack item = loot.get(rng.nextParallelRNG(3945).nextInt(loot.size())).get(debug, doSomething, this, rng, x, y, z);
if(item != null)
if(item != null && item.getType() != Material.AIR)
{
lootf.add(item);
m++;
}
}
}

View File

@@ -256,6 +256,12 @@ public class IrisObjectPlacement
});
}
/**
* Gets the loot table that should be used for the block
* @param data The block data of the block
* @param dataManager Iris Data Manager
* @return The loot table it should use.
*/
public IrisLootTable getTable(BlockData data, IrisDataManager dataManager) {
TableCache cache = getCache(dataManager);