diff options
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r-- | src/main/java/gregtech/common/GT_Proxy.java | 3 | ||||
-rw-r--r-- | src/main/java/gregtech/common/items/GT_MetaGenerated_Item_98.java | 90 |
2 files changed, 73 insertions, 20 deletions
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 2e18ea9693..dc9db6e8e3 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -26,6 +26,7 @@ import gregtech.api.util.*; import gregtech.common.entities.GT_Entity_Arrow; import gregtech.common.gui.GT_ContainerVolumetricFlask; import gregtech.common.gui.GT_GUIContainerVolumetricFlask; +import gregtech.common.items.GT_MetaGenerated_Item_98; import gregtech.common.items.GT_MetaGenerated_Tool_01; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; @@ -1812,6 +1813,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 240 + 120 * i); GT_Values.RA.addChemicalRecipe(GT_ModHandler.getIC2Item("steamCell", 1L), GT_Utility.getIntegratedCircuit(i + 1), new FluidStack(uncrackedFluid, 1000), new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); + GT_Values.RA.addChemicalRecipe(GT_MetaGenerated_Item_98.FluidCell.steam.get(), GT_Utility.getIntegratedCircuit(i + 1), new FluidStack(uncrackedFluid, 1000), + new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); GT_Values.RA.addChemicalRecipe(aMaterial.getCells(1), GT_Utility.getIntegratedCircuit(i + 1), GT_ModHandler.getSteam(1000), new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); } diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_98.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_98.java index b7b73b86b4..b6123fb2d0 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_98.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_98.java @@ -1,6 +1,5 @@ package gregtech.common.items; -import com.google.common.collect.ImmutableMap; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.ItemList; @@ -9,6 +8,7 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.IIconContainer; import gregtech.api.items.GT_MetaGenerated_Item; import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -38,14 +38,62 @@ public class GT_MetaGenerated_Item_98 extends GT_MetaGenerated_Item { * re-ordered or removed! The only safe modification that can be made to this list is adding new * entries to the end. To remove an entry, pass {@code null} in for the fluid name. */ - private static final ImmutableMap<String, CellType> FLUIDS = - ImmutableMap.<String, CellType>builder() - .put("steam", CellType.REGULAR) - .put("bacterialsludge", CellType.REGULAR) - .put("mutagen", CellType.REGULAR) - .put("ender", CellType.REGULAR) - .put("endergoo", CellType.REGULAR) - .build(); + public enum FluidCell { + steam(CellType.REGULAR), + bacterialsludge(CellType.REGULAR), + mutagen(CellType.REGULAR), + ender(CellType.REGULAR), + endergoo(CellType.REGULAR), + ; + + private final CellType mType; + private ItemStack mStack; + + FluidCell(CellType aType) { + this.mType = aType; + } + + public CellType getDisplayType() { + return mType; + } + + /** + * Get a copy of this stack with stack size 1. + * + * Might return null if not yet initialized, or the fluid referenced does not exist. + */ + public ItemStack get() { + return GT_Utility.copy(mStack); + } + + /** + * Get a copy of this cell WITHOUT copy. + * + * Might return null if not yet initialized, or the fluid referenced does not exist. + * + * Use with caution. + */ + public ItemStack getNoCopy() { + return mStack; + } + + /** + * Get a copy of this cell with specified stack size. + * + * Might return null if not yet initialized, or the fluid referenced does not exist. + */ + public ItemStack get(int aStackSize) { + return GT_Utility.copyAmount(aStackSize, mStack); + } + + void setStack(ItemStack mStack) { + this.mStack = mStack; + } + + public int getId() { + return ordinal(); + } + } /** * We support adding two different types of cells. @@ -88,23 +136,23 @@ public class GT_MetaGenerated_Item_98 extends GT_MetaGenerated_Item { */ private final Map<Integer, RegisteredFluidData> registeredFluidDataMap; - public GT_MetaGenerated_Item_98() { + public static synchronized void init() { + if (INSTANCE == null) + INSTANCE = new GT_MetaGenerated_Item_98(); + } + + private GT_MetaGenerated_Item_98() { // For some reason, fluid cells will be rendered only if the metadata ID is less than the // offset. So we will specify maximum offset here. // See: GT_MetaGenerated_Item_Renderer.java - super("metaitem.98", (short) 32766, (short) FLUIDS.size()); + super("metaitem.98", (short) 32766, (short) FluidCell.values().length); - INSTANCE = this; registeredFluidDataMap = new HashMap<>(); - int i = -1; - for (Map.Entry<String, CellType> entry : FLUIDS.entrySet()) { - i++; // Increment first so that we don't accidentally skip doing so with continue - String fluidName = entry.getKey(); - CellType cellType = entry.getValue(); - if (fluidName == null) { - continue; - } + for (FluidCell tCell : FluidCell.values()) { + int i = tCell.getId(); // Increment first so that we don't accidentally skip doing so with continue + String fluidName = tCell.name(); + CellType cellType = tCell.getDisplayType(); Fluid fluid = FluidRegistry.getFluid(fluidName); if (fluid == null) { @@ -120,6 +168,8 @@ public class GT_MetaGenerated_Item_98 extends GT_MetaGenerated_Item { new FluidContainerRegistry.FluidContainerData( fluidStack, itemStack, ItemList.Cell_Empty.get(1L))); + tCell.setStack(itemStack); + GT_LanguageManager.addStringLocalization( getUnlocalizedName(itemStack) + ".name", cellType.prefix.mLocalizedMaterialPre + fluid.getLocalizedName(fluidStack) + cellType.prefix.mLocalizedMaterialPost); |