Skip to content

Commit

Permalink
Make chest inventory size material factors configurable
Browse files Browse the repository at this point in the history
Closes #117
  • Loading branch information
rubensworks committed Apr 22, 2023
1 parent 1b95db3 commit 28df8c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/cyclops/colossalchests/GeneralConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ public class GeneralConfig extends DummyConfig {
@ConfigurableProperty(category = "general", comment = "Always create full creative-mode chests when formed. Should not be used in survival worlds!", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static boolean creativeChests = false;

@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorWood = 1;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorCopper = 1.666;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorIron = 2;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorSilver = 2.666;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorGold = 3;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorDiamond = 4;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorObsidian = 4;

public GeneralConfig() {
super(ColossalChests._instance, "general");
}
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/org/cyclops/colossalchests/block/ChestMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.world.inventory.MenuType;
import net.minecraft.core.Vec3i;
import net.minecraftforge.registries.ForgeRegistryEntry;
import org.cyclops.colossalchests.GeneralConfig;
import org.cyclops.colossalchests.Reference;
import org.cyclops.colossalchests.inventory.container.ContainerColossalChest;
import org.cyclops.colossalchests.blockentity.BlockEntityColossalChest;
Expand All @@ -18,6 +19,7 @@

import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

/**
* @author rubensworks
Expand All @@ -27,16 +29,16 @@ public class ChestMaterial extends ForgeRegistryEntry<ChestMaterial> {
public static final List<ChestMaterial> VALUES = Lists.newArrayList();
public static final Map<String, ChestMaterial> KEYED_VALUES = Maps.newHashMap();

public static final ChestMaterial WOOD = new ChestMaterial("wood", 1);
public static final ChestMaterial COPPER = new ChestMaterial("copper", 1.666);
public static final ChestMaterial IRON = new ChestMaterial("iron", 2);
public static final ChestMaterial SILVER = new ChestMaterial("silver", 2.666);
public static final ChestMaterial GOLD = new ChestMaterial("gold", 3);
public static final ChestMaterial DIAMOND = new ChestMaterial("diamond", 4);
public static final ChestMaterial OBSIDIAN = new ChestMaterial("obsidian", 4);
public static final ChestMaterial WOOD = new ChestMaterial("wood", () -> GeneralConfig.chestInventoryMaterialFactorWood);
public static final ChestMaterial COPPER = new ChestMaterial("copper", () -> GeneralConfig.chestInventoryMaterialFactorCopper);
public static final ChestMaterial IRON = new ChestMaterial("iron", () -> GeneralConfig.chestInventoryMaterialFactorIron);
public static final ChestMaterial SILVER = new ChestMaterial("silver", () -> GeneralConfig.chestInventoryMaterialFactorSilver);
public static final ChestMaterial GOLD = new ChestMaterial("gold", () -> GeneralConfig.chestInventoryMaterialFactorGold);
public static final ChestMaterial DIAMOND = new ChestMaterial("diamond", () -> GeneralConfig.chestInventoryMaterialFactorDiamond);
public static final ChestMaterial OBSIDIAN = new ChestMaterial("obsidian", () -> GeneralConfig.chestInventoryMaterialFactorObsidian);

private final String name;
private final double inventoryMultiplier;
private final Supplier<Double> inventoryMultiplier;
private final int index;

private ColossalChest blockCore;
Expand All @@ -45,7 +47,7 @@ public class ChestMaterial extends ForgeRegistryEntry<ChestMaterial> {
private CubeDetector chestDetector = null;
private MenuType<ContainerColossalChest> container;

public ChestMaterial(String name, double inventoryMultiplier) {
public ChestMaterial(String name, Supplier<Double> inventoryMultiplier) {
this.name = name;
this.inventoryMultiplier = inventoryMultiplier;
this.index = ChestMaterial.VALUES.size();
Expand All @@ -62,7 +64,7 @@ public String getName() {
}

public double getInventoryMultiplier() {
return this.inventoryMultiplier;
return this.inventoryMultiplier.get();
}

public String getUnlocalizedName() {
Expand Down

0 comments on commit 28df8c9

Please sign in to comment.