mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 09:26:08 +03:00
76 lines
2.4 KiB
Diff
76 lines
2.4 KiB
Diff
--- ../src-base/minecraft/net/minecraft/world/storage/loot/LootTable.java
|
|
+++ ../src-work/minecraft/net/minecraft/world/storage/loot/LootTable.java
|
|
@@ -24,11 +24,11 @@
|
|
{
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
public static final LootTable EMPTY_LOOT_TABLE = new LootTable(new LootPool[0]);
|
|
- private final LootPool[] pools;
|
|
+ private final List<LootPool> pools;
|
|
|
|
public LootTable(LootPool[] poolsIn)
|
|
{
|
|
- this.pools = poolsIn;
|
|
+ this.pools = Lists.newArrayList(poolsIn);
|
|
}
|
|
|
|
public List<ItemStack> generateLootForPools(Random rand, LootContext context)
|
|
@@ -144,6 +144,58 @@
|
|
return list;
|
|
}
|
|
|
|
+ //======================== FORGE START =============================================
|
|
+ private boolean isFrozen = false;
|
|
+ public void freeze()
|
|
+ {
|
|
+ this.isFrozen = true;
|
|
+ for (LootPool pool : this.pools)
|
|
+ pool.freeze();
|
|
+ }
|
|
+ public boolean isFrozen(){ return this.isFrozen; }
|
|
+ private void checkFrozen()
|
|
+ {
|
|
+ if (this.isFrozen())
|
|
+ throw new RuntimeException("Attempted to modify LootTable after being finalized!");
|
|
+ }
|
|
+
|
|
+ public LootPool getPool(String name)
|
|
+ {
|
|
+ for (LootPool pool : this.pools)
|
|
+ {
|
|
+ if (name.equals(pool.getName()))
|
|
+ return pool;
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ public LootPool removePool(String name)
|
|
+ {
|
|
+ checkFrozen();
|
|
+ for (LootPool pool : this.pools)
|
|
+ {
|
|
+ if (name.equals(pool.getName()))
|
|
+ {
|
|
+ this.pools.remove(pool);
|
|
+ return pool;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ public void addPool(LootPool pool)
|
|
+ {
|
|
+ checkFrozen();
|
|
+ for (LootPool p : this.pools)
|
|
+ {
|
|
+ if (p == pool || p.getName().equals(pool.getName()))
|
|
+ throw new RuntimeException("Attempted to add a duplicate pool to loot table: " + pool.getName());
|
|
+ }
|
|
+ this.pools.add(pool);
|
|
+ }
|
|
+ //======================== FORGE END ===============================================
|
|
+
|
|
public static class Serializer implements JsonDeserializer<LootTable>, JsonSerializer<LootTable>
|
|
{
|
|
public LootTable deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|