This commit is contained in:
Boblet 2024-09-12 16:21:56 +02:00
parent 00f5e8e279
commit 85925a54dc
5 changed files with 63 additions and 39 deletions

View File

@ -1,2 +1,6 @@
## Changed
* Most loot piles now have configurable loot pools
## Fixed ## Fixed
* Fixed some things not using variable max charge for armor mods, like static pads and DNT nanosuit tooltips * 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

View File

@ -233,7 +233,7 @@ public class ArcFurnaceRecipes extends SerializableRecipe {
List<MaterialStack> mats = new ArrayList(); List<MaterialStack> mats = new ArrayList();
for(JsonElement fluid : fluids) { for(JsonElement fluid : fluids) {
JsonArray matStack = fluid.getAsJsonArray(); 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) { if(stack.material.smeltable == SmeltingBehavior.SMELTABLE) {
mats.add(stack); mats.add(stack);
} }

View File

@ -65,6 +65,10 @@ public class ItemPool {
return pool.pool; 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) { public static ItemStack getStack(WeightedRandomChestContent[] pool, Random rand) {
WeightedRandomChestContent weighted = (WeightedRandomChestContent) WeightedRandom.getRandomItem(rand, pool); WeightedRandomChestContent weighted = (WeightedRandomChestContent) WeightedRandom.getRandomItem(rand, pool);
ItemStack stack = weighted.theItemId.copy(); ItemStack stack = weighted.theItemId.copy();

View File

@ -2,6 +2,7 @@ package com.hbm.itempool;
import static com.hbm.lib.HbmChestContents.weighted; import static com.hbm.lib.HbmChestContents.weighted;
import com.hbm.inventory.material.Mats;
import com.hbm.items.ItemAmmoEnums.Ammo357Magnum; import com.hbm.items.ItemAmmoEnums.Ammo357Magnum;
import com.hbm.items.ItemAmmoEnums.AmmoFatman; import com.hbm.items.ItemAmmoEnums.AmmoFatman;
import com.hbm.items.ModItems; 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_HIVE = "POOL_PILE_HIVE";
public static final String POOL_PILE_BONES = "POOL_PILE_BONES"; 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_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() { public static void init() {
@ -69,5 +77,36 @@ public class ItemPoolsPile {
weighted(ModItems.cap_sparkle, 0, 4, 4, 1), 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),
};
}};
} }
} }

View File

@ -4,7 +4,6 @@ import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot; import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
import com.hbm.inventory.material.Mats;
import com.hbm.itempool.ItemPool; import com.hbm.itempool.ItemPool;
import com.hbm.itempool.ItemPoolsPile; import com.hbm.itempool.ItemPoolsPile;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
@ -12,7 +11,6 @@ import com.hbm.items.special.ItemBookLore;
import com.hbm.items.ItemAmmoEnums.AmmoFatman; import com.hbm.items.ItemAmmoEnums.AmmoFatman;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -46,12 +44,9 @@ public class LootGenerator {
else else
loot.addItem(new ItemStack(ModItems.ammo_rocket), -0.25, 0, -0.25); loot.addItem(new ItemStack(ModItems.ammo_rocket), -0.25, 0, -0.25);
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++) addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.cap_nuka, 2), 0.125, i * 0.03125, 0.25);
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 < 2; i++) for(int i = 0; i < 6; i++) addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.cap_nuka, 2), 0.125, i * 0.03125, -0.25);
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()) { if(loot != null && loot.items.isEmpty()) {
for(int i = 0; i < 4; i++) { 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);
int type = world.rand.nextInt(4); addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MED_PILLS, world.rand), -0.25, 0, -0.125);
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);
} }
} }
@ -84,7 +72,7 @@ public class LootGenerator {
int count = world.rand.nextInt(5) + 3; int count = world.rand.nextInt(5) + 3;
for(int k = 0; k < count; k++) { 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()) { if(loot != null && loot.items.isEmpty()) {
boolean r = world.rand.nextBoolean(); boolean r = world.rand.nextBoolean();
if(r) if(r) addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MAKESHIFT_GUN, world.rand), 0.125, 0.025, 0.25);
addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.gun_lever_action), 0.125, 0.025, 0.25);
if(!r || world.rand.nextBoolean()) if(!r || world.rand.nextBoolean()) addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPoolsPile.POOL_PILE_MAKESHIFT_WRENCH, world.rand), -0.25, 0, -0.28125);
addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.wrench), -0.25, 0, -0.28125);
int count = world.rand.nextInt(2) + 1; int count = world.rand.nextInt(2) + 1;
for(int i = 0; i < count; i++) { 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);
addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.plate_steel), -0.25, i * 0.03125, 0.3125);
}
count = world.rand.nextInt(2) + 2; count = world.rand.nextInt(2) + 2;
for(int i = 0; i < count; i++) 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);
addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.wire_fine, 1, Mats.MAT_ALUMINIUM.id), 0.25, i * 0.03125, 0.1875);
} }
} }
@ -121,15 +104,11 @@ public class LootGenerator {
if(loot != null && loot.items.isEmpty()) { if(loot != null && loot.items.isEmpty()) {
boolean memes = world.rand.nextInt(10) == 0;
for(int i = 0; i < 4; i++) { for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) { for(int j = 0; j < 4; j++) {
if(world.rand.nextBoolean() || memes) { if(world.rand.nextBoolean()) {
int type = world.rand.nextInt(11); loot.addItem(ItemPool.getStack(ItemPoolsPile.POOL_PILE_NUKE_STORAGE, world.rand), -0.375 + i * 0.25, 0, -0.375 + j * 0.25);
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);
} }
} }
} }
@ -170,12 +149,10 @@ public class LootGenerator {
addItemWithDeviation(loot, world.rand, book, 0, 0, -0.25); addItemWithDeviation(loot, world.rand, book, 0, 0, -0.25);
int count = world.rand.nextInt(3) + 2; int count = world.rand.nextInt(3) + 2;
for(int k = 0; k < count; k++) for(int k = 0; k < count; k++) addItemWithDeviation(loot, world.rand, new ItemStack(Items.book), -0.25, k * 0.03125, 0.25);
addItemWithDeviation(loot, world.rand, new ItemStack(Items.book), -0.25, k * 0.03125, 0.25);
count = world.rand.nextInt(2) + 1; count = world.rand.nextInt(2) + 1;
for(int k = 0; k < count; k++) for(int k = 0; k < count; k++) addItemWithDeviation(loot, world.rand, new ItemStack(Items.paper), 0.25, k * 0.03125, 0.125);
addItemWithDeviation(loot, world.rand, new ItemStack(Items.paper), 0.25, k * 0.03125, 0.125);
} }
} }