From 85925a54dc1bdaa3554f057e83caec59a5f71e19 Mon Sep 17 00:00:00 2001 From: Boblet Date: Thu, 12 Sep 2024 16:21:56 +0200 Subject: [PATCH] fixes --- changelog | 6 ++- .../inventory/recipes/ArcFurnaceRecipes.java | 2 +- src/main/java/com/hbm/itempool/ItemPool.java | 4 ++ .../java/com/hbm/itempool/ItemPoolsPile.java | 39 ++++++++++++++ src/main/java/com/hbm/util/LootGenerator.java | 51 +++++-------------- 5 files changed, 63 insertions(+), 39 deletions(-) diff --git a/changelog b/changelog index 6b89db494..198a7f873 100644 --- a/changelog +++ b/changelog @@ -1,2 +1,6 @@ +## Changed +* Most loot piles now have configurable loot pools + ## Fixed -* Fixed some things not using variable max charge for armor mods, like static pads and DNT nanosuit tooltips \ No newline at end of file +* Fixed some things not using variable max charge for armor mods, like static pads and DNT nanosuit tooltips +* Fixed arc furnace recipe config parser breaking when reading fluid recipes \ No newline at end of file diff --git a/src/main/java/com/hbm/inventory/recipes/ArcFurnaceRecipes.java b/src/main/java/com/hbm/inventory/recipes/ArcFurnaceRecipes.java index eaafa0638..c32d31a52 100644 --- a/src/main/java/com/hbm/inventory/recipes/ArcFurnaceRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/ArcFurnaceRecipes.java @@ -233,7 +233,7 @@ public class ArcFurnaceRecipes extends SerializableRecipe { List mats = new ArrayList(); for(JsonElement fluid : fluids) { JsonArray matStack = fluid.getAsJsonArray(); - MaterialStack stack = new MaterialStack(Mats.matById.get(matStack.get(0).getAsInt()), matStack.get(1).getAsInt()); + MaterialStack stack = new MaterialStack(Mats.matByName.get(matStack.get(0).getAsString()), matStack.get(1).getAsInt()); if(stack.material.smeltable == SmeltingBehavior.SMELTABLE) { mats.add(stack); } diff --git a/src/main/java/com/hbm/itempool/ItemPool.java b/src/main/java/com/hbm/itempool/ItemPool.java index 0d4fd2d11..a112f92a5 100644 --- a/src/main/java/com/hbm/itempool/ItemPool.java +++ b/src/main/java/com/hbm/itempool/ItemPool.java @@ -65,6 +65,10 @@ public class ItemPool { return pool.pool; } + public static ItemStack getStack(String pool, Random rand) { + return getStack(ItemPool.getPool(pool), rand); + } + public static ItemStack getStack(WeightedRandomChestContent[] pool, Random rand) { WeightedRandomChestContent weighted = (WeightedRandomChestContent) WeightedRandom.getRandomItem(rand, pool); ItemStack stack = weighted.theItemId.copy(); diff --git a/src/main/java/com/hbm/itempool/ItemPoolsPile.java b/src/main/java/com/hbm/itempool/ItemPoolsPile.java index 46bf7adca..254016416 100644 --- a/src/main/java/com/hbm/itempool/ItemPoolsPile.java +++ b/src/main/java/com/hbm/itempool/ItemPoolsPile.java @@ -2,6 +2,7 @@ package com.hbm.itempool; import static com.hbm.lib.HbmChestContents.weighted; +import com.hbm.inventory.material.Mats; import com.hbm.items.ItemAmmoEnums.Ammo357Magnum; import com.hbm.items.ItemAmmoEnums.AmmoFatman; import com.hbm.items.ModItems; @@ -14,6 +15,13 @@ public class ItemPoolsPile { public static final String POOL_PILE_HIVE = "POOL_PILE_HIVE"; public static final String POOL_PILE_BONES = "POOL_PILE_BONES"; public static final String POOL_PILE_CAPS = "POOL_PILE_CAPS"; + public static final String POOL_PILE_MED_SYRINGE = "POOL_PILE_MED_SYRINGE"; + public static final String POOL_PILE_MED_PILLS = "POOL_PILE_MED_PILLS"; + public static final String POOL_PILE_MAKESHIFT_GUN = "POOL_PILE_MAKESHIFT_GUN"; + public static final String POOL_PILE_MAKESHIFT_WRENCH = "POOL_PILE_MAKESHIFT_WRENCH"; + public static final String POOL_PILE_MAKESHIFT_PLATES = "POOL_PILE_MAKESHIFT_PLATES"; + public static final String POOL_PILE_MAKESHIFT_WIRE = "POOL_PILE_MAKESHIFT_WIRE"; + public static final String POOL_PILE_NUKE_STORAGE = "POOL_PILE_NUKE_STORAGE"; public static void init() { @@ -69,5 +77,36 @@ public class ItemPoolsPile { weighted(ModItems.cap_sparkle, 0, 4, 4, 1), }; }}; + + //medicine stashes + new ItemPool(POOL_PILE_MED_SYRINGE) {{ + this.pool = new WeightedRandomChestContent[] { + weighted(ModItems.syringe_metal_stimpak, 0, 1, 1, 10), + weighted(ModItems.syringe_metal_medx, 0, 1, 1, 5), + weighted(ModItems.syringe_metal_psycho, 0, 1, 1, 5), + }; + }}; + new ItemPool(POOL_PILE_MED_PILLS) {{ + this.pool = new WeightedRandomChestContent[] { + weighted(ModItems.radaway, 0, 1, 1, 10), + weighted(ModItems.radx, 0, 1, 1, 10), + weighted(ModItems.iv_blood, 0, 1, 1, 15), + weighted(ModItems.siox, 0, 1, 1, 5), + }; + }}; + + //makeshift gun + new ItemPool(POOL_PILE_MAKESHIFT_GUN) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.gun_lever_action, 0, 1, 1, 10) }; }}; + new ItemPool(POOL_PILE_MAKESHIFT_WRENCH) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.wrench, 0, 1, 1, 10) }; }}; + new ItemPool(POOL_PILE_MAKESHIFT_PLATES) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.plate_combine_steel, 0, 1, 1, 10) }; }}; + new ItemPool(POOL_PILE_MAKESHIFT_WIRE) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.wire_fine, Mats.MAT_ALUMINIUM.id, 1, 1, 10) }; }}; + + new ItemPool(POOL_PILE_NUKE_STORAGE) {{ + this.pool = new WeightedRandomChestContent[] { + weighted(ModItems.ammo_nuke, AmmoFatman.STOCK.ordinal(), 1, 1, 10), + weighted(ModItems.ammo_nuke, AmmoFatman.LOW.ordinal(), 1, 1, 50), + weighted(ModItems.ammo_nuke, AmmoFatman.SAFE.ordinal(), 1, 1, 50), + }; + }}; } } diff --git a/src/main/java/com/hbm/util/LootGenerator.java b/src/main/java/com/hbm/util/LootGenerator.java index bf96fb050..ee4f64899 100644 --- a/src/main/java/com/hbm/util/LootGenerator.java +++ b/src/main/java/com/hbm/util/LootGenerator.java @@ -4,7 +4,6 @@ import java.util.Random; import com.hbm.blocks.ModBlocks; import com.hbm.blocks.generic.BlockLoot.TileEntityLoot; -import com.hbm.inventory.material.Mats; import com.hbm.itempool.ItemPool; import com.hbm.itempool.ItemPoolsPile; import com.hbm.items.ModItems; @@ -12,7 +11,6 @@ import com.hbm.items.special.ItemBookLore; import com.hbm.items.ItemAmmoEnums.AmmoFatman; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -46,12 +44,9 @@ public class LootGenerator { else loot.addItem(new ItemStack(ModItems.ammo_rocket), -0.25, 0, -0.25); - for(int i = 0; i < 4; i++) - addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.cap_nuka, 2), 0.125, i * 0.03125, 0.25); - for(int i = 0; i < 2; i++) - addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.syringe_metal_stimpak, 1), -0.25, i * 0.03125, 0.25); - for(int i = 0; i < 6; i++) - addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.cap_nuka, 2), 0.125, i * 0.03125, -0.25); + for(int i = 0; i < 4; i++) addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.cap_nuka, 2), 0.125, i * 0.03125, 0.25); + for(int i = 0; i < 2; i++) addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.syringe_metal_stimpak, 1), -0.25, i * 0.03125, 0.25); + for(int i = 0; i < 6; i++) addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.cap_nuka, 2), 0.125, i * 0.03125, -0.25); } } @@ -61,15 +56,8 @@ public class LootGenerator { if(loot != null && loot.items.isEmpty()) { - for(int i = 0; i < 4; i++) { - int type = world.rand.nextInt(4); - Item syringe = type < 2 ? ModItems.syringe_metal_stimpak : type == 2 ? ModItems.syringe_metal_medx : ModItems.syringe_metal_psycho; - addItemWithDeviation(loot, world.rand, new ItemStack(syringe), 0.125, i * 0.03125, 0.25); - } - - int type = world.rand.nextInt(8); - Item syringe = type < 2 ? ModItems.radaway : type < 4 ? ModItems.radx : type < 7 ? ModItems.iv_blood : ModItems.siox; - addItemWithDeviation(loot, world.rand, new ItemStack(syringe), -0.25, 0, -0.125); + for(int i = 0; i < 4; i++) addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MED_SYRINGE, world.rand), 0.125, i * 0.03125, 0.25); + addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MED_PILLS, world.rand), -0.25, 0, -0.125); } } @@ -84,7 +72,7 @@ public class LootGenerator { int count = world.rand.nextInt(5) + 3; for(int k = 0; k < count; k++) { - addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPool.getPool(ItemPoolsPile.POOL_PILE_CAPS), world.rand), i * 0.3125, k * 0.03125, j * 0.3125); + addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_CAPS, world.rand), i * 0.3125, k * 0.03125, j * 0.3125); } } } @@ -98,20 +86,15 @@ public class LootGenerator { if(loot != null && loot.items.isEmpty()) { boolean r = world.rand.nextBoolean(); - if(r) - addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.gun_lever_action), 0.125, 0.025, 0.25); + if(r) addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MAKESHIFT_GUN, world.rand), 0.125, 0.025, 0.25); - if(!r || world.rand.nextBoolean()) - addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.wrench), -0.25, 0, -0.28125); + if(!r || world.rand.nextBoolean()) addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MAKESHIFT_WRENCH, world.rand), -0.25, 0, -0.28125); int count = world.rand.nextInt(2) + 1; - for(int i = 0; i < count; i++) { - addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.plate_steel), -0.25, i * 0.03125, 0.3125); - } + for(int i = 0; i < count; i++) addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MAKESHIFT_PLATES, world.rand), -0.25, i * 0.03125, 0.3125); count = world.rand.nextInt(2) + 2; - for(int i = 0; i < count; i++) - addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.wire_fine, 1, Mats.MAT_ALUMINIUM.id), 0.25, i * 0.03125, 0.1875); + for(int i = 0; i < count; i++) addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MAKESHIFT_WIRE, world.rand), 0.25, i * 0.03125, 0.1875); } } @@ -121,15 +104,11 @@ public class LootGenerator { if(loot != null && loot.items.isEmpty()) { - boolean memes = world.rand.nextInt(10) == 0; - for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { - if(world.rand.nextBoolean() || memes) { - int type = world.rand.nextInt(11); - AmmoFatman nuke = memes ? AmmoFatman.PUMPKIN : type == 0 ? AmmoFatman.STOCK : type <= 5 ? AmmoFatman.LOW : AmmoFatman.SAFE; - loot.addItem(ModItems.ammo_nuke.stackFromEnum(nuke), -0.375 + i * 0.25, 0, -0.375 + j * 0.25); + if(world.rand.nextBoolean()) { + loot.addItem(ItemPool.getStack(ItemPoolsPile.POOL_PILE_NUKE_STORAGE, world.rand), -0.375 + i * 0.25, 0, -0.375 + j * 0.25); } } } @@ -170,12 +149,10 @@ public class LootGenerator { addItemWithDeviation(loot, world.rand, book, 0, 0, -0.25); int count = world.rand.nextInt(3) + 2; - for(int k = 0; k < count; k++) - addItemWithDeviation(loot, world.rand, new ItemStack(Items.book), -0.25, k * 0.03125, 0.25); + for(int k = 0; k < count; k++) addItemWithDeviation(loot, world.rand, new ItemStack(Items.book), -0.25, k * 0.03125, 0.25); count = world.rand.nextInt(2) + 1; - for(int k = 0; k < count; k++) - addItemWithDeviation(loot, world.rand, new ItemStack(Items.paper), 0.25, k * 0.03125, 0.125); + for(int k = 0; k < count; k++) addItemWithDeviation(loot, world.rand, new ItemStack(Items.paper), 0.25, k * 0.03125, 0.125); } }