From 18647ceb31029b6127ebd5a54ddedf110b388225 Mon Sep 17 00:00:00 2001 From: GlodBlock <1356392126@qq.com> Date: Wed, 11 May 2022 22:07:01 +0800 Subject: [PATCH] config file --- .../java/com/glodblock/github/FluidCraft.java | 2 ++ .../com/glodblock/github/common/Config.java | 31 ++++++++++++++++ .../item/ItemBasicFluidStorageCell.java | 2 ++ .../item/ItemBasicFluidStoragePart.java | 2 ++ .../FluidConvertingInventoryAdaptor.java | 3 +- .../github/loader/ItemAndBlockHolder.java | 2 ++ .../glodblock/github/loader/RecipeLoader.java | 35 ++++++++++--------- 7 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/glodblock/github/common/Config.java diff --git a/src/main/java/com/glodblock/github/FluidCraft.java b/src/main/java/com/glodblock/github/FluidCraft.java index 3806135f..58ea2d13 100644 --- a/src/main/java/com/glodblock/github/FluidCraft.java +++ b/src/main/java/com/glodblock/github/FluidCraft.java @@ -1,6 +1,7 @@ package com.glodblock.github; import appeng.api.AEApi; +import com.glodblock.github.common.Config; import com.glodblock.github.common.storage.FluidCellHandler; import com.glodblock.github.inventory.InventoryHandler; import com.glodblock.github.loader.*; @@ -31,6 +32,7 @@ public class FluidCraft { @Mod.EventHandler public static void preInit(FMLPreInitializationEvent event) { + Config.run(); (new ChannelLoader()).run(); proxy.preInit(event); } diff --git a/src/main/java/com/glodblock/github/common/Config.java b/src/main/java/com/glodblock/github/common/Config.java new file mode 100644 index 00000000..fa7ae617 --- /dev/null +++ b/src/main/java/com/glodblock/github/common/Config.java @@ -0,0 +1,31 @@ +package com.glodblock.github.common; + +import cpw.mods.fml.relauncher.FMLInjectionData; +import net.minecraftforge.common.config.Configuration; + +import java.io.File; + +public class Config { + + private static final Configuration Config = new Configuration(new File(new File((File) FMLInjectionData.data()[6], "config"), "ae2fc.cfg")); + + public static boolean fluidCells; + public static boolean noFluidPacket; + + public static void run() { + loadCategory(); + loadProperty(); + } + + private static void loadProperty() { + fluidCells = Config.getBoolean("Enable Fluid Storage Cell", "Fluid Craft for AE2", true, "Enable this to generate the fluid storage cells. If you are playing with EC2, you can turn it off."); + noFluidPacket = Config.getBoolean("No Fluid Packet", "Fluid Craft for AE2", false, "Enable this to make normal ME Interface can emit fluid with fluid pattern, like the Fluid Interface."); + + if (Config.hasChanged()) + Config.save(); + } + + private static void loadCategory() { + Config.addCustomCategoryComment("Fluid Craft for AE2", "Settings for AE2FC."); + } +} diff --git a/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStorageCell.java b/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStorageCell.java index 7b9534e0..7612509f 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStorageCell.java +++ b/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStorageCell.java @@ -18,6 +18,7 @@ import appeng.items.contents.CellUpgrades; import appeng.util.InventoryAdaptor; import appeng.util.Platform; import com.glodblock.github.FluidCraft; +import com.glodblock.github.common.Config; import com.glodblock.github.common.storage.CellType; import com.glodblock.github.common.storage.IFluidCellInventory; import com.glodblock.github.common.storage.IFluidCellInventoryHandler; @@ -323,6 +324,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu } public ItemBasicFluidStorageCell register() { + if (!Config.fluidCells) return null; GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024 , FluidCraft.MODID); return this; } diff --git a/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStoragePart.java b/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStoragePart.java index 097ebe53..8f1bb661 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStoragePart.java +++ b/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStoragePart.java @@ -1,6 +1,7 @@ package com.glodblock.github.common.item; import com.glodblock.github.FluidCraft; +import com.glodblock.github.common.Config; import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; @@ -57,6 +58,7 @@ public class ItemBasicFluidStoragePart extends Item { } public ItemBasicFluidStoragePart register() { + if (!Config.fluidCells) return null; GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PART, FluidCraft.MODID); return this; } diff --git a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java index fe176a4e..9b538395 100644 --- a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java +++ b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java @@ -5,6 +5,7 @@ import appeng.tile.networking.TileCableBus; import appeng.util.InventoryAdaptor; import appeng.util.inv.IInventoryDestination; import appeng.util.inv.ItemSlot; +import com.glodblock.github.common.Config; import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.common.parts.PartFluidInterface; import com.glodblock.github.common.tile.TileFluidInterface; @@ -29,7 +30,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { // sometimes i wish 1.7.10 has cap system. ForgeDirection f = Util.from(face); TileEntity inter = capProvider.getWorldObj().getTileEntity(capProvider.xCoord + f.offsetX, capProvider.yCoord + f.offsetY, capProvider.zCoord + f.offsetZ); - if (!(inter instanceof TileFluidInterface || (inter instanceof TileCableBus && ((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface))) + if (!Config.noFluidPacket && !(inter instanceof TileFluidInterface || (inter instanceof TileCableBus && ((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface))) return InventoryAdaptor.getAdaptor(capProvider, f); IInventory item = capProvider instanceof IInventory ? (IInventory) capProvider : null; IFluidHandler fluid = capProvider instanceof IFluidHandler ? (IFluidHandler) capProvider : null; diff --git a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java index 3b59ee88..cfddefe6 100644 --- a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java +++ b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java @@ -1,5 +1,6 @@ package com.glodblock.github.loader; +import com.glodblock.github.common.Config; import com.glodblock.github.common.block.BlockFluidDiscretizer; import com.glodblock.github.common.block.BlockFluidInterface; import com.glodblock.github.common.block.BlockFluidPacketDecoder; @@ -29,6 +30,7 @@ public class ItemAndBlockHolder { public static BlockFluidInterface INTERFACE = new BlockFluidInterface().register(); public static void loadSetting() { + if (!Config.fluidCells) return; CellType.Cell1kPart.setItemInstance(CELL_PART); CellType.Cell4kPart.setItemInstance(CELL_PART); CellType.Cell16kPart.setItemInstance(CELL_PART); diff --git a/src/main/java/com/glodblock/github/loader/RecipeLoader.java b/src/main/java/com/glodblock/github/loader/RecipeLoader.java index cfb1c105..4b102841 100644 --- a/src/main/java/com/glodblock/github/loader/RecipeLoader.java +++ b/src/main/java/com/glodblock/github/loader/RecipeLoader.java @@ -1,5 +1,6 @@ package com.glodblock.github.loader; +import com.glodblock.github.common.Config; import com.glodblock.github.common.item.ItemBasicFluidStorageCell; import com.glodblock.github.common.storage.CellType; import cpw.mods.fml.common.registry.GameRegistry; @@ -37,25 +38,27 @@ public class RecipeLoader implements Runnable { GameRegistry.addRecipe(new ShapedOreRecipe(ENCODER.stack(), "LPL", "IWI", "III", 'I', "ingotIron", 'L', "blockLapis", 'P', AE2_PROCESS_ENG, 'W', AE2_WORK_BENCH)); GameRegistry.addShapelessRecipe(FLUID_TERMINAL.stack(), AE2_PATTERN_TERM, ENCODER); - OreDictionary.registerOre("anyCertusCrystal", AE2_PURE_CERTUS); - for (ItemStack it : OreDictionary.getOres("crystalCertusQuartz")) - OreDictionary.registerOre("anyCertusCrystal", it); + if (Config.fluidCells) { + OreDictionary.registerOre("anyCertusCrystal", AE2_PURE_CERTUS); + for (ItemStack it : OreDictionary.getOres("crystalCertusQuartz")) + OreDictionary.registerOre("anyCertusCrystal", it); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell1kPart.stack(1), "DCD", "CEC", "DCD", 'D', "dyeBlue", 'C', "anyCertusCrystal", 'E', AE2_PROCESS_ENG)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell4kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell1kPart.stack(1), 'P', AE2_PROCESS_CAL, 'G', AE2_QUARTZ_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell16kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell4kPart.stack(1), 'P', AE2_PROCESS_LOG, 'G', AE2_QUARTZ_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell64kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell16kPart.stack(1), 'P', AE2_PROCESS_ENG, 'G', AE2_QUARTZ_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell256kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell64kPart.stack(1), 'P', AE2_PROCESS_CAL, 'G', AE2_LAMP_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell1024kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell256kPart.stack(1), 'P', AE2_PROCESS_LOG, 'G', AE2_LAMP_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell4096kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell1024kPart.stack(1), 'P', AE2_PROCESS_ENG, 'G', AE2_LAMP_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell1kPart.stack(1), "DCD", "CEC", "DCD", 'D', "dyeBlue", 'C', "anyCertusCrystal", 'E', AE2_PROCESS_ENG)); + GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell4kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell1kPart.stack(1), 'P', AE2_PROCESS_CAL, 'G', AE2_QUARTZ_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell16kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell4kPart.stack(1), 'P', AE2_PROCESS_LOG, 'G', AE2_QUARTZ_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell64kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell16kPart.stack(1), 'P', AE2_PROCESS_ENG, 'G', AE2_QUARTZ_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell256kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell64kPart.stack(1), 'P', AE2_PROCESS_CAL, 'G', AE2_LAMP_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell1024kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell256kPart.stack(1), 'P', AE2_PROCESS_LOG, 'G', AE2_LAMP_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell4096kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell1024kPart.stack(1), 'P', AE2_PROCESS_ENG, 'G', AE2_LAMP_GLASS)); - ItemBasicFluidStorageCell[] cells = new ItemBasicFluidStorageCell[]{ - CELL1K, CELL4K, CELL16K, CELL64K, CELL256K, CELL1024K, CELL4096K - }; + ItemBasicFluidStorageCell[] cells = new ItemBasicFluidStorageCell[]{ + CELL1K, CELL4K, CELL16K, CELL64K, CELL256K, CELL1024K, CELL4096K + }; - for (ItemBasicFluidStorageCell cell : cells) { - GameRegistry.addRecipe(new ShapedOreRecipe(cell, "GDG", "DCD", "III", 'D', "dustRedstone", 'G', AE2_QUARTZ_GLASS, 'C', cell.getComponent(), 'I', "ingotIron")); - GameRegistry.addRecipe(new ShapelessOreRecipe(cell, AE2_CELL_HOUSING, cell.getComponent())); + for (ItemBasicFluidStorageCell cell : cells) { + GameRegistry.addRecipe(new ShapedOreRecipe(cell, "GDG", "DCD", "III", 'D', "dustRedstone", 'G', AE2_QUARTZ_GLASS, 'C', cell.getComponent(), 'I', "ingotIron")); + GameRegistry.addRecipe(new ShapelessOreRecipe(cell, AE2_CELL_HOUSING, cell.getComponent())); + } } }