use proper shuffling algorithm for the loot

This commit is contained in:
Julian Krings 2025-06-09 19:35:43 +02:00
parent 172e234514
commit 944cc19ebc
No known key found for this signature in database
GPG Key ID: 208C6E08C3B718D2

View File

@ -78,7 +78,6 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.awt.Color; import java.awt.Color;
import java.util.Arrays;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -457,14 +456,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
} }
} }
for (int i = 0; i < 4; i++) { for (int i = nitems.length; i > 1; i--) {
try { int j = rng.nextInt(i);
Arrays.parallelSort(nitems, (a, b) -> rng.nextInt()); ItemStack tmp = nitems[i - 1];
break; nitems[i - 1] = nitems[j];
} catch (Throwable e) { nitems[j] = tmp;
Iris.reportError(e);
}
} }
inventory.setContents(nitems); inventory.setContents(nitems);