From 84c13e098c16f3f978cf607497c8c46c5ac3b8d9 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Mon, 11 Aug 2014 00:55:48 +0100 Subject: [PATCH] Add creative frequencies to the entangled blocks. Adds the uility of being able to generate "infinite" (Integer.MAX_VALUE) amounts of fluids or gases. --- src/main/java/mekanism/api/gas/GasTank.java | 8 ++++ .../client/gui/GuiEntangledBlock.java | 1 - .../teleportation/SharedInventoryManager.java | 41 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/main/java/mekanism/api/gas/GasTank.java b/src/main/java/mekanism/api/gas/GasTank.java index 7ab4e4f2e..1e2aeb944 100644 --- a/src/main/java/mekanism/api/gas/GasTank.java +++ b/src/main/java/mekanism/api/gas/GasTank.java @@ -163,6 +163,14 @@ public class GasTank return maxGas; } + /** + * Sets the maximum amount of gas this tank can hold + */ + public void setMaxGas(int capacity) + { + maxGas = capacity; + } + /** * Gets the GasStack held by this GasTank. * @return - GasStakc held by this tank diff --git a/src/main/java/mekanism/client/gui/GuiEntangledBlock.java b/src/main/java/mekanism/client/gui/GuiEntangledBlock.java index f56835613..e7e568bae 100644 --- a/src/main/java/mekanism/client/gui/GuiEntangledBlock.java +++ b/src/main/java/mekanism/client/gui/GuiEntangledBlock.java @@ -125,7 +125,6 @@ public class GuiEntangledBlock extends GuiMekanism String prevFreq = frequencyField != null ? frequencyField.getText() : ""; frequencyField = new GuiTextField(fontRendererObj, guiWidth + 75, guiHeight + 55, 96, 11); - frequencyField.setMaxStringLength(10); frequencyField.setText(prevFreq); } } diff --git a/src/main/java/mekanism/common/teleportation/SharedInventoryManager.java b/src/main/java/mekanism/common/teleportation/SharedInventoryManager.java index 99c7c209f..fb55388ba 100644 --- a/src/main/java/mekanism/common/teleportation/SharedInventoryManager.java +++ b/src/main/java/mekanism/common/teleportation/SharedInventoryManager.java @@ -1,6 +1,15 @@ package mekanism.common.teleportation; +import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; + +import mekanism.api.gas.GasRegistry; +import mekanism.api.gas.GasStack; + +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidRegistry.FluidRegisterEvent; +import net.minecraftforge.fluids.FluidStack; public class SharedInventoryManager { @@ -22,6 +31,38 @@ public class SharedInventoryManager inventories.put(frequency, inv); } + if(frequency.startsWith("creative.")) + { + Iterator creativeFreqs = Arrays.asList(frequency.substring(9).split("\\.")).iterator(); + while(creativeFreqs.hasNext()) + { + String type = creativeFreqs.next(); + if(type.equals("energy")) + { + inv.MAX_ENERGY = Integer.MAX_VALUE; + inv.setEnergy(Integer.MAX_VALUE); + } + else if(type.equals("fluid") && creativeFreqs.hasNext()) + { + String fluidType = creativeFreqs.next(); + if(FluidRegistry.isFluidRegistered(fluidType)) + { + inv.storedFluid.setCapacity(Integer.MAX_VALUE); + inv.storedFluid.setFluid(new FluidStack(FluidRegistry.getFluid(fluidType), Integer.MAX_VALUE)); + } + } + else if(type.equals("gas") && creativeFreqs.hasNext()) + { + String gasType = creativeFreqs.next(); + if(GasRegistry.containsGas(gasType)) + { + inv.storedGas.setMaxGas(Integer.MAX_VALUE); + inv.storedGas.setGas(new GasStack(GasRegistry.getGas(gasType), Integer.MAX_VALUE)); + } + } + } + } + return inv; } }