aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kekztech
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kekztech')
-rw-r--r--src/main/java/kekztech/GuiHandler.java55
-rw-r--r--src/main/java/kekztech/Items.java166
-rw-r--r--src/main/java/kekztech/KekzCore.java80
-rw-r--r--src/main/java/kekztech/MultiFluidHandler.java800
-rw-r--r--src/main/java/kekztech/ServerProxy.java4
5 files changed, 539 insertions, 566 deletions
diff --git a/src/main/java/kekztech/GuiHandler.java b/src/main/java/kekztech/GuiHandler.java
index 97d4350b71..56c7a8b102 100644
--- a/src/main/java/kekztech/GuiHandler.java
+++ b/src/main/java/kekztech/GuiHandler.java
@@ -10,32 +10,35 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class GuiHandler implements IGuiHandler {
-
- public static final int ITEM_PROXY_SOURCE = 0;
- public static final int ITEM_PROXY_ENDPOINT = 1;
-
- @Override
- public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
- final TileEntity te = world.getTileEntity(x, y, z);
- if(te != null) {
- switch(ID) {
- case ITEM_PROXY_SOURCE: return new Container_ItemProxySource(te, player);
- case ITEM_PROXY_ENDPOINT: return new Container_ItemProxyEndpoint(te, player);
- }
- }
- return null;
- }
- @Override
- public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
- final TileEntity te = world.getTileEntity(x, y, z);
- if(te != null) {
- switch(ID) {
- case ITEM_PROXY_SOURCE: return new Gui_ItemProxySource(te, player);
- case ITEM_PROXY_ENDPOINT: return new Gui_ItemProxyEndpoint(te, player);
- }
- }
- return null;
- }
+ public static final int ITEM_PROXY_SOURCE = 0;
+ public static final int ITEM_PROXY_ENDPOINT = 1;
+ @Override
+ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
+ final TileEntity te = world.getTileEntity(x, y, z);
+ if (te != null) {
+ switch (ID) {
+ case ITEM_PROXY_SOURCE:
+ return new Container_ItemProxySource(te, player);
+ case ITEM_PROXY_ENDPOINT:
+ return new Container_ItemProxyEndpoint(te, player);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
+ final TileEntity te = world.getTileEntity(x, y, z);
+ if (te != null) {
+ switch (ID) {
+ case ITEM_PROXY_SOURCE:
+ return new Gui_ItemProxySource(te, player);
+ case ITEM_PROXY_ENDPOINT:
+ return new Gui_ItemProxyEndpoint(te, player);
+ }
+ }
+ return null;
+ }
}
diff --git a/src/main/java/kekztech/Items.java b/src/main/java/kekztech/Items.java
index 50e56ced00..2444eb2fe9 100644
--- a/src/main/java/kekztech/Items.java
+++ b/src/main/java/kekztech/Items.java
@@ -2,94 +2,100 @@ package kekztech;
import common.items.MetaItem_CraftingComponent;
import common.items.MetaItem_ReactorComponent;
+import java.util.Arrays;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import util.Util;
-import java.util.Arrays;
-
public enum Items {
- /*
- // Heat Vents
- T1HeatVent(0,0), T2HeatVent(1,0), T3HeatVent(2,0), T4HeatVent(3,0),
- T1ComponentHeatVent(4,0), T2ComponentHeatVent(5,0), T3ComponentHeatVent(6,0), T4ComponentHeatVent(7,0),
- T1OverclockedHeatVent(8,0), T2OverclockedHeatVent(9,0), T3OverclockedHeatVent(10,0), T4OverclockedHeatVent(11,0),
- // Heat Exchanger
- T1HeatExchanger(12,0), T2HeatExchanger(13,0), T3HeatExchanger(14,0), T4HeatExchanger(15,0),
- // Fuel Rods
- UraniumFuelRod(16,0), UraniumDualFuelRod(17,0), UraniumQuadFuelRod(18,0),
- ThoriumFuelRod(19,0), ThoriumDualFuelRod(20,0), ThoriumQuadFuelRod(21,0),
- MOXFuelRod(22,0), MOXDualFuelRod(23,0), MOXQuadFuelRod(24,0),
- NaquadahFuelRod(25,0), NaquadahDualFuelRod(26,0), NaquadahQuadFuelRod(27,0),
- Th_MOXFuelRod(28,0), Th_MOXDualFuelRod(29,0), Th_MOXQuadFuelRod(30,0),
- // Depleted Fuel Rods
- DepletedUraniumFuelRod(31,0), DepletedUraniumDualFuelRod(32,0), DepletedUraniumQuadFuelRod(33,0),
- DepletedThoriumFuelRod(34,0), DepletedThoriumDualFuelRod(35,0), DepletedThoriumQuadFuelRod(36,0),
- DepletedMOXFuelRod(37,0), DepletedMOXDualFuelRod(38,0), DepletedMOXQuadFuelRod(39,0),
- DepletedNaquadahFuelRod(40,0), DepletedNaquadahDualFuelRod(41,0), DepletedNaquadahQuadFuelRod(42,0),
- Th_DepletedMOXFuelRod(43,0), Th_DepletedMOXDualFuelRod(44,0), Th_DepletedMOXQuadFuelRod(45,0),
- // Neutron Reflectors
- T1NeutronReflector(46,0), T2NeutronReflector(47,0),
- // Coolant Cells
- HeliumCoolantCell360k(48,0), NaKCoolantCell360k(49,0),
-
- // Heat Pipes
- CopperHeatPipe(0,1), SilverHeatPipe(1,1), BoronArsenideHeatPipe(2,1), DiamondHeatPipe(3,1),
- BoronArsenideDust(4,1), IsotopicallyPureDiamondDust(5,1), AmineCarbamiteDust(6,1),
- BoronArsenideCrystal(7,1), IsotopicallyPureDiamondCrystal(8,1),
- */
- // Ceramics
- YSZCeramicDust(9,1), GDCCeramicDust(10,1),
- YttriaDust(11,1), ZirconiaDust(12,1), CeriaDust(13,1),
- YSZCeramicPlate(14,1), GDCCeramicPlate(15,1),
- // Error Item
- Error(0,1),
- // Configurator
- Configurator(0, 1);
-
- static {
- YttriaDust.setOreDictName("dustYttriumOxide");
- ZirconiaDust.setOreDictName("dustCubicZirconia");
- }
-
- private final int metaID;
- private final int identifier;
-
- Items(int metaID, int identifier) {
- this.metaID = metaID;
- this.identifier = identifier;
- }
-
- public int getMetaID() {
- return metaID;
- }
-
- String OreDictName;
+ /*
+ // Heat Vents
+ T1HeatVent(0,0), T2HeatVent(1,0), T3HeatVent(2,0), T4HeatVent(3,0),
+ T1ComponentHeatVent(4,0), T2ComponentHeatVent(5,0), T3ComponentHeatVent(6,0), T4ComponentHeatVent(7,0),
+ T1OverclockedHeatVent(8,0), T2OverclockedHeatVent(9,0), T3OverclockedHeatVent(10,0), T4OverclockedHeatVent(11,0),
+ // Heat Exchanger
+ T1HeatExchanger(12,0), T2HeatExchanger(13,0), T3HeatExchanger(14,0), T4HeatExchanger(15,0),
+ // Fuel Rods
+ UraniumFuelRod(16,0), UraniumDualFuelRod(17,0), UraniumQuadFuelRod(18,0),
+ ThoriumFuelRod(19,0), ThoriumDualFuelRod(20,0), ThoriumQuadFuelRod(21,0),
+ MOXFuelRod(22,0), MOXDualFuelRod(23,0), MOXQuadFuelRod(24,0),
+ NaquadahFuelRod(25,0), NaquadahDualFuelRod(26,0), NaquadahQuadFuelRod(27,0),
+ Th_MOXFuelRod(28,0), Th_MOXDualFuelRod(29,0), Th_MOXQuadFuelRod(30,0),
+ // Depleted Fuel Rods
+ DepletedUraniumFuelRod(31,0), DepletedUraniumDualFuelRod(32,0), DepletedUraniumQuadFuelRod(33,0),
+ DepletedThoriumFuelRod(34,0), DepletedThoriumDualFuelRod(35,0), DepletedThoriumQuadFuelRod(36,0),
+ DepletedMOXFuelRod(37,0), DepletedMOXDualFuelRod(38,0), DepletedMOXQuadFuelRod(39,0),
+ DepletedNaquadahFuelRod(40,0), DepletedNaquadahDualFuelRod(41,0), DepletedNaquadahQuadFuelRod(42,0),
+ Th_DepletedMOXFuelRod(43,0), Th_DepletedMOXDualFuelRod(44,0), Th_DepletedMOXQuadFuelRod(45,0),
+ // Neutron Reflectors
+ T1NeutronReflector(46,0), T2NeutronReflector(47,0),
+ // Coolant Cells
+ HeliumCoolantCell360k(48,0), NaKCoolantCell360k(49,0),
+
+ // Heat Pipes
+ CopperHeatPipe(0,1), SilverHeatPipe(1,1), BoronArsenideHeatPipe(2,1), DiamondHeatPipe(3,1),
+ BoronArsenideDust(4,1), IsotopicallyPureDiamondDust(5,1), AmineCarbamiteDust(6,1),
+ BoronArsenideCrystal(7,1), IsotopicallyPureDiamondCrystal(8,1),
+ */
+ // Ceramics
+ YSZCeramicDust(9, 1),
+ GDCCeramicDust(10, 1),
+ YttriaDust(11, 1),
+ ZirconiaDust(12, 1),
+ CeriaDust(13, 1),
+ YSZCeramicPlate(14, 1),
+ GDCCeramicPlate(15, 1),
+ // Error Item
+ Error(0, 1),
+ // Configurator
+ Configurator(0, 1);
+
+ static {
+ YttriaDust.setOreDictName("dustYttriumOxide");
+ ZirconiaDust.setOreDictName("dustCubicZirconia");
+ }
+
+ private final int metaID;
+ private final int identifier;
+
+ Items(int metaID, int identifier) {
+ this.metaID = metaID;
+ this.identifier = identifier;
+ }
+
+ public int getMetaID() {
+ return metaID;
+ }
+
+ String OreDictName;
+
+ private void registerOreDict() {
+ OreDictionary.registerOre(getOreDictName(), getNonOreDictedItemStack(1));
+ }
- private void registerOreDict(){
- OreDictionary.registerOre(getOreDictName(),getNonOreDictedItemStack(1));
- }
+ public static void registerOreDictNames() {
+ Arrays.stream(Items.values()).filter(e -> e.getOreDictName() != null).forEach(Items::registerOreDict);
+ }
- public static void registerOreDictNames(){
- Arrays.stream(Items.values()).filter(e -> e.getOreDictName() != null).forEach(Items::registerOreDict);
- }
+ public ItemStack getNonOreDictedItemStack(int amount) {
+ return identifier == 0
+ ? new ItemStack(MetaItem_ReactorComponent.getInstance(), amount, this.getMetaID())
+ : new ItemStack(MetaItem_CraftingComponent.getInstance(), amount, this.getMetaID());
+ }
- public ItemStack getNonOreDictedItemStack(int amount){
- return identifier == 0 ? new ItemStack(MetaItem_ReactorComponent.getInstance(),amount,this.getMetaID()) :
- new ItemStack(MetaItem_CraftingComponent.getInstance(),amount,this.getMetaID());
- }
+ public ItemStack getOreDictedItemStack(int amount) {
+ return this.getOreDictName() != null
+ ? Util.getStackofAmountFromOreDict(this.getOreDictName(), amount)
+ : identifier == 0
+ ? new ItemStack(MetaItem_ReactorComponent.getInstance(), amount, this.getMetaID())
+ : new ItemStack(MetaItem_CraftingComponent.getInstance(), amount, this.getMetaID());
+ }
- public ItemStack getOreDictedItemStack(int amount){
- return this.getOreDictName() != null ? Util.getStackofAmountFromOreDict(this.getOreDictName(),amount) :
- identifier == 0 ? new ItemStack(MetaItem_ReactorComponent.getInstance(),amount,this.getMetaID()) :
- new ItemStack(MetaItem_CraftingComponent.getInstance(),amount,this.getMetaID());
- }
-
- public String getOreDictName() {
- return OreDictName;
- }
+ public String getOreDictName() {
+ return OreDictName;
+ }
- public void setOreDictName(String oreDictName) {
- OreDictName = oreDictName;
- }
+ public void setOreDictName(String oreDictName) {
+ OreDictName = oreDictName;
+ }
}
diff --git a/src/main/java/kekztech/KekzCore.java b/src/main/java/kekztech/KekzCore.java
index f0d77ce5fa..ba1869ef08 100644
--- a/src/main/java/kekztech/KekzCore.java
+++ b/src/main/java/kekztech/KekzCore.java
@@ -1,68 +1,58 @@
package kekztech;
-import client.renderer.TESR_SECapacitor;
-import client.renderer.TESR_SETether;
-import common.Blocks;
import common.CommonProxy;
-import common.Recipes;
-import common.Researches;
import common.tileentities.*;
-import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
-import cpw.mods.fml.common.network.NetworkRegistry;
-import cpw.mods.fml.common.registry.GameRegistry;
-import common.items.ErrorItem;
-import common.items.MetaItem_CraftingComponent;
-import common.items.MetaItem_ReactorComponent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* My GT-Meta-IDs are: 13101 - 13500
- *
+ *
* @author kekzdealer
*
*/
-@Mod(modid = KekzCore.MODID, name = KekzCore.NAME, version = KekzCore.VERSION,
- dependencies =
- "required-after:IC2;"
- + "required-after:gregtech;"
- + "required-after:tectech;"
- + "required-after:Thaumcraft;"
- + "required-after:ThaumicTinkerer;"
- + "after:bartworks;"
- + "after:dreamcraft"
- )
+@Mod(
+ modid = KekzCore.MODID,
+ name = KekzCore.NAME,
+ version = KekzCore.VERSION,
+ dependencies = "required-after:IC2;"
+ + "required-after:gregtech;"
+ + "required-after:tectech;"
+ + "required-after:Thaumcraft;"
+ + "required-after:ThaumicTinkerer;"
+ + "after:bartworks;"
+ + "after:dreamcraft")
public class KekzCore {
-
- public static final String NAME = "KekzTech";
- public static final String MODID = "kekztech";
- public static final String VERSION = "GRADLETOKEN_VERSION";
- public static final Logger LOGGER = LogManager.getLogger(NAME);
+ public static final String NAME = "KekzTech";
+ public static final String MODID = "kekztech";
+ public static final String VERSION = "GRADLETOKEN_VERSION";
+
+ public static final Logger LOGGER = LogManager.getLogger(NAME);
+
+ @Mod.Instance("kekztech")
+ public static KekzCore instance;
+
+ @SidedProxy(clientSide = "client.ClientProxy", serverSide = "kekztech.ServerProxy")
+ public static CommonProxy proxy;
- @Mod.Instance("kekztech")
- public static KekzCore instance;
+ @Mod.EventHandler
+ public void preInit(FMLPreInitializationEvent event) {
+ proxy.preInit(event);
+ }
- @SidedProxy(clientSide = "client.ClientProxy", serverSide = "kekztech.ServerProxy")
- public static CommonProxy proxy;
+ @Mod.EventHandler
+ public void init(FMLInitializationEvent event) {
+ proxy.init(event);
+ }
- @Mod.EventHandler
- public void preInit(FMLPreInitializationEvent event) {
- proxy.preInit(event);
- }
-
- @Mod.EventHandler
- public void init(FMLInitializationEvent event) {
- proxy.init(event);
- }
-
- @Mod.EventHandler
- public void postInit(FMLPostInitializationEvent event) {
- proxy.postInit(event);
- }
+ @Mod.EventHandler
+ public void postInit(FMLPostInitializationEvent event) {
+ proxy.postInit(event);
+ }
}
diff --git a/src/main/java/kekztech/MultiFluidHandler.java b/src/main/java/kekztech/MultiFluidHandler.java
index 399f9faa8b..232931b6fc 100644
--- a/src/main/java/kekztech/MultiFluidHandler.java
+++ b/src/main/java/kekztech/MultiFluidHandler.java
@@ -1,421 +1,397 @@
package kekztech;
+import java.util.ArrayList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fluids.FluidStack;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
public class MultiFluidHandler {
- private final FluidStack[] fluids;
- private final int maxDistinctFluids;
- private final int capacityPerFluid;
-
- private boolean locked = true;
- private boolean doVoidExcess = false;
- private byte fluidSelector = -1;
-
- public MultiFluidHandler(int maxDistinctFluids, int capacityPerFluid, FluidStack[] fluidsToAdd) {
- this.maxDistinctFluids = maxDistinctFluids;
- this.fluids = new FluidStack[maxDistinctFluids];
- if(fluidsToAdd != null) {
- int tFluidLengt = (maxDistinctFluids <fluidsToAdd.length) ? maxDistinctFluids:fluidsToAdd.length;
- for (int i = 0; i < tFluidLengt; i++) {
- this.fluids[i] = fluidsToAdd[i];
- }
- }
- this.capacityPerFluid = capacityPerFluid;
- }
-
- /**
- * Initialize a new MultiFluidHandler object with the given parameters
- * @param maxDistinctFluids
- * How many different fluids can be stored
- * @param capacityPerFluid
- * How much capacity each fluid should have
- * @param fluidsToAdd
- * Fluids to add immediately
- * @return
- * A new instance
- */
- public static MultiFluidHandler newInstance(int maxDistinctFluids, int capacityPerFluid, FluidStack...fluidsToAdd) {
- return new MultiFluidHandler(maxDistinctFluids, capacityPerFluid, fluidsToAdd);
- }
-
- /**
- * Deep copy a MultiFluidHandler instance with a new capacity
- * @param toCopy
- * The MultiFluidHandler that should be copied
- * @param capacityPerFluid
- * How much capacity each fluid should have
- * @return
- * A new instance
- */
- public static MultiFluidHandler newAdjustedInstance(MultiFluidHandler toCopy, int capacityPerFluid) {
- return new MultiFluidHandler(toCopy.maxDistinctFluids, capacityPerFluid, toCopy.fluids);
- }
-
- /**
- * Lock internal tanks in case T.F.F.T is not running.
- *
- * @param state
- * Lock state.
- */
- public void setLock(boolean state) {
- locked = state;
- }
-
- public void setDoVoidExcess(boolean doVoidExcess) { this.doVoidExcess = doVoidExcess; }
-
- /**
- * Used to tell the MFH if a fluid is selected by
- * an Integrated Circuit in the controller.
- * If the Integrate Circuit configuration exceeds
- * the number of stored fluid, the configuration will be ignored.
- *
- * @param fluidSelector
- * Selected fluid or -1 if no fluid is selected
- */
- public void setFluidSelector(byte fluidSelector) {
- this.fluidSelector = fluidSelector < fluids.length ? fluidSelector : -1;
- }
-
- /**
- *
- * @return
- * Selected fluid or -1 if no fluid is selected
- */
- public byte getSelectedFluid() {
- return fluidSelector;
- }
-
- public FluidStack[] getAllFluids() {
- return fluids;
- }
-
- public int getFluidPosistion(FluidStack aFluid) {
-
- for (int i = 0; i < fluids.length; i++)
- {
- FluidStack tFluid = fluids[i];
- if (tFluid != null && tFluid.isFluidEqual(aFluid))
- return i;
- }
- return -1;
- }
-
- public boolean contains(FluidStack aFluid) {
- if (locked)
- return false;
- return getFluidPosistion(aFluid)>=0;
- }
-
- public int countFluids()
- {
- int tCount = 0;
- for (int i = 0; i < fluids.length; i++) {
- if (fluids[i] != null)
- tCount++;
- }
- return tCount;
- }
-
-
- public int getCapacity() {
- return capacityPerFluid;
- }
- public int getMaxDistinctFluids() {
- return maxDistinctFluids;
- }
-
- /**
- * Returns a deep copy of the the FluidStack in the requested slot
- * @param slot
- * requested slot
- * @return
- * deep copy of the requested FluidStack
- */
- public FluidStack getFluidCopy(int slot) {
- if (slot >= fluids.length)
- return null;
- if (!locked
- && fluids.length > 0
- && slot >= 0
- && slot < maxDistinctFluids)
- {
- FluidStack tFluid = fluids[slot];
- if (tFluid != null)
- return tFluid.copy();
- }
- return null;
- }
-
- /**
- * Returns the amount of different fluids currently stored.
- * @return
- * amount of different fluids currently stored (0-25)
- */
- public int getDistinctFluids() {
- int distinctFluids = 0;
- for (FluidStack f : fluids) {
- if (f != null)
- distinctFluids++;
- }
- return distinctFluids;
- }
-
- /**
- * Helper method to save a MultiFluidHandler to NBT data
- * @param nbt
- * The NBT Tag to write to
- * @return
- * Updated NBT Tag
- */
- public NBTTagCompound saveNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- nbt.setInteger("capacityPerFluid", getCapacity());
- nbt.setInteger("maxDistinctFluids",this.maxDistinctFluids);
- int c = 0;
- for(FluidStack f : fluids) {
- if (f == null)
- {
- c++;
- continue;
- }
- nbt.setTag( String.valueOf(c), f.writeToNBT(new NBTTagCompound()));
- c++;
- }
- return nbt;
- }
-
- /**
- * Helper method to initialize a MultiFluidHandler from NBT data
- * @param nbt
- * The NBT Tag to read from
- * @return
- * A new Instance
- */
- static public MultiFluidHandler loadNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- final int capacityPerFluid = nbt.getInteger("capacityPerFluid");
- final NBTTagCompound fluidsTag = (NBTTagCompound) nbt.getTag("fluids");
- int distinctFluids = nbt.getInteger("maxDistinctFluids");
- if (!nbt.hasKey("maxDistinctFluids"))
- distinctFluids = 25;// adding it so it doesent break on upgrading
- final FluidStack[] loadedFluids = new FluidStack[distinctFluids];
-
- if (fluidsTag != null)
- {
- for (int i = 0; i < distinctFluids; i++) {
- final NBTTagCompound fluidNBT = (NBTTagCompound) fluidsTag.getTag("" + i);
- if(fluidNBT == null) {
- loadedFluids[i] = null;
- } else {
- loadedFluids[i] = FluidStack.loadFluidStackFromNBT(fluidNBT);
- }
- }
- }
- return new MultiFluidHandler(distinctFluids, capacityPerFluid, loadedFluids);
- }
-
- public ArrayList<String> getInfoData() {
- final ArrayList<String> lines = new ArrayList<>(fluids.length);
- lines.add(EnumChatFormatting.YELLOW + "Stored Fluids:" + EnumChatFormatting.RESET);
- for(int i = 0; i < fluids.length; i++) {
- FluidStack tFluid = fluids[i];
- if (tFluid == null) {
- lines.add(i + " - " + "null" + ": "
- + "0" + "L ("
- + "0" + "%)");
- } else {
- lines.add(i + " - " + tFluid.getLocalizedName() + ": "
- + tFluid.amount + "L ("
- + (Math.round(100.0f * tFluid.amount / getCapacity())) + "%)");
- }
- }
-
- return lines;
- }
-
- /**
- * Fill fluid into a tank.
- *
- * @param push
- * Fluid type and quantity to be inserted.
- * @param doPush
- * If false, fill will only be simulated.
- * @return Amount of fluid that was (or would have been, if simulated) filled.
- */
- public int pushFluid(FluidStack push, boolean doPush) {
- if(locked) {
- return 0;
- }
- int empty = getNullSlot();
- int fluidCount = countFluids();
- if(fluidCount >= maxDistinctFluids && !contains(push)) {
- // Already contains 25 fluids and this isn't one of them
- return 0;
- } else if (empty < maxDistinctFluids && !contains(push)) {
- // Add new fluid
- final int fit = Math.min(getCapacity(), push.amount);
- if(doPush) {
- if (empty == -1)
- return 0;
- else
- fluids[empty] = new FluidStack(push.getFluid(), fit);
- }
- // If doVoidExcess, pretend all of it fit
- return doVoidExcess ? push.amount : fit;
- } else {
- // Add to existing fluids
- int index = getFluidPosistion(push);
- if (index < 0)
- return 0;
- final FluidStack existing = fluids[index];
- final int fit = Math.min(getCapacity() - existing.amount, push.amount);
- if(doPush) {
- existing.amount += fit;
- }
- // If doVoidExcess, pretend all of it fit
- return doVoidExcess ? push.amount : fit;
- }
- }
-
-
- public int getNullSlot()
- {
- for (int i = 0; i < fluids.length; i++) {
- if (fluids[i] == null)
- return i;
- }
- return -1;
- }
-
- /**
- * Fill fluid into the specified tank.
- *
- * @param push
- * Fluid type and quantity to be inserted.
- * @param slot
- * Tank the fluid should go into.
- * @param doPush
- * If false, fill will only be simulated.
- * @return Amount of fluid that was (or would have been, if simulated) filled.
- */
- public int pushFluid(FluidStack push, int slot, boolean doPush) {
- if(locked) {
- return 0;
- }
- FluidStack tFluid = fluids[slot];
- if(slot < 0 || slot >= maxDistinctFluids) {
- // Invalid slot
- return 0;
- }
- if((tFluid != null) && !tFluid.equals(push)) {
- // Selected slot is taken by a non-matching fluid
- return 0;
- } else {
- int fit = 0;
- // Add to existing fluid
- if (tFluid == null) {
- fit = Math.min(getCapacity(),push.amount);
- fluids[slot] = new FluidStack(push.getFluid(), fit);
- } else {
- fit = Math.min(getCapacity() - tFluid.amount, push.amount);
- if(doPush) {
- tFluid.amount += fit;
- }
- }
- // If doVoidExcess, pretend all of it fit
- return doVoidExcess ? push.amount : fit;
- }
- }
-
- /**
- * Drains fluid out of the internal tanks.
- *
- * @param pull
- * Fluid type and quantity to be pulled.
- * @param doPull
- * If false, drain will only be simulated.
- * @return Amount of fluid that was (or would have been, if simulated) pulled.
- */
- public int pullFluid(FluidStack pull, boolean doPull) {
- if (locked) {
- return 0;
- } else {
- int tIndex = getFluidPosistion(pull);
- if (tIndex < 0)
- return 0;
- FluidStack src = fluids[tIndex];
- final int rec = Math.min(pull.amount, src.amount);
- if (doPull) {
- src.amount -= rec;
- }
- if (src.amount == 0) {
- fluids[tIndex]= null;
- }
- return rec;
- }
- }
-
- /**
- * Drains fluid out of the specified internal tank.
- *
- * @param pull
- * Fluid type and quantity to be pulled.
- * @param slot
- * Tank fluid should be drained from.
- * @param doPull
- * If false, drain will only be simulated.
- * @return Amount of fluid that was (or would have been, if simulated) pulled.
- */
- public int pullFluid(FluidStack pull, int slot, boolean doPull) {
- if(locked || slot >= fluids.length) {
- return 0;
- }
- if(slot < 0 || slot >= maxDistinctFluids) {
- return 0;
- }
- FluidStack tFluid = fluids[slot];
- if(tFluid == null || !tFluid.equals(pull)) {
- return 0;
- } else {
- final int rec = Math.min(pull.amount, tFluid.amount);
- if(doPull) {
- tFluid.amount -= rec;
- }
- if(tFluid.amount == 0) {
- fluids[slot] = null;
- }
- return rec;
- }
- }
-
- /**
- * Test whether the given fluid type and quantity can be inserted into the internal tanks.
- * @param push
- * Fluid type and quantity to be tested
- * @return True if there is sufficient space
- */
- public boolean couldPush(FluidStack push) {
- if(locked) {
- return false;
- }
- int tFluidIndex = getFluidPosistion(push);
- int fluidCount = countFluids();
- if(fluidCount >= maxDistinctFluids && !contains(push)) {
- return false;
- } else if (fluidCount < maxDistinctFluids && !contains(push)) {
- return Math.min(getCapacity(), push.amount) > 0;
- } else {
- final int remcap = getCapacity() - fluids[tFluidIndex].amount;
- return doVoidExcess || (Math.min(remcap, push.amount) > 0);
- }
- }
+ private final FluidStack[] fluids;
+ private final int maxDistinctFluids;
+ private final int capacityPerFluid;
+
+ private boolean locked = true;
+ private boolean doVoidExcess = false;
+ private byte fluidSelector = -1;
+
+ public MultiFluidHandler(int maxDistinctFluids, int capacityPerFluid, FluidStack[] fluidsToAdd) {
+ this.maxDistinctFluids = maxDistinctFluids;
+ this.fluids = new FluidStack[maxDistinctFluids];
+ if (fluidsToAdd != null) {
+ int tFluidLengt = (maxDistinctFluids < fluidsToAdd.length) ? maxDistinctFluids : fluidsToAdd.length;
+ for (int i = 0; i < tFluidLengt; i++) {
+ this.fluids[i] = fluidsToAdd[i];
+ }
+ }
+ this.capacityPerFluid = capacityPerFluid;
+ }
+
+ /**
+ * Initialize a new MultiFluidHandler object with the given parameters
+ * @param maxDistinctFluids
+ * How many different fluids can be stored
+ * @param capacityPerFluid
+ * How much capacity each fluid should have
+ * @param fluidsToAdd
+ * Fluids to add immediately
+ * @return
+ * A new instance
+ */
+ public static MultiFluidHandler newInstance(
+ int maxDistinctFluids, int capacityPerFluid, FluidStack... fluidsToAdd) {
+ return new MultiFluidHandler(maxDistinctFluids, capacityPerFluid, fluidsToAdd);
+ }
+
+ /**
+ * Deep copy a MultiFluidHandler instance with a new capacity
+ * @param toCopy
+ * The MultiFluidHandler that should be copied
+ * @param capacityPerFluid
+ * How much capacity each fluid should have
+ * @return
+ * A new instance
+ */
+ public static MultiFluidHandler newAdjustedInstance(MultiFluidHandler toCopy, int capacityPerFluid) {
+ return new MultiFluidHandler(toCopy.maxDistinctFluids, capacityPerFluid, toCopy.fluids);
+ }
+
+ /**
+ * Lock internal tanks in case T.F.F.T is not running.
+ *
+ * @param state
+ * Lock state.
+ */
+ public void setLock(boolean state) {
+ locked = state;
+ }
+
+ public void setDoVoidExcess(boolean doVoidExcess) {
+ this.doVoidExcess = doVoidExcess;
+ }
+
+ /**
+ * Used to tell the MFH if a fluid is selected by
+ * an Integrated Circuit in the controller.
+ * If the Integrate Circuit configuration exceeds
+ * the number of stored fluid, the configuration will be ignored.
+ *
+ * @param fluidSelector
+ * Selected fluid or -1 if no fluid is selected
+ */
+ public void setFluidSelector(byte fluidSelector) {
+ this.fluidSelector = fluidSelector < fluids.length ? fluidSelector : -1;
+ }
+
+ /**
+ *
+ * @return
+ * Selected fluid or -1 if no fluid is selected
+ */
+ public byte getSelectedFluid() {
+ return fluidSelector;
+ }
+
+ public FluidStack[] getAllFluids() {
+ return fluids;
+ }
+
+ public int getFluidPosistion(FluidStack aFluid) {
+
+ for (int i = 0; i < fluids.length; i++) {
+ FluidStack tFluid = fluids[i];
+ if (tFluid != null && tFluid.isFluidEqual(aFluid)) return i;
+ }
+ return -1;
+ }
+
+ public boolean contains(FluidStack aFluid) {
+ if (locked) return false;
+ return getFluidPosistion(aFluid) >= 0;
+ }
+
+ public int countFluids() {
+ int tCount = 0;
+ for (int i = 0; i < fluids.length; i++) {
+ if (fluids[i] != null) tCount++;
+ }
+ return tCount;
+ }
+
+ public int getCapacity() {
+ return capacityPerFluid;
+ }
+
+ public int getMaxDistinctFluids() {
+ return maxDistinctFluids;
+ }
+
+ /**
+ * Returns a deep copy of the the FluidStack in the requested slot
+ * @param slot
+ * requested slot
+ * @return
+ * deep copy of the requested FluidStack
+ */
+ public FluidStack getFluidCopy(int slot) {
+ if (slot >= fluids.length) return null;
+ if (!locked && fluids.length > 0 && slot >= 0 && slot < maxDistinctFluids) {
+ FluidStack tFluid = fluids[slot];
+ if (tFluid != null) return tFluid.copy();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the amount of different fluids currently stored.
+ * @return
+ * amount of different fluids currently stored (0-25)
+ */
+ public int getDistinctFluids() {
+ int distinctFluids = 0;
+ for (FluidStack f : fluids) {
+ if (f != null) distinctFluids++;
+ }
+ return distinctFluids;
+ }
+
+ /**
+ * Helper method to save a MultiFluidHandler to NBT data
+ * @param nbt
+ * The NBT Tag to write to
+ * @return
+ * Updated NBT Tag
+ */
+ public NBTTagCompound saveNBTData(NBTTagCompound nbt) {
+ nbt = (nbt == null) ? new NBTTagCompound() : nbt;
+
+ nbt.setInteger("capacityPerFluid", getCapacity());
+ nbt.setInteger("maxDistinctFluids", this.maxDistinctFluids);
+ int c = 0;
+ for (FluidStack f : fluids) {
+ if (f == null) {
+ c++;
+ continue;
+ }
+ nbt.setTag(String.valueOf(c), f.writeToNBT(new NBTTagCompound()));
+ c++;
+ }
+ return nbt;
+ }
+
+ /**
+ * Helper method to initialize a MultiFluidHandler from NBT data
+ * @param nbt
+ * The NBT Tag to read from
+ * @return
+ * A new Instance
+ */
+ public static MultiFluidHandler loadNBTData(NBTTagCompound nbt) {
+ nbt = (nbt == null) ? new NBTTagCompound() : nbt;
+
+ final int capacityPerFluid = nbt.getInteger("capacityPerFluid");
+ final NBTTagCompound fluidsTag = (NBTTagCompound) nbt.getTag("fluids");
+ int distinctFluids = nbt.getInteger("maxDistinctFluids");
+ if (!nbt.hasKey("maxDistinctFluids")) distinctFluids = 25; // adding it so it doesent break on upgrading
+ final FluidStack[] loadedFluids = new FluidStack[distinctFluids];
+
+ if (fluidsTag != null) {
+ for (int i = 0; i < distinctFluids; i++) {
+ final NBTTagCompound fluidNBT = (NBTTagCompound) fluidsTag.getTag("" + i);
+ if (fluidNBT == null) {
+ loadedFluids[i] = null;
+ } else {
+ loadedFluids[i] = FluidStack.loadFluidStackFromNBT(fluidNBT);
+ }
+ }
+ }
+ return new MultiFluidHandler(distinctFluids, capacityPerFluid, loadedFluids);
+ }
+
+ public ArrayList<String> getInfoData() {
+ final ArrayList<String> lines = new ArrayList<>(fluids.length);
+ lines.add(EnumChatFormatting.YELLOW + "Stored Fluids:" + EnumChatFormatting.RESET);
+ for (int i = 0; i < fluids.length; i++) {
+ FluidStack tFluid = fluids[i];
+ if (tFluid == null) {
+ lines.add(i + " - " + "null" + ": " + "0" + "L (" + "0" + "%)");
+ } else {
+ lines.add(i + " - " + tFluid.getLocalizedName() + ": "
+ + tFluid.amount + "L ("
+ + (Math.round(100.0f * tFluid.amount / getCapacity())) + "%)");
+ }
+ }
+
+ return lines;
+ }
+
+ /**
+ * Fill fluid into a tank.
+ *
+ * @param push
+ * Fluid type and quantity to be inserted.
+ * @param doPush
+ * If false, fill will only be simulated.
+ * @return Amount of fluid that was (or would have been, if simulated) filled.
+ */
+ public int pushFluid(FluidStack push, boolean doPush) {
+ if (locked) {
+ return 0;
+ }
+ int empty = getNullSlot();
+ int fluidCount = countFluids();
+ if (fluidCount >= maxDistinctFluids && !contains(push)) {
+ // Already contains 25 fluids and this isn't one of them
+ return 0;
+ } else if (empty < maxDistinctFluids && !contains(push)) {
+ // Add new fluid
+ final int fit = Math.min(getCapacity(), push.amount);
+ if (doPush) {
+ if (empty == -1) return 0;
+ else fluids[empty] = new FluidStack(push.getFluid(), fit);
+ }
+ // If doVoidExcess, pretend all of it fit
+ return doVoidExcess ? push.amount : fit;
+ } else {
+ // Add to existing fluids
+ int index = getFluidPosistion(push);
+ if (index < 0) return 0;
+ final FluidStack existing = fluids[index];
+ final int fit = Math.min(getCapacity() - existing.amount, push.amount);
+ if (doPush) {
+ existing.amount += fit;
+ }
+ // If doVoidExcess, pretend all of it fit
+ return doVoidExcess ? push.amount : fit;
+ }
+ }
+
+ public int getNullSlot() {
+ for (int i = 0; i < fluids.length; i++) {
+ if (fluids[i] == null) return i;
+ }
+ return -1;
+ }
+
+ /**
+ * Fill fluid into the specified tank.
+ *
+ * @param push
+ * Fluid type and quantity to be inserted.
+ * @param slot
+ * Tank the fluid should go into.
+ * @param doPush
+ * If false, fill will only be simulated.
+ * @return Amount of fluid that was (or would have been, if simulated) filled.
+ */
+ public int pushFluid(FluidStack push, int slot, boolean doPush) {
+ if (locked) {
+ return 0;
+ }
+ FluidStack tFluid = fluids[slot];
+ if (slot < 0 || slot >= maxDistinctFluids) {
+ // Invalid slot
+ return 0;
+ }
+ if ((tFluid != null) && !tFluid.equals(push)) {
+ // Selected slot is taken by a non-matching fluid
+ return 0;
+ } else {
+ int fit = 0;
+ // Add to existing fluid
+ if (tFluid == null) {
+ fit = Math.min(getCapacity(), push.amount);
+ fluids[slot] = new FluidStack(push.getFluid(), fit);
+ } else {
+ fit = Math.min(getCapacity() - tFluid.amount, push.amount);
+ if (doPush) {
+ tFluid.amount += fit;
+ }
+ }
+ // If doVoidExcess, pretend all of it fit
+ return doVoidExcess ? push.amount : fit;
+ }
+ }
+
+ /**
+ * Drains fluid out of the internal tanks.
+ *
+ * @param pull
+ * Fluid type and quantity to be pulled.
+ * @param doPull
+ * If false, drain will only be simulated.
+ * @return Amount of fluid that was (or would have been, if simulated) pulled.
+ */
+ public int pullFluid(FluidStack pull, boolean doPull) {
+ if (locked) {
+ return 0;
+ } else {
+ int tIndex = getFluidPosistion(pull);
+ if (tIndex < 0) return 0;
+ FluidStack src = fluids[tIndex];
+ final int rec = Math.min(pull.amount, src.amount);
+ if (doPull) {
+ src.amount -= rec;
+ }
+ if (src.amount == 0) {
+ fluids[tIndex] = null;
+ }
+ return rec;
+ }
+ }
+
+ /**
+ * Drains fluid out of the specified internal tank.
+ *
+ * @param pull
+ * Fluid type and quantity to be pulled.
+ * @param slot
+ * Tank fluid should be drained from.
+ * @param doPull
+ * If false, drain will only be simulated.
+ * @return Amount of fluid that was (or would have been, if simulated) pulled.
+ */
+ public int pullFluid(FluidStack pull, int slot, boolean doPull) {
+ if (locked || slot >= fluids.length) {
+ return 0;
+ }
+ if (slot < 0 || slot >= maxDistinctFluids) {
+ return 0;
+ }
+ FluidStack tFluid = fluids[slot];
+ if (tFluid == null || !tFluid.equals(pull)) {
+ return 0;
+ } else {
+ final int rec = Math.min(pull.amount, tFluid.amount);
+ if (doPull) {
+ tFluid.amount -= rec;
+ }
+ if (tFluid.amount == 0) {
+ fluids[slot] = null;
+ }
+ return rec;
+ }
+ }
+
+ /**
+ * Test whether the given fluid type and quantity can be inserted into the internal tanks.
+ * @param push
+ * Fluid type and quantity to be tested
+ * @return True if there is sufficient space
+ */
+ public boolean couldPush(FluidStack push) {
+ if (locked) {
+ return false;
+ }
+ int tFluidIndex = getFluidPosistion(push);
+ int fluidCount = countFluids();
+ if (fluidCount >= maxDistinctFluids && !contains(push)) {
+ return false;
+ } else if (fluidCount < maxDistinctFluids && !contains(push)) {
+ return Math.min(getCapacity(), push.amount) > 0;
+ } else {
+ final int remcap = getCapacity() - fluids[tFluidIndex].amount;
+ return doVoidExcess || (Math.min(remcap, push.amount) > 0);
+ }
+ }
}
diff --git a/src/main/java/kekztech/ServerProxy.java b/src/main/java/kekztech/ServerProxy.java
index 0291cf687f..ac366a54fd 100644
--- a/src/main/java/kekztech/ServerProxy.java
+++ b/src/main/java/kekztech/ServerProxy.java
@@ -2,6 +2,4 @@ package kekztech;
import common.CommonProxy;
-public class ServerProxy extends CommonProxy {
-
-}
+public class ServerProxy extends CommonProxy {}