From 6245b6a3eaf1ce475f6624da97ab3f04dcfd35f8 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 29 Feb 2016 19:33:00 +1000 Subject: V0.9.2 Release - Removed dev features and some messy code to push a 0.9.2 snapshop codebase. --- src/Java/miscutil/MiscUtils.java | 2 +- src/Java/miscutil/core/commands/CommandMath.java | 145 ++++----- src/Java/miscutil/core/lib/Strings.java | 2 +- src/Java/miscutil/core/util/Utils.java | 47 +++ .../miscutil/core/waila/IWailaInfoProvider.java | 5 +- .../miscutil/core/waila/IWailaNBTProvider.java | 2 +- src/Java/miscutil/core/waila/WailaCompat.java | 52 ++-- .../conduit/GregTech/AbstractGtConduit.java | 73 ----- .../conduit/GregTech/AbstractGtTankConduit.java | 161 ---------- .../GregTech/AbstractGtTankConduitNetwork.java | 64 ---- .../enderio/conduit/GregTech/ConduitGtTank.java | 153 ---------- .../enderio/conduit/GregTech/GtConduit.java | 265 ----------------- .../enderio/conduit/GregTech/GtConduitNetwork.java | 310 ------------------- .../conduit/GregTech/GtConduitRenderer.java | 180 ----------- .../enderio/conduit/GregTech/GtOutput.java | 49 --- .../miscutil/enderio/conduit/GregTech/GtUtil.java | 69 ----- .../enderio/conduit/GregTech/IGtConduit.java | 12 - .../enderio/conduit/GregTech/ItemGtConduit.java | 76 ----- .../enderio/conduit/GregTech/PacketGtLevel.java | 43 --- .../miscutil/enderio/conduit/MetaConduitBase.java | 2 +- .../enderio/conduit/gas/AbstractGasConduit.java | 203 ------------- .../conduit/gas/AbstractGasTankConduit.java | 169 ----------- .../conduit/gas/AbstractGasTankConduitNetwork.java | 73 ----- .../enderio/conduit/gas/ConduitGasTank.java | 160 ---------- .../miscutil/enderio/conduit/gas/GasConduit.java | 258 ---------------- .../enderio/conduit/gas/GasConduitNetwork.java | 317 -------------------- .../enderio/conduit/gas/GasConduitRenderer.java | 176 ----------- .../miscutil/enderio/conduit/gas/GasOutput.java | 57 ---- src/Java/miscutil/enderio/conduit/gas/GasUtil.java | 79 ----- .../miscutil/enderio/conduit/gas/IGasConduit.java | 14 - .../enderio/conduit/gas/ItemGasConduit.java | 72 ----- .../enderio/conduit/gas/PacketGasLevel.java | 44 --- src/Java/miscutil/gregtech/enums/MaterialsNew.java | 44 +++ .../gregtech/gui/CONTAINER_SteamCondenser.java | 92 ++++++ .../miscutil/gregtech/gui/GUI_SteamCondenser.java | 53 ++++ .../init/machines/GregtechCobbleGenerator.java | 2 +- .../init/machines/GregtechSteamCondenser.java | 36 +++ .../implementations/GregtechMetaCondensor.java | 164 +++++++++++ .../implementations/GregtechMetaEnergyBuffer.java | 1 + .../implementations/GregtechMetaTileEntity.java | 66 ----- .../implementations/GregtechSteelBoiler.java | 290 ------------------ .../base/GregtechMetaBoilerBase.java | 328 +++++++++++++++++++++ .../base/GregtechMetaTileEntity.java | 67 +++++ .../implementations/base/GregtechSteelBoiler.java | 290 ++++++++++++++++++ .../gregtech/objects/GregMaterialStack.java | 42 --- src/Java/miscutil/mcmod.info | 2 +- 46 files changed, 1233 insertions(+), 3578 deletions(-) delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/AbstractGtConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/AbstractGtTankConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/AbstractGtTankConduitNetwork.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/ConduitGtTank.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/GtConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/GtConduitNetwork.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/GtConduitRenderer.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/GtOutput.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/GtUtil.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/IGtConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/ItemGtConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/GregTech/PacketGtLevel.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/AbstractGasConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduitNetwork.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/ConduitGasTank.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/GasConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/GasConduitRenderer.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/GasOutput.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/GasUtil.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/IGasConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/ItemGasConduit.java delete mode 100644 src/Java/miscutil/enderio/conduit/gas/PacketGasLevel.java create mode 100644 src/Java/miscutil/gregtech/enums/MaterialsNew.java create mode 100644 src/Java/miscutil/gregtech/gui/CONTAINER_SteamCondenser.java create mode 100644 src/Java/miscutil/gregtech/gui/GUI_SteamCondenser.java create mode 100644 src/Java/miscutil/gregtech/init/machines/GregtechSteamCondenser.java create mode 100644 src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java delete mode 100644 src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaTileEntity.java delete mode 100644 src/Java/miscutil/gregtech/metatileentity/implementations/GregtechSteelBoiler.java create mode 100644 src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaBoilerBase.java create mode 100644 src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaTileEntity.java create mode 100644 src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechSteelBoiler.java delete mode 100644 src/Java/miscutil/gregtech/objects/GregMaterialStack.java (limited to 'src/Java') diff --git a/src/Java/miscutil/MiscUtils.java b/src/Java/miscutil/MiscUtils.java index 0272d0015c..c1e6a14913 100644 --- a/src/Java/miscutil/MiscUtils.java +++ b/src/Java/miscutil/MiscUtils.java @@ -61,7 +61,7 @@ implements ActionListener //Post-Init @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { - Utils.LOG_INFO("Tidying things up."); + Utils.LOG_INFO("Cleaning up the banana on the floor."); proxy.postInit(event); } diff --git a/src/Java/miscutil/core/commands/CommandMath.java b/src/Java/miscutil/core/commands/CommandMath.java index bf5e52ad94..a099d7b5a0 100644 --- a/src/Java/miscutil/core/commands/CommandMath.java +++ b/src/Java/miscutil/core/commands/CommandMath.java @@ -79,13 +79,18 @@ public class CommandMath implements ICommand System.out.println("Processing on Server side - Home Teleport engaged by: "+P.getDisplayName()); - int XP_TOTAL = P.experienceTotal; - Utils.LOG_WARNING("Total Xp:" + XP_TOTAL); - ChunkCoordinates X = P.getPlayerCoordinates(); - Utils.LOG_WARNING("Player Location: "+X); - ChunkCoordinates Y = null; - Utils.LOG_WARNING("Bed Location: "+Y); - if (!P.getBedLocation(0).equals(null)){ + int XP_TOTAL = P.experienceTotal; + Utils.LOG_WARNING("Total Xp:" + XP_TOTAL); + ChunkCoordinates X = P.getPlayerCoordinates(); + Utils.LOG_WARNING("Player Location: "+X); + ChunkCoordinates Y = null; + Utils.LOG_WARNING("Bed Location: "+Y); + try { + if (P.getBedLocation(0).equals(null)){ + Y = W.getSpawnPoint(); + Utils.LOG_WARNING("Spawn Location: "+Y); + } + else if (!P.getBedLocation(0).equals(null)){ Y = P.getBedLocation(0); Utils.LOG_WARNING("Bed Location: "+Y); } @@ -93,69 +98,73 @@ public class CommandMath implements ICommand Y = W.getSpawnPoint(); Utils.LOG_WARNING("Spawn Location: "+Y); } - if (Y == null) { - Y = W.getSpawnPoint(); - Utils.LOG_WARNING("Spawn Location: "+Y); + } + catch(NullPointerException e) { + Utils.messagePlayer(P, "You do not have a spawn, so..."); + } + if (Y == null || Y.equals(null)) { + Y = W.getSpawnPoint(); + Utils.LOG_WARNING("Spawn Location: "+Y); + } + + int x1 = X.posX; + Utils.LOG_WARNING("X1: "+x1); + int x2 = Y.posX; + Utils.LOG_WARNING("X2: "+x2); + int y1 = X.posY; + Utils.LOG_WARNING("Y1: "+y1); + int y2 = Y.posY; + Utils.LOG_WARNING("Y2: "+y2); + int z1 = X.posZ; + Utils.LOG_WARNING("Z1: "+z1); + int z2 = Y.posZ; + Utils.LOG_WARNING("Z2: "+z2); + + + double d = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)); + String xpCost = String.valueOf((int)(d*0.15)); + + Utils.LOG_WARNING("d:" + d); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Actual math formulae"); + Utils.LOG_WARNING(String.valueOf(d)); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Xp Cost based on answer B."); + Utils.LOG_WARNING(String.valueOf(d*0.15) + " | " + String.valueOf(xpCost)); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Xp Total"); + Utils.LOG_WARNING(String.valueOf(XP_TOTAL)); + Utils.LOG_WARNING("-----------------------------------------"); + + + + if ((XP_TOTAL-Float.valueOf(xpCost)) > 0){ + EntityXPOrb E = new EntityXPOrb(W, P.posX, P.posY + 1.62D - (double) P.yOffset, P.posZ, 1); + //E.moveTowards((double) Y.posX + 0.5D, (int) Y.posY + 3, (double) Y.posZ + 0.5D); + E.setVelocity((double) Y.posX + 0.5D, (int) Y.posY + 0.1, (double) Y.posZ + 0.5D); + W.spawnEntityInWorld(E); + W.playAuxSFXAtEntity((EntityPlayer) null, 1002, (int) P.posX, (int) P.posY, (int) P.posZ, 0); + P.setPositionAndUpdate(x2, y2+1, z2); + + //gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Movement | X:"+x2+" | Y:"+y2+" | Z:"+z2); + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Distance Traveled | "+String.valueOf((int)(d)) + " Blocks & " + xpCost + "xp"); + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You suddenly feel at home."); + P.experienceTotal = (int) (XP_TOTAL-Float.valueOf(xpCost)); + if (!xpCost.equals("0") && Float.valueOf(xpCost) > 0){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "...At the loss of "+xpCost+" xp."); } - - int x1 = X.posX; - Utils.LOG_WARNING("X1: "+x1); - int x2 = Y.posX; - Utils.LOG_WARNING("X2: "+x2); - int y1 = X.posY; - Utils.LOG_WARNING("Y1: "+y1); - int y2 = Y.posY; - Utils.LOG_WARNING("Y2: "+y2); - int z1 = X.posZ; - Utils.LOG_WARNING("Z1: "+z1); - int z2 = Y.posZ; - Utils.LOG_WARNING("Z2: "+z2); - - - double d = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)); - String xpCost = String.valueOf((int)(d*0.15)); - - Utils.LOG_WARNING("d:" + d); - Utils.LOG_WARNING("-----------------------------------------"); - Utils.LOG_WARNING("Actual math formulae"); - Utils.LOG_WARNING(String.valueOf(d)); - Utils.LOG_WARNING("-----------------------------------------"); - Utils.LOG_WARNING("Xp Cost based on answer B."); - Utils.LOG_WARNING(String.valueOf(d*0.15) + " | " + String.valueOf(xpCost)); - Utils.LOG_WARNING("-----------------------------------------"); - Utils.LOG_WARNING("Xp Total"); - Utils.LOG_WARNING(String.valueOf(XP_TOTAL)); - Utils.LOG_WARNING("-----------------------------------------"); - - - - if ((XP_TOTAL-Float.valueOf(xpCost)) > 0){ - EntityXPOrb E = new EntityXPOrb(W, P.posX, P.posY + 1.62D - (double) P.yOffset, P.posZ, 1); - //E.moveTowards((double) Y.posX + 0.5D, (int) Y.posY + 3, (double) Y.posZ + 0.5D); - E.setVelocity((double) Y.posX + 0.5D, (int) Y.posY + 0.1, (double) Y.posZ + 0.5D); - W.spawnEntityInWorld(E); - W.playAuxSFXAtEntity((EntityPlayer) null, 1002, (int) P.posX, (int) P.posY, (int) P.posZ, 0); - P.setPositionAndUpdate(x2, y2+1, z2); - - //gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Movement | X:"+x2+" | Y:"+y2+" | Z:"+z2); - gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Distance Traveled | "+String.valueOf((int)(d)) + " Blocks & " + xpCost + "xp"); - gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You suddenly feel at home."); - P.experienceTotal = (int) (XP_TOTAL-Float.valueOf(xpCost)); - if (!xpCost.equals("0") && Float.valueOf(xpCost) > 0){ - gregtech.api.util.GT_Utility.sendChatToPlayer(P, "...At the loss of "+xpCost+" xp."); - } - else if (xpCost.equals("0")){ - gregtech.api.util.GT_Utility.sendChatToPlayer(P, "...At the loss of very little xp."); - } - else { - gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Something went wrong with the math, have this one on the house. :)"); - } + else if (xpCost.equals("0")){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "...At the loss of very little xp."); } - else { - gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You don't feel you're able to do this yet."); + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Something went wrong with the math, have this one on the house. :)"); } - + } + + else { + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You don't feel you're able to do this yet."); + } + } } @@ -183,11 +192,11 @@ public class CommandMath implements ICommand return false; } - + public boolean playerUsesCommand(World W, EntityPlayer P, int cost) { - + return true; } diff --git a/src/Java/miscutil/core/lib/Strings.java b/src/Java/miscutil/core/lib/Strings.java index 01976b9bdd..a26d697065 100644 --- a/src/Java/miscutil/core/lib/Strings.java +++ b/src/Java/miscutil/core/lib/Strings.java @@ -6,7 +6,7 @@ public class Strings { public static final String name = "Misc. Utils"; public static final String MODID = "miscutils"; - public static final String VERSION = "0.7.8gtu"; + public static final String VERSION = "0.9.2-gtu"; public static final boolean DEBUG = false; public static final boolean LOAD_ALL_CONTENT = false; public static final int GREG_FIRST_ID = 760; diff --git a/src/Java/miscutil/core/util/Utils.java b/src/Java/miscutil/core/util/Utils.java index 7565d1e308..2ae494d96e 100644 --- a/src/Java/miscutil/core/util/Utils.java +++ b/src/Java/miscutil/core/util/Utils.java @@ -3,6 +3,7 @@ package miscutil.core.util; import static gregtech.api.enums.GT_Values.F; import java.awt.Graphics; +import java.util.Random; import miscutil.core.lib.Strings; import net.minecraft.entity.player.EntityPlayer; @@ -14,6 +15,50 @@ import cpw.mods.fml.common.FMLLog; public class Utils { public static final int WILDCARD_VALUE = Short.MAX_VALUE; + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Integer.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Integer between min and max, inclusive. + * @see java.util.Random#nextInt(int) + */ + public static int randInt(int min, int max) { + + // Usually this can be a field rather than a method variable + Random rand = new Random(); + + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + int randomNum = rand.nextInt((max - min) + 1) + min; + + return randomNum; + } + + public static long randLong(long min, long max) { + // Usually this can be a field rather than a method variable + Random rand = new Random(); + + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + long randomNum = nextLong(rand,(max - min) + 1) + min; + + return randomNum; + } + + private static long nextLong(Random rng, long n) { + // error checking and 2^x checking removed for simplicity. + long bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (bits-val+(n-1) < 0L); + return val; + } + public static boolean containsMatch(boolean strict, ItemStack[] inputs, ItemStack... targets) { for (ItemStack input : inputs) @@ -81,5 +126,7 @@ public class Utils { public static FluidStack getIC2Steam(long aAmount) { return FluidRegistry.getFluidStack("ic2steam", (int)aAmount); } + + } diff --git a/src/Java/miscutil/core/waila/IWailaInfoProvider.java b/src/Java/miscutil/core/waila/IWailaInfoProvider.java index 90b96d4bc0..b8ac036ac5 100644 --- a/src/Java/miscutil/core/waila/IWailaInfoProvider.java +++ b/src/Java/miscutil/core/waila/IWailaInfoProvider.java @@ -1,7 +1,8 @@ -package crazypants.enderio.waila; +package miscutil.core.waila; import java.text.NumberFormat; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; @@ -11,7 +12,7 @@ public abstract interface IWailaInfoProvider public static final int BIT_COMMON = 2; public static final int BIT_DETAILED = 4; public static final int ALL_BITS = 7; - public static final NumberFormat fmt = ; + public static NumberFormat fmt = null; public abstract void getWailaInfo(List paramList, EntityPlayer paramEntityPlayer, World paramWorld, int paramInt1, int paramInt2, int paramInt3); diff --git a/src/Java/miscutil/core/waila/IWailaNBTProvider.java b/src/Java/miscutil/core/waila/IWailaNBTProvider.java index 5b4f7dbe2b..28d15a8bce 100644 --- a/src/Java/miscutil/core/waila/IWailaNBTProvider.java +++ b/src/Java/miscutil/core/waila/IWailaNBTProvider.java @@ -1,4 +1,4 @@ -package crazypants.enderio.waila; +package miscutil.core.waila; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/Java/miscutil/core/waila/WailaCompat.java b/src/Java/miscutil/core/waila/WailaCompat.java index 1f494f89bd..49cf209c87 100644 --- a/src/Java/miscutil/core/waila/WailaCompat.java +++ b/src/Java/miscutil/core/waila/WailaCompat.java @@ -1,27 +1,7 @@ -package crazypants.enderio.waila; +package miscutil.core.waila; -import crazypants.enderio.EnderIO; -import crazypants.enderio.TileEntityEio; -import crazypants.enderio.block.BlockDarkSteelAnvil; -import crazypants.enderio.conduit.ConduitUtil; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.IConduitBundle; -import crazypants.enderio.conduit.liquid.AbstractTankConduit; -import crazypants.enderio.conduit.liquid.ConduitTank; -import crazypants.enderio.conduit.power.IPowerConduit; -import crazypants.enderio.fluid.Fluids; -import crazypants.enderio.gui.IAdvancedTooltipProvider; -import crazypants.enderio.gui.IResourceTooltipProvider; -import crazypants.enderio.gui.TooltipAddera; -import crazypants.enderio.machine.IIoConfigurable; -import crazypants.enderio.machine.IoMode; -import crazypants.enderio.machine.capbank.TileCapBank; -import crazypants.enderio.machine.power.TileCapacitorBank; -import crazypants.enderio.power.IInternalPoweredTile; -import crazypants.util.IFacade; -import crazypants.util.Lang; -import java.text.NumberFormat; import java.util.List; + import mcp.mobius.waila.api.ITaggedList; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -42,9 +22,27 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraft.world.WorldSettings; import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.storage.WorldInfo; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; +import crazypants.enderio.EnderIO; +import crazypants.enderio.TileEntityEio; +import crazypants.enderio.block.BlockDarkSteelAnvil; +import crazypants.enderio.conduit.ConduitUtil; +import crazypants.enderio.conduit.IConduit; +import crazypants.enderio.conduit.IConduitBundle; +import crazypants.enderio.conduit.liquid.AbstractTankConduit; +import crazypants.enderio.conduit.liquid.ConduitTank; +import crazypants.enderio.conduit.power.IPowerConduit; +import crazypants.enderio.fluid.Fluids; +import crazypants.enderio.gui.IAdvancedTooltipProvider; +import crazypants.enderio.gui.IResourceTooltipProvider; +import crazypants.enderio.gui.TooltipAddera; +import crazypants.enderio.machine.IIoConfigurable; +import crazypants.enderio.machine.IoMode; +import crazypants.enderio.machine.capbank.TileCapBank; +import crazypants.enderio.machine.power.TileCapacitorBank; +import crazypants.enderio.power.IInternalPoweredTile; +import crazypants.util.IFacade; +import crazypants.util.Lang; public class WailaCompat implements IWailaDataProvider @@ -56,7 +54,7 @@ public class WailaCompat private WailaWorldWrapper(World wrapped) { - super(wrapped.getWorldInfo().getWorldName(), wrapped.provider, new WorldSettings(wrapped.getWorldInfo()), wrapped.theProfiler); + super(null, wrapped.getWorldInfo().getWorldName(), wrapped.provider, new WorldSettings(wrapped.getWorldInfo()), wrapped.theProfiler); this.wrapped = wrapped; this.isRemote = wrapped.isRemote; } @@ -133,7 +131,7 @@ public class WailaCompat - ConfigHandler.instance().addConfig("Ender IO", "facades.hidden", Lang.localize("waila.config.hiddenfacades")); + ConfigHandler.instance().addConfig("MiscUtils", "facades.hidden", Lang.localize("waila.config.hiddenfacades")); IWailaInfoProvider.fmt.setMaximumFractionDigits(1); } @@ -151,7 +149,7 @@ public class WailaCompat Block facade = bundle.getFacade(accessor.getWorld(), pos.blockX, pos.blockY, pos.blockZ, accessor.getSide().ordinal()); if (facade != null) { - ItemStack ret = facade.getPickBlock(pos, new WailaWorldWrapper(accessor.getWorld(), null), pos.blockX, pos.blockY, pos.blockZ); + ItemStack ret = facade.getPickBlock(pos, new WailaWorldWrapper(accessor.getWorld()), pos.blockX, pos.blockY, pos.blockZ); return ret; } } diff --git a/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtConduit.java b/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtConduit.java deleted file mode 100644 index de0fc13371..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtConduit.java +++ /dev/null @@ -1,73 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasStack; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.conduit.AbstractConduitNetwork; -import crazypants.enderio.conduit.gas.AbstractGasConduit; -import crazypants.enderio.conduit.geom.CollidableComponent; - -public class AbstractGtConduit extends AbstractGasConduit{ - - @Override - public ItemStack createItem() { - // TODO Auto-generated method stub - return null; - } - - @Override - public AbstractConduitNetwork getNetwork() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean setNetwork(AbstractConduitNetwork network) { - // TODO Auto-generated method stub - return false; - } - - @Override - public IIcon getTextureForState(CollidableComponent component) { - // TODO Auto-generated method stub - return null; - } - - @Override - public IIcon getTransmitionTextureForState(CollidableComponent component) { - // TODO Auto-generated method stub - return null; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) { - // TODO Auto-generated method stub - return false; - } - - protected boolean canJoinNeighbour(IGtConduit n) { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtTankConduit.java b/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtTankConduit.java deleted file mode 100644 index 1b440aa0bb..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtTankConduit.java +++ /dev/null @@ -1,161 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import java.util.List; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.conduit.AbstractConduitNetwork; -import crazypants.enderio.conduit.ConduitUtil; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.RaytraceResult; -import crazypants.enderio.tool.ToolUtil; -import crazypants.util.BlockCoord; - -public abstract class AbstractGtTankConduit extends AbstractGtConduit { - - protected ConduitGtTank tank = new ConduitGtTank(0); - protected boolean stateDirty = false; - protected long lastEmptyTick = 0; - protected int numEmptyEvents = 0; - - @Override - public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List all) { - if(player.getCurrentEquippedItem() == null) { - return false; - } - if(ToolUtil.isToolEquipped(player)) { - - if(!getBundle().getEntity().getWorldObj().isRemote) { - - if(res != null && res.component != null) { - - ForgeDirection connDir = res.component.dir; - ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit); - - if(connDir == ForgeDirection.UNKNOWN || connDir == faceHit) { - - if(getConnectionMode(faceHit) == ConnectionMode.DISABLED) { - setConnectionMode(faceHit, getNextConnectionMode(faceHit)); - return true; - } - - BlockCoord loc = getLocation().getLocation(faceHit); - IGtConduit n = ConduitUtil.getConduit(getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, IGtConduit.class); - if(n == null) { - return false; - } - if(!canJoinNeighbour(n)) { - return false; - } - if(!(n instanceof AbstractGtTankConduit)) { - return false; - } - AbstractGtTankConduit neighbour = (AbstractGtTankConduit) n; - if(neighbour.getGasType() == null || getGasType() == null) { - GasStack type = getGasType(); - type = type != null ? type : neighbour.getGasType(); - neighbour.setGasTypeOnNetwork(neighbour, type); - setGasTypeOnNetwork(this, type); - } - return ConduitUtil.joinConduits(this, faceHit); - } else if(containsExternalConnection(connDir)) { - // Toggle extraction mode - setConnectionMode(connDir, getNextConnectionMode(connDir)); - } else if(containsConduitConnection(connDir)) { - GasStack curGasType = null; - if(getTankNetwork() != null) { - curGasType = getTankNetwork().getGasType(); - } - ConduitUtil.disconectConduits(this, connDir); - setGasType(curGasType); - - } - } - } - return true; - - } - - return false; - } - - private void setGasTypeOnNetwork(AbstractGtTankConduit con, GasStack type) { - AbstractConduitNetwork n = con.getNetwork(); - if(n != null) { - AbstractGtTankConduitNetwork network = (AbstractGtTankConduitNetwork) n; - network.setGasType(type); - } - - } - - protected abstract boolean canJoinNeighbour(IGtConduit n); - - public abstract AbstractGtTankConduitNetwork getTankNetwork(); - - public void setGasType(GasStack gasType) { - if(tank.getGas() != null && tank.getGas().isGasEqual(gasType)) { - return; - } - if(gasType != null) { - gasType = gasType.copy(); - } else if(tank.getGas() == null) { - return; - } - tank.setGas(gasType); - stateDirty = true; - } - - public ConduitGtTank getTank() { - return tank; - } - - public GasStack getGasType() { - GasStack result = null; - if(getTankNetwork() != null) { - result = getTankNetwork().getGasType(); - } - if(result == null) { - result = tank.getGas(); - } - return result; - } - - @Override - public boolean canOutputToDir(ForgeDirection dir) { - if (super.canOutputToDir(dir)) { - IGasHandler ext = getExternalHandler(dir); - return ext != null && ext.canReceiveGas(dir.getOpposite(), tank.getGasType()); - } - return false; - } - - protected abstract void updateTank(); - - @Override - public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) { - super.readFromNBT(nbtRoot, nbtVersion); - updateTank(); - if(nbtRoot.hasKey("tank")) { - GasStack gas = GasStack.readFromNBT(nbtRoot.getCompoundTag("tank")); - tank.setGas(gas); - } else { - tank.setGas(null); - } - } - - @Override - public void writeToNBT(NBTTagCompound nbtRoot) { - super.writeToNBT(nbtRoot); - GasStack gt = getGasType(); - if(GtUtil.isGasValid(gt)) { - updateTank(); - gt = gt.copy(); - gt.amount = tank.getStored(); - nbtRoot.setTag("tank", gt.write(new NBTTagCompound())); - } - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtTankConduitNetwork.java b/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtTankConduitNetwork.java deleted file mode 100644 index e48a9b97e5..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/AbstractGtTankConduitNetwork.java +++ /dev/null @@ -1,64 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import mekanism.api.gas.GasStack; -import crazypants.enderio.conduit.AbstractConduitNetwork; - -public class AbstractGtTankConduitNetwork extends AbstractConduitNetwork { - - protected GasStack gasType; - private int test; - protected AbstractGtTankConduitNetwork(Class cl) { - super(cl); - } - - public GasStack getGasType() { - return gasType; - } - - @Override - public Class getBaseConduitType() { - return IGtConduit.class; - } - - @Override - public void addConduit(T con) { - super.addConduit(con); - con.setGasType(gasType); - } - - public boolean setGasType(GasStack newType) { - if(gasType != null && gasType.isGasEqual(newType)) { - return false; - } - if(newType != null) { - gasType = newType.copy(); - gasType.amount = 0; - } else { - gasType = null; - } - for (AbstractGtTankConduit conduit : conduits) { - conduit.setGasType(gasType); - } - return true; - } - - public boolean canAcceptGas(GasStack acceptable) { - return areGassCompatable(gasType, acceptable); - } - - public static boolean areGassCompatable(GasStack a, GasStack b) { - if(a == null || b == null) { - return true; - } - return a.isGasEqual(b); - } - - public int getTotalVolume() { - int totalVolume = 0; - for (T con : conduits) { - totalVolume += con.getTank().getStored(); - } - return totalVolume; - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/ConduitGtTank.java b/src/Java/miscutil/enderio/conduit/GregTech/ConduitGtTank.java deleted file mode 100644 index d1a81f32d2..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/ConduitGtTank.java +++ /dev/null @@ -1,153 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTank; -import net.minecraft.nbt.NBTTagCompound; - -public class ConduitGtTank extends GasTank { - - private int capacity; - - ConduitGtTank(int capacity) { - super(capacity); - this.capacity = capacity; - } - - public float getFilledRatio() { - if(getStored() <= 0) { - return 0; - } - if(getMaxGas() <= 0) { - return -1; - } - float res = (float) getStored() / getMaxGas(); - return res; - } - - public boolean isFull() { - return getStored() >= getMaxGas(); - } - - public void setAmount(int amount) { - if(stored != null) { - stored.amount = amount; - } - } - - public int getAvailableSpace() { - return getMaxGas() - getStored(); - } - - public void addAmount(int amount) { - setAmount(getStored() + amount); - } - - @Override - public int getMaxGas() { - return this.capacity; - } - - public void setCapacity(int capacity) { - this.capacity = capacity; - if(getStored() > capacity) { - setAmount(capacity); - } - } - - @Override - public int receive(GasStack resource, boolean doReceive) { - if(resource == null || resource.getGas().getID() < 0) { - return 0; - } - - if(stored == null || stored.getGas().getID() < 0) { - if(resource.amount <= capacity) { - if(doReceive) { - setGas(resource.copy()); - } - return resource.amount; - } else { - if(doReceive) { - stored = resource.copy(); - stored.amount = capacity; - } - return capacity; - } - } - - if(!stored.isGasEqual(resource)) { - return 0; - } - - int space = capacity - stored.amount; - if(resource.amount <= space) { - if(doReceive) { - addAmount(resource.amount); - } - return resource.amount; - } else { - if(doReceive) { - stored.amount = capacity; - } - return space; - } - - } - - @Override - public GasStack draw(int maxDrain, boolean doDraw) { - if(stored == null || stored.getGas().getID() < 0) { - return null; - } - if(stored.amount <= 0) { - return null; - } - - int used = maxDrain; - if(stored.amount < used) { - used = stored.amount; - } - - if(doDraw) { - addAmount(-used); - } - - GasStack drained = new GasStack(stored.getGas().getID(), used); - - if(stored.amount < 0) { - stored.amount = 0; - } - return drained; - } - - public String getGasName() { - return stored != null ? stored.getGas().getLocalizedName() : null; - } - - public boolean containsValidGas() { - return GtUtil.isGasValid(stored); - } - - public NBTTagCompound write(NBTTagCompound nbt) { - if(containsValidGas()) { - stored.write(nbt); - } else { - nbt.setBoolean("emptyGasTank", true); - } - return nbt; - } - - public void read(NBTTagCompound nbt) { - if(!nbt.hasKey("emptyGasTank")) { - GasStack gas = GasStack.readFromNBT(nbt); - if(gas != null) { - setGas(gas); - } - } - } - - public boolean isEmpty() { - return stored == null || stored.amount == 0; - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/GtConduit.java b/src/Java/miscutil/enderio/conduit/GregTech/GtConduit.java deleted file mode 100644 index 3af9f089e4..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/GtConduit.java +++ /dev/null @@ -1,265 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import java.util.HashMap; -import java.util.Map; - -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasStack; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import crazypants.enderio.EnderIO; -import crazypants.enderio.conduit.AbstractConduitNetwork; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.geom.CollidableComponent; -import crazypants.enderio.config.Config; -import crazypants.render.IconUtil; -import crazypants.util.BlockCoord; - -public class GtConduit extends AbstractGtTankConduit { - - public static final int CONDUIT_VOLUME = 1000; - - public static final String ICON_KEY = "enderio:gasConduit"; - public static final String ICON_CORE_KEY = "enderio:gasConduitCore"; - public static final String ICON_EXTRACT_KEY = "enderio:gasConduitInput"; - public static final String ICON_INSERT_KEY = "enderio:gasConduitOutput"; - public static final String ICON_EMPTY_EDGE = "enderio:gasConduitEdge"; - - static final Map ICONS = new HashMap(); - - @SideOnly(Side.CLIENT) - public static void initIcons() { - IconUtil.addIconProvider(new IconUtil.IIconProvider() { - - @Override - public void registerIcons(IIconRegister register) { - ICONS.put(ICON_KEY, register.registerIcon(ICON_KEY)); - ICONS.put(ICON_CORE_KEY, register.registerIcon(ICON_CORE_KEY)); - ICONS.put(ICON_EXTRACT_KEY, register.registerIcon(ICON_EXTRACT_KEY)); - ICONS.put(ICON_INSERT_KEY, register.registerIcon(ICON_INSERT_KEY)); - ICONS.put(ICON_EMPTY_EDGE, register.registerIcon(ICON_EMPTY_EDGE)); - } - - @Override - public int getTextureType() { - return 0; - } - - }); - } - - private GtConduitNetwork network; - - private long ticksSinceFailedExtract = 0; - - public static final int MAX_EXTRACT_PER_TICK = Config.gasConduitExtractRate; - - public static final int MAX_IO_PER_TICK = Config.gasConduitMaxIoRate; - - public GtConduit() { - updateTank(); - } - - @Override - public void updateEntity(World world) { - super.updateEntity(world); - if(world.isRemote) { - return; - } - doExtract(); - if(stateDirty) { - getBundle().dirty(); - stateDirty = false; - } - } - - private void doExtract() { - BlockCoord loc = getLocation(); - if(!hasConnectionMode(ConnectionMode.INPUT)) { - return; - } - if(network == null) { - return; - } - - // assume failure, reset to 0 if we do extract - ticksSinceFailedExtract++; - if(ticksSinceFailedExtract > 25 && ticksSinceFailedExtract % 10 != 0) { - // after 25 ticks of failing, only check every 10 ticks - return; - } - - Gas f = tank.getGas() == null ? null : tank.getGas().getGas(); - for (ForgeDirection dir : externalConnections) { - if(autoExtractForDir(dir)) { - if(network.extractFrom(this, dir, MAX_EXTRACT_PER_TICK)) { - ticksSinceFailedExtract = 0; - } - } - } - - } - - @Override - protected void updateTank() { - tank.setCapacity(CONDUIT_VOLUME); - if(network != null) { - network.updateConduitVolumes(); - } - } - - @Override - public ItemStack createItem() { - return new ItemStack(EnderIO.itemGasConduit); - } - - @Override - public AbstractConduitNetwork getNetwork() { - return network; - } - - @Override - public boolean setNetwork(AbstractConduitNetwork network) { - if(network == null) { - this.network = null; - return true; - } - if(!(network instanceof GtConduitNetwork)) { - return false; - } - - GtConduitNetwork n = (GtConduitNetwork) network; - if(tank.getGas() == null) { - tank.setGas(n.getGasType() == null ? null : n.getGasType().copy()); - } else if(n.getGasType() == null) { - n.setGasType(tank.getGas()); - } else if(!tank.getGas().isGasEqual(n.getGasType())) { - return false; - } - this.network = n; - return true; - - } - - @Override - public boolean canConnectToConduit(ForgeDirection direction, IConduit con) { - if(!super.canConnectToConduit(direction, con)) { - return false; - } - if(!(con instanceof GtConduit)) { - return false; - } - if(getGasType() != null && ((GtConduit) con).getGasType() == null) { - return false; - } - return GtConduitNetwork.areGassCompatable(getGasType(), ((GtConduit) con).getGasType()); - } - - @Override - public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) { - super.setConnectionMode(dir, mode); - refreshInputs(dir); - } - - private void refreshInputs(ForgeDirection dir) { - if(network == null) { - return; - } - GtOutput lo = new GtOutput(getLocation().getLocation(dir), dir.getOpposite()); - network.removeInput(lo); - if(getConnectionMode(dir).acceptsOutput() && containsExternalConnection(dir)) { - network.addInput(lo); - } - } - - @Override - public void externalConnectionAdded(ForgeDirection fromDirection) { - super.externalConnectionAdded(fromDirection); - refreshInputs(fromDirection); - } - - @Override - public void externalConnectionRemoved(ForgeDirection fromDirection) { - super.externalConnectionRemoved(fromDirection); - refreshInputs(fromDirection); - } - - @Override - public IIcon getTextureForState(CollidableComponent component) { - if(component.dir == ForgeDirection.UNKNOWN) { - return ICONS.get(ICON_CORE_KEY); - } - return ICONS.get(ICON_KEY); - } - - public IIcon getTextureForInputMode() { - return ICONS.get(ICON_EXTRACT_KEY); - } - - public IIcon getTextureForOutputMode() { - return ICONS.get(ICON_INSERT_KEY); - } - - public IIcon getNotSetEdgeTexture() { - return ICONS.get(ICON_EMPTY_EDGE); - } - - @Override - public IIcon getTransmitionTextureForState(CollidableComponent component) { - if(isActive() && tank.containsValidGas()) { - return tank.getGas().getGas().getIcon(); - } - return null; - } - - // ------------------------------------------- Gas API - - @Override - public int receiveGas(ForgeDirection from, GasStack resource) { - if(network == null || !getConnectionMode(from).acceptsInput()) { - return 0; - } - return network.fill(from, resource, true); - } - - @Override - public GasStack drawGas(ForgeDirection from, int maxDrain) { - if(network == null || !getConnectionMode(from).acceptsOutput()) { - return null; - } - return network.drain(from, maxDrain, true); - } - - @Override - public boolean canReceiveGas(ForgeDirection from, Gas gas) { - if(network == null) { - return false; - } - return getConnectionMode(from).acceptsInput() && GtConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0)); - } - - @Override - public boolean canDrawGas(ForgeDirection from, Gas gas) { - if(network == null) { - return false; - } - return getConnectionMode(from).acceptsOutput() && GtConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0)); - } - - @Override - protected boolean canJoinNeighbour(IGtConduit n) { - return n instanceof GtConduit; - } - - @Override - public AbstractGtTankConduitNetwork getTankNetwork() { - return network; - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/GtConduitNetwork.java b/src/Java/miscutil/enderio/conduit/GregTech/GtConduitNetwork.java deleted file mode 100644 index 7855547a7e..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/GtConduitNetwork.java +++ /dev/null @@ -1,310 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import miscutil.enderio.conduit.ConduitGTHandler; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent; -import crazypants.enderio.conduit.ConduitNetworkTickHandler; -import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener; -import crazypants.enderio.conduit.IConduit; -import crazypants.util.BlockCoord; - -public class GtConduitNetwork extends AbstractGtTankConduitNetwork { - - private final ConduitGtTank tank = new ConduitGtTank(0); - - private final Set outputs = new HashSet(); - - private Iterator outputIterator; - - private int ticksActiveUnsynced; - - private boolean lastSyncedActive = false; - - private int lastSyncedVolume = -1; - - private long timeAtLastApply; - - private final InnerTickHandler tickHandler = new InnerTickHandler(); - - public GtConduitNetwork() { - super(GtConduit.class); - } - - @Override - public Class getBaseConduitType() { - return IGtConduit.class; - } - - @Override - public void addConduit(GtConduit con) { - tank.setCapacity(tank.getMaxGas() + GtConduit.CONDUIT_VOLUME); - if(con.getTank().containsValidGas()) { - tank.addAmount(con.getTank().getStored()); - } - for (ForgeDirection dir : con.getExternalConnections()) { - if(con.getConnectionMode(dir).acceptsOutput()) { - outputs.add(new GtOutput(con.getLocation().getLocation(dir), dir.getOpposite())); - } - } - outputIterator = null; - super.addConduit(con); - } - - @Override - public boolean setGasType(GasStack newType) { - if(super.setGasType(newType)) { - - GasStack ft = getGasType(); - tank.setGas(ft == null ? null : ft.copy()); - return true; - } - return false; - } - - @Override - public void destroyNetwork() { - setConduitVolumes(); - outputs.clear(); - super.destroyNetwork(); - } - - private void setConduitVolumes() { - if(tank.containsValidGas() && !conduits.isEmpty()) { - GasStack gasPerConduit = tank.getGas().copy(); - int numCons = conduits.size(); - int leftOvers = gasPerConduit.amount % numCons; - gasPerConduit.amount = gasPerConduit.amount / numCons; - - for (GtConduit con : conduits) { - GasStack f = gasPerConduit.copy(); - if(leftOvers > 0) { - f.amount += 1; - leftOvers--; - } - con.getTank().setGas(f); - BlockCoord bc = con.getLocation(); - con.getBundle().getEntity().getWorldObj().markTileEntityChunkModified(bc.x, bc.y, bc.z, con.getBundle().getEntity()); - } - - } - } - - @Override - public void onUpdateEntity(IConduit conduit) { - World world = conduit.getBundle().getEntity().getWorldObj(); - if(world == null) { - return; - } - if(world.isRemote) { - return; - } - - long curTime = world.getTotalWorldTime(); - if(curTime > 0 && curTime != timeAtLastApply) { - timeAtLastApply = curTime; - ConduitNetworkTickHandler.instance.addListener(tickHandler); - } - - } - - private void doTick() { - if(gasType == null || outputs.isEmpty() || !tank.containsValidGas() || tank.isEmpty()) { - updateActiveState(); - return; - } - - if(outputIterator == null || !outputIterator.hasNext()) { - outputIterator = outputs.iterator(); - } - - updateActiveState(); - - int numVisited = 0; - while (!tank.isEmpty() && numVisited < outputs.size()) { - if(!outputIterator.hasNext()) { - outputIterator = outputs.iterator(); - } - GtOutput output = outputIterator.next(); - if(output != null) { - ConduitGTHandler cont = (ConduitGTHandler) getTankContainer(output.location); - if(cont != null) { - GasStack offer = tank.getGas().copy(); - int filled = cont.receiveGas(output.dir, offer); - if(filled > 0) { - tank.addAmount(-filled); - - } - } - } - numVisited++; - } - - } - - private void updateActiveState() { - boolean isActive = tank.containsValidGas() && !tank.isEmpty(); - if(lastSyncedActive != isActive) { - ticksActiveUnsynced++; - } else { - ticksActiveUnsynced = 0; - } - if(ticksActiveUnsynced >= 10 || ticksActiveUnsynced > 0 && isActive) { - if(!isActive) { - setGasType(null); - } - for (IConduit con : conduits) { - con.setActive(isActive); - } - lastSyncedActive = isActive; - ticksActiveUnsynced = 0; - } - } - - public int fill(ForgeDirection from, GasStack resource, boolean doFill) { - if(resource == null) { - return 0; - } - resource.amount = Math.min(resource.amount, GtConduit.MAX_IO_PER_TICK); - boolean gasWasValid = tank.containsValidGas(); - int res = tank.receive(resource, doFill); - if(doFill && res > 0 && gasWasValid) { - int vol = tank.getStored(); - setGasType(resource); - tank.setAmount(vol); - } - return res; - } - - public GasStack drain(ForgeDirection from, GasStack resource, boolean doDrain) { - if(resource == null || tank.isEmpty() || !tank.containsValidGas() || !GtConduitNetwork.areGassCompatable(getGasType(), resource)) { - return null; - } - int amount = Math.min(resource.amount, tank.getStored()); - amount = Math.min(amount, GtConduit.MAX_IO_PER_TICK); - GasStack result = resource.copy(); - result.amount = amount; - if(doDrain) { - tank.addAmount(-amount); - } - return result; - } - - public GasStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - if(tank.isEmpty() || !tank.containsValidGas()) { - return null; - } - int amount = Math.min(maxDrain, tank.getStored()); - GasStack result = tank.getGas().copy(); - result.amount = amount; - if(doDrain) { - tank.addAmount(-amount); - } - return result; - } - - public boolean extractFrom(GtConduit advancedGtConduit, ForgeDirection dir, int maxExtractPerTick) { - - if(tank.isFull()) { - return false; - } - - IGasHandler extTank = getTankContainer(advancedGtConduit, dir); - if(extTank != null) { - int maxExtract = Math.min(maxExtractPerTick, tank.getAvailableSpace()); - - if(gasType == null || !tank.containsValidGas()) { - GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract); - if(drained == null || drained.amount <= 0) { - return false; - } - setGasType(drained); - tank.setGas(drained.copy()); - return true; - } - - GasStack couldDrain = gasType.copy(); - couldDrain.amount = maxExtract; - - // GasStack drained = extTank.drain(dir.getOpposite(), couldDrain, true); - // if(drained == null || drained.amount <= 0) { - // return false; - // } - // tank.addAmount(drained.amount); - - //Have to use this 'double handle' approach to work around an issue with TiC - GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract); - if(drained == null || drained.amount == 0) { - return false; - } else { - if(drained.isGasEqual(getGasType())) { - tank.addAmount(drained.amount); - } - } - return true; - } - return false; - } - - public IGasHandler getTankContainer(BlockCoord bc) { - World w = getWorld(); - if(w == null) { - return null; - } - TileEntity te = w.getTileEntity(bc.x, bc.y, bc.z); - if(te instanceof IGasHandler) { - return (IGasHandler) te; - } - return null; - } - - public IGasHandler getTankContainer(GtConduit con, ForgeDirection dir) { - BlockCoord bc = con.getLocation().getLocation(dir); - return getTankContainer(bc); - } - - World getWorld() { - if(conduits.isEmpty()) { - return null; - } - return conduits.get(0).getBundle().getWorld(); - } - - public void removeInput(GtOutput lo) { - outputs.remove(lo); - outputIterator = null; - } - - public void addInput(GtOutput lo) { - outputs.add(lo); - outputIterator = null; - } - - public void updateConduitVolumes() { - if(tank.getStored() == lastSyncedVolume) { - return; - } - setConduitVolumes(); - lastSyncedVolume = tank.getStored(); - } - - private class InnerTickHandler implements TickListener { - - @Override - public void tickStart(ServerTickEvent evt) { - } - - @Override - public void tickEnd(ServerTickEvent evt) { - doTick(); - } - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/GtConduitRenderer.java b/src/Java/miscutil/enderio/conduit/GregTech/GtConduitRenderer.java deleted file mode 100644 index 00070b0db5..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/GtConduitRenderer.java +++ /dev/null @@ -1,180 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import static crazypants.render.CubeRenderer.addVecWithUV; - -import java.util.List; - -import mekanism.api.gas.GasStack; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.IIcon; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.EnderIO; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.IConduitBundle; -import crazypants.enderio.conduit.geom.CollidableComponent; -import crazypants.enderio.conduit.geom.ConnectionModeGeometry; -import crazypants.enderio.conduit.geom.Offset; -import crazypants.enderio.conduit.render.ConduitBundleRenderer; -import crazypants.enderio.conduit.render.DefaultConduitRenderer; -import crazypants.render.BoundingBox; -import crazypants.render.RenderUtil; -import crazypants.vecmath.Vector3d; -import crazypants.vecmath.Vertex; - -public class GtConduitRenderer extends DefaultConduitRenderer { - - @Override - public boolean isRendererForConduit(IConduit conduit) { - return conduit instanceof GtConduit; - } - - @Override - public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x, double y, double z, float partialTick, - float worldLight, RenderBlocks rb) { - super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight, rb); - - if(!conduit.hasConnectionMode(ConnectionMode.INPUT) && !conduit.hasConnectionMode(ConnectionMode.OUTPUT)) { - return; - } - GtConduit pc = (GtConduit) conduit; - for (ForgeDirection dir : conduit.getExternalConnections()) { - IIcon tex = null; - if(conduit.getConnectionMode(dir) == ConnectionMode.INPUT) { - tex = pc.getTextureForInputMode(); - } else if(conduit.getConnectionMode(dir) == ConnectionMode.OUTPUT) { - tex = pc.getTextureForOutputMode(); - } - if(tex != null) { - Offset offset = te.getOffset(IGtConduit.class, dir); - ConnectionModeGeometry.renderModeConnector(dir, offset, tex, true); - } - } - } - - @Override - protected void renderConduit(IIcon tex, IConduit conduit, CollidableComponent component, float brightness) { - super.renderConduit(tex, conduit, component, brightness); - - if(isNSEWUD(component.dir)) { - GtConduit lc = (GtConduit) conduit; - - GasStack gas = lc.getGasType(); - IIcon texture = null; - if(gas != null) { - texture = gas.getGas().getIcon(); - } - - if(texture == null) { - texture = lc.getNotSetEdgeTexture(); - } - - float scaleFactor = 0.75f; - float xLen = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor; - float yLen = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor; - float zLen = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor; - - BoundingBox cube = component.bound; - BoundingBox bb = cube.scale(xLen, yLen, zLen); - - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - if(d != component.dir && d != component.dir.getOpposite()) { - - ForgeDirection vDir = RenderUtil.getVDirForFace(d); - if(component.dir == ForgeDirection.UP || component.dir == ForgeDirection.DOWN) { - vDir = RenderUtil.getUDirForFace(d); - } else if((component.dir == ForgeDirection.NORTH || component.dir == ForgeDirection.SOUTH) && d.offsetY != 0) { - vDir = RenderUtil.getUDirForFace(d); - } - - float minU = texture.getMinU(); - float maxU = texture.getMaxU(); - float minV = texture.getMinV(); - float maxV = texture.getMaxV(); - - float sideScale = Math.max(bb.sizeX(), bb.sizeY()) * 2 / 16f; - sideScale = Math.max(sideScale, bb.sizeZ() * 2 / 16f); - float width = Math.min(bb.sizeX(), bb.sizeY()) * 15f / 16f; - - List corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV); - moveEdgeCorners(corners, vDir, width); - moveEdgeCorners(corners, component.dir.getOpposite(), sideScale); - for (Vertex c : corners) { - addVecWithUV(c.xyz, c.uv.x, c.uv.y); - } - - corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV); - moveEdgeCorners(corners, vDir.getOpposite(), width); - moveEdgeCorners(corners, component.dir.getOpposite(), sideScale); - for (Vertex c : corners) { - addVecWithUV(c.xyz, c.uv.x, c.uv.y); - } - - } - } - - if(conduit.getConnectionMode(component.dir) == ConnectionMode.DISABLED) { - tex = EnderIO.blockConduitBundle.getConnectorIcon(component.data); - List corners = component.bound.getCornersWithUvForFace(component.dir, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV()); - Tessellator tessellator = Tessellator.instance; - for (Vertex c : corners) { - addVecWithUV(c.xyz, c.uv.x, c.uv.y); - } - //back face - for (int i = corners.size() - 1; i >= 0; i--) { - Vertex c = corners.get(i); - addVecWithUV(c.xyz, c.uv.x, c.uv.y); - } - } - - } - - } - - @Override - protected void renderTransmission(IConduit conduit, IIcon tex, CollidableComponent component, float selfIllum) { - super.renderTransmission(conduit, tex, component, selfIllum); - } - - private void moveEdgeCorners(List vertices, ForgeDirection edge, float scaleFactor) { - int[] indices = getClosest(edge, vertices); - vertices.get(indices[0]).xyz.x -= scaleFactor * edge.offsetX; - vertices.get(indices[1]).xyz.x -= scaleFactor * edge.offsetX; - vertices.get(indices[0]).xyz.y -= scaleFactor * edge.offsetY; - vertices.get(indices[1]).xyz.y -= scaleFactor * edge.offsetY; - vertices.get(indices[0]).xyz.z -= scaleFactor * edge.offsetZ; - vertices.get(indices[1]).xyz.z -= scaleFactor * edge.offsetZ; - } - - private int[] getClosest(ForgeDirection edge, List vertices) { - int[] res = new int[] { -1, -1 }; - boolean highest = edge.offsetX > 0 || edge.offsetY > 0 || edge.offsetZ > 0; - double minMax = highest ? -Double.MAX_VALUE : Double.MAX_VALUE; - int index = 0; - for (Vertex v : vertices) { - double val = get(v.xyz, edge); - if(highest ? val >= minMax : val <= minMax) { - if(val != minMax) { - res[0] = index; - } else { - res[1] = index; - } - minMax = val; - } - index++; - } - return res; - } - - private double get(Vector3d xyz, ForgeDirection edge) { - if(edge == ForgeDirection.EAST || edge == ForgeDirection.WEST) { - return xyz.x; - } - if(edge == ForgeDirection.UP || edge == ForgeDirection.DOWN) { - return xyz.y; - } - return xyz.z; - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/GtOutput.java b/src/Java/miscutil/enderio/conduit/GregTech/GtOutput.java deleted file mode 100644 index afaa97eb00..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/GtOutput.java +++ /dev/null @@ -1,49 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.util.BlockCoord; - -public class GtOutput { - - final ForgeDirection dir; - final BlockCoord location; - - public GtOutput(BlockCoord bc, ForgeDirection dir) { - this.dir = dir; - this.location = bc; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((location == null) ? 0 : location.hashCode()); - result = prime * result + ((dir == null) ? 0 : dir.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if(this == obj) - return true; - if(obj == null) - return false; - if(getClass() != obj.getClass()) - return false; - GtOutput other = (GtOutput) obj; - if(location == null) { - if(other.location != null) - return false; - } else if(!location.equals(other.location)) - return false; - if(dir != other.dir) - return false; - return true; - } - - @Override - public String toString() { - return "GasOutput [dir=" + dir + ", location=" + location + "]"; - } - -} \ No newline at end of file diff --git a/src/Java/miscutil/enderio/conduit/GregTech/GtUtil.java b/src/Java/miscutil/enderio/conduit/GregTech/GtUtil.java deleted file mode 100644 index 16408ca88c..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/GtUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.common.Loader; -import crazypants.enderio.conduit.IConduitBundle; -import crazypants.enderio.config.Config; -import crazypants.util.BlockCoord; - -public final class GtUtil { - - private static boolean useCheckPerformed = false; - private static boolean isGasConduitEnabled = false; - - public static boolean isGasConduitEnabled() { - if (!useCheckPerformed) { - String configOption = Config.isGasConduitEnabled; - if (configOption.equalsIgnoreCase("auto")) { - isGasConduitEnabled = Loader.isModLoaded("Mekanism"); - if (isGasConduitEnabled) { - isGasConduitEnabled = Loader.instance().getIndexedModList().get("Mekanism").getVersion().startsWith("7"); - } - } else if (configOption.equalsIgnoreCase("true")) { - isGasConduitEnabled = true; - } else { - isGasConduitEnabled = false; - } - useCheckPerformed = true; - } - return isGasConduitEnabled; - } - - public static IGasHandler getExternalGasHandler(IBlockAccess world, BlockCoord bc) { - IGasHandler con = getGasHandler(world, bc); - return (con != null && !(con instanceof IConduitBundle)) ? con : null; - } - - public static IGasHandler getGasHandler(IBlockAccess world, BlockCoord bc) { - return getGasHandler(world, bc.x, bc.y, bc.z); - } - - public static IGasHandler getGasHandler(IBlockAccess world, int x, int y, int z) { - TileEntity te = world.getTileEntity(x, y, z); - return getGasHandler(te); - } - - public static IGasHandler getGasHandler(TileEntity te) { - if(te instanceof IGasHandler) { - return (IGasHandler) te; - } - return null; - } - - public static boolean isGasValid(GasStack gas) { - if(gas != null) { - String name = gas.getGas().getLocalizedName(); - if(name != null && !name.trim().isEmpty()) { - return true; - } - } - return false; - } - - private GtUtil() { - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/IGtConduit.java b/src/Java/miscutil/enderio/conduit/GregTech/IGtConduit.java deleted file mode 100644 index 869966e33d..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/IGtConduit.java +++ /dev/null @@ -1,12 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.conduit.IConduit; - -public interface IGtConduit extends IConduit { - - boolean canOutputToDir(ForgeDirection dir); - - boolean isExtractingFromDir(ForgeDirection dir); - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/ItemGtConduit.java b/src/Java/miscutil/enderio/conduit/GregTech/ItemGtConduit.java deleted file mode 100644 index 9ded118f20..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/ItemGtConduit.java +++ /dev/null @@ -1,76 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import crazypants.enderio.ModObject; -import crazypants.enderio.conduit.AbstractItemConduit; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.ItemConduitSubtype; -import crazypants.enderio.config.Config; -import crazypants.enderio.gui.IAdvancedTooltipProvider; -import crazypants.enderio.gui.TooltipAddera; -import crazypants.util.Lang; - -public class ItemGtConduit extends AbstractItemConduit implements IAdvancedTooltipProvider { - - private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] { - new ItemConduitSubtype(ModObject.itemGasConduit.name(), "enderio:itemGasConduit"), - }; - - public static ItemGtConduit create() { - ItemGtConduit result = new ItemGtConduit(); - if (GtUtil.isGasConduitEnabled()) { - result.init(); - } - return result; - } - - protected ItemGtConduit() { - super(ModObject.itemGasConduit, subtypes); - if(!GtUtil.isGasConduitEnabled()) { - setCreativeTab(null); - } - } - - @Override - public Class getBaseConduitType() { - return IGtConduit.class; - } - - @Override - public IConduit createConduit(ItemStack stack, EntityPlayer player) { - return new GtConduit(); - } - - @Override - @SideOnly(Side.CLIENT) - public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - } - - @Override - @SideOnly(Side.CLIENT) - public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - - } - - @Override - @SideOnly(Side.CLIENT) - public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - String gpt = " " + Lang.localize("gas.gasTick"); - int extractRate = Config.gasConduitExtractRate; - int maxIo = Config.gasConduitMaxIoRate; - list.add(Lang.localize("itemGasConduit.tooltip.maxExtract") + " " + extractRate + gpt); - list.add(Lang.localize("itemGasConduit.tooltip.maxIo") + " " + maxIo + gpt); - TooltipAddera.addDetailedTooltipFromResources(list, "enderio.itemGasConduit"); - } - - @Override - public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) { - return true; - } - -} diff --git a/src/Java/miscutil/enderio/conduit/GregTech/PacketGtLevel.java b/src/Java/miscutil/enderio/conduit/GregTech/PacketGtLevel.java deleted file mode 100644 index 9998d59d20..0000000000 --- a/src/Java/miscutil/enderio/conduit/GregTech/PacketGtLevel.java +++ /dev/null @@ -1,43 +0,0 @@ -package miscutil.enderio.conduit.GregTech; - -import io.netty.buffer.ByteBuf; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.common.network.ByteBufUtils; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import crazypants.enderio.conduit.gas.IGasConduit; -import crazypants.enderio.network.MessageTileEntity; - -public class PacketGtLevel extends MessageTileEntity implements IMessageHandler { - - public NBTTagCompound tc; - - public PacketGtLevel() { - } - - public PacketGtLevel(IGasConduit conduit) { - super(conduit.getBundle().getEntity()); - tc = new NBTTagCompound(); - conduit.writeToNBT(tc); - } - - @Override - public void toBytes(ByteBuf buf) { - super.toBytes(buf); - ByteBufUtils.writeTag(buf, tc); - } - - @Override - public void fromBytes(ByteBuf buf) { - super.fromBytes(buf); - tc = ByteBufUtils.readTag(buf); - } - - @Override - public IMessage onMessage(PacketGtLevel message, MessageContext ctx) { - // TODO ClientUtil.doGasLevelUpdate(message.x, message.y, message.z, message); - return null; - } -} diff --git a/src/Java/miscutil/enderio/conduit/MetaConduitBase.java b/src/Java/miscutil/enderio/conduit/MetaConduitBase.java index ea7c431ecb..32560a470d 100644 --- a/src/Java/miscutil/enderio/conduit/MetaConduitBase.java +++ b/src/Java/miscutil/enderio/conduit/MetaConduitBase.java @@ -12,7 +12,7 @@ import gregtech.api.util.GT_Utility; import ic2.api.item.IElectricItem; import miscutil.core.handler.GuiHandler; import miscutil.core.util.Utils; -import miscutil.gregtech.metatileentity.implementations.GregtechMetaTileEntity; +import miscutil.gregtech.metatileentity.implementations.base.GregtechMetaTileEntity; import miscutil.gregtech.util.IMessage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/Java/miscutil/enderio/conduit/gas/AbstractGasConduit.java b/src/Java/miscutil/enderio/conduit/gas/AbstractGasConduit.java deleted file mode 100644 index 0cdee252b0..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/AbstractGasConduit.java +++ /dev/null @@ -1,203 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.EnumMap; -import java.util.HashMap; -import java.util.Map; - -import mekanism.api.gas.IGasHandler; -import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.conduit.AbstractConduit; -import crazypants.enderio.conduit.ConduitUtil; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.IConduitBundle; -import crazypants.enderio.machine.RedstoneControlMode; -import crazypants.enderio.machine.reservoir.TileReservoir; -import crazypants.util.BlockCoord; -import crazypants.util.DyeColor; - -public abstract class AbstractGasConduit - extends AbstractConduit - implements IGasConduit -{ - protected final EnumMap extractionModes = new EnumMap(ForgeDirection.class); - protected final EnumMap extractionColors = new EnumMap(ForgeDirection.class); - protected final Map externalRedstoneSignals = new HashMap(); - protected boolean redstoneStateDirty = true; - - public IGasHandler getExternalHandler(ForgeDirection direction) - { - IGasHandler con = GasUtil.getExternalGasHandler(getBundle().getWorld(), getLocation().getLocation(direction)); - return (con != null) && (!(con instanceof IConduitBundle)) ? con : null; - } - - public IGasHandler getTankContainer(BlockCoord bc) - { - return GasUtil.getGasHandler(getBundle().getWorld(), bc); - } - - public boolean canConnectToExternal(ForgeDirection direction, boolean ignoreDisabled) - { - IGasHandler h = getExternalHandler(direction); - if (h == null) { - return false; - } - return true; - } - - public Class getBaseConduitType() - { - return IGasConduit.class; - } - - public boolean onNeighborBlockChange(Block blockId) - { - this.redstoneStateDirty = true; - return super.onNeighborBlockChange(blockId); - } - - public void setExtractionRedstoneMode(RedstoneControlMode mode, ForgeDirection dir) - { - this.extractionModes.put(dir, mode); - this.redstoneStateDirty = true; - } - - public RedstoneControlMode getExtractionRedstoneMode(ForgeDirection dir) - { - RedstoneControlMode res = (RedstoneControlMode)this.extractionModes.get(dir); - if (res == null) { - res = RedstoneControlMode.ON; - } - return res; - } - - public void setExtractionSignalColor(ForgeDirection dir, DyeColor col) - { - this.extractionColors.put(dir, col); - } - - public DyeColor getExtractionSignalColor(ForgeDirection dir) - { - DyeColor result = (DyeColor)this.extractionColors.get(dir); - if (result == null) { - return DyeColor.RED; - } - return result; - } - - public boolean canOutputToDir(ForgeDirection dir) - { - if ((isExtractingFromDir(dir)) || (getConnectionMode(dir) == ConnectionMode.DISABLED)) { - return false; - } - if (this.conduitConnections.contains(dir)) { - return true; - } - if (!this.externalConnections.contains(dir)) { - return false; - } - IGasHandler ext = getExternalHandler(dir); - if ((ext instanceof TileReservoir)) - { - TileReservoir tr = (TileReservoir)ext; - return (!tr.isMultiblock()) || (!tr.isAutoEject()); - } - return true; - } - - protected boolean autoExtractForDir(ForgeDirection dir) - { - if (!isExtractingFromDir(dir)) { - return false; - } - RedstoneControlMode mode = getExtractionRedstoneMode(dir); - if (mode == RedstoneControlMode.IGNORE) { - return true; - } - if (mode == RedstoneControlMode.NEVER) { - return false; - } - if (this.redstoneStateDirty) - { - this.externalRedstoneSignals.clear(); - this.redstoneStateDirty = false; - } - DyeColor col = getExtractionSignalColor(dir); - int signal = ConduitUtil.getInternalSignalForColor(getBundle(), col); - if ((RedstoneControlMode.isConditionMet(mode, signal)) && (mode != RedstoneControlMode.OFF)) { - return true; - } - return isConditionMetByExternalSignal(dir, mode, col); - } - - private boolean isConditionMetByExternalSignal(ForgeDirection dir, RedstoneControlMode mode, DyeColor col) - { - int externalSignal = 0; - if (col == DyeColor.RED) - { - Integer val = (Integer)this.externalRedstoneSignals.get(dir); - if (val == null) - { - TileEntity te = getBundle().getEntity(); - externalSignal = te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord); - this.externalRedstoneSignals.put(dir, Integer.valueOf(externalSignal)); - } - else - { - externalSignal = val.intValue(); - } - } - return RedstoneControlMode.isConditionMet(mode, externalSignal); - } - - public boolean isExtractingFromDir(ForgeDirection dir) - { - return getConnectionMode(dir) == ConnectionMode.INPUT; - } - - public void writeToNBT(NBTTagCompound nbtRoot) - { - super.writeToNBT(nbtRoot); - for (Map.Entry entry : this.extractionModes.entrySet()) { - if (entry.getValue() != null) - { - short ord = (short)((RedstoneControlMode)entry.getValue()).ordinal(); - nbtRoot.setShort("extRM." + ((ForgeDirection)entry.getKey()).name(), ord); - } - } - for (Map.Entry entry : this.extractionColors.entrySet()) { - if (entry.getValue() != null) - { - short ord = (short)((DyeColor)entry.getValue()).ordinal(); - nbtRoot.setShort("extSC." + ((ForgeDirection)entry.getKey()).name(), ord); - } - } - } - - public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) - { - super.readFromNBT(nbtRoot, nbtVersion); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - String key = "extRM." + dir.name(); - if (nbtRoot.hasKey(key)) - { - short ord = nbtRoot.getShort(key); - if ((ord >= 0) && (ord < RedstoneControlMode.values().length)) { - this.extractionModes.put(dir, RedstoneControlMode.values()[ord]); - } - } - key = "extSC." + dir.name(); - if (nbtRoot.hasKey(key)) - { - short ord = nbtRoot.getShort(key); - if ((ord >= 0) && (ord < DyeColor.values().length)) { - this.extractionColors.put(dir, DyeColor.values()[ord]); - } - } - } - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduit.java b/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduit.java deleted file mode 100644 index 7b8e36f498..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduit.java +++ /dev/null @@ -1,169 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.List; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.conduit.AbstractConduitNetwork; -import crazypants.enderio.conduit.ConduitUtil; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.RaytraceResult; -import crazypants.enderio.tool.ToolUtil; -import crazypants.util.BlockCoord; - -public abstract class AbstractGasTankConduit - extends AbstractGasConduit -{ - protected ConduitGasTank tank = new ConduitGasTank(0); - protected boolean stateDirty = false; - protected long lastEmptyTick = 0L; - protected int numEmptyEvents = 0; - - public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List all) - { - if (player.getCurrentEquippedItem() == null) { - return false; - } - if (ToolUtil.isToolEquipped(player)) - { - if (!getBundle().getEntity().getWorldObj().isRemote) { - if ((res != null) && (res.component != null)) - { - ForgeDirection connDir = res.component.dir; - ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit); - if ((connDir == ForgeDirection.UNKNOWN) || (connDir == faceHit)) - { - if (getConnectionMode(faceHit) == ConnectionMode.DISABLED) - { - setConnectionMode(faceHit, getNextConnectionMode(faceHit)); - return true; - } - BlockCoord loc = getLocation().getLocation(faceHit); - IGasConduit n = (IGasConduit)ConduitUtil.getConduit(getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, IGasConduit.class); - if (n == null) { - return false; - } - if (!canJoinNeighbour(n)) { - return false; - } - if (!(n instanceof AbstractGasTankConduit)) { - return false; - } - AbstractGasTankConduit neighbour = (AbstractGasTankConduit)n; - if ((neighbour.getGasType() == null) || (getGasType() == null)) - { - GasStack type = getGasType(); - type = type != null ? type : neighbour.getGasType(); - neighbour.setGasTypeOnNetwork(neighbour, type); - setGasTypeOnNetwork(this, type); - } - return ConduitUtil.joinConduits(this, faceHit); - } - if (containsExternalConnection(connDir)) - { - setConnectionMode(connDir, getNextConnectionMode(connDir)); - } - else if (containsConduitConnection(connDir)) - { - GasStack curGasType = null; - if (getTankNetwork() != null) { - curGasType = getTankNetwork().getGasType(); - } - ConduitUtil.disconectConduits(this, connDir); - setGasType(curGasType); - } - } - } - return true; - } - return false; - } - - private void setGasTypeOnNetwork(AbstractGasTankConduit con, GasStack type) - { - AbstractConduitNetwork n = con.getNetwork(); - if (n != null) - { - AbstractGasTankConduitNetwork network = (AbstractGasTankConduitNetwork)n; - network.setGasType(type); - } - } - - protected abstract boolean canJoinNeighbour(IGasConduit paramIGasConduit); - - public abstract AbstractGasTankConduitNetwork getTankNetwork(); - - public void setGasType(GasStack gasType) - { - if ((this.tank.getGas() != null) && (this.tank.getGas().isGasEqual(gasType))) { - return; - } - if (gasType != null) { - gasType = gasType.copy(); - } else if (this.tank.getGas() == null) { - return; - } - this.tank.setGas(gasType); - this.stateDirty = true; - } - - public ConduitGasTank getTank() - { - return this.tank; - } - - public GasStack getGasType() - { - GasStack result = null; - if (getTankNetwork() != null) { - result = getTankNetwork().getGasType(); - } - if (result == null) { - result = this.tank.getGas(); - } - return result; - } - - public boolean canOutputToDir(ForgeDirection dir) - { - if (super.canOutputToDir(dir)) - { - IGasHandler ext = getExternalHandler(dir); - return (ext != null) && (ext.canReceiveGas(dir.getOpposite(), this.tank.getGasType())); - } - return false; - } - - protected abstract void updateTank(); - - public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) - { - super.readFromNBT(nbtRoot, nbtVersion); - updateTank(); - if (nbtRoot.hasKey("tank")) - { - GasStack gas = GasStack.readFromNBT(nbtRoot.getCompoundTag("tank")); - this.tank.setGas(gas); - } - else - { - this.tank.setGas(null); - } - } - - public void writeToNBT(NBTTagCompound nbtRoot) - { - super.writeToNBT(nbtRoot); - GasStack gt = getGasType(); - if (GasUtil.isGasValid(gt)) - { - updateTank(); - gt = gt.copy(); - gt.amount = this.tank.getStored(); - nbtRoot.setTag("tank", gt.write(new NBTTagCompound())); - } - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduitNetwork.java b/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduitNetwork.java deleted file mode 100644 index ec75d1319e..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduitNetwork.java +++ /dev/null @@ -1,73 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import mekanism.api.gas.GasStack; -import crazypants.enderio.conduit.AbstractConduitNetwork; - -public class AbstractGasTankConduitNetwork - extends AbstractConduitNetwork -{ - protected GasStack gasType; - - protected AbstractGasTankConduitNetwork(Class cl) - { - super(cl); - } - - public GasStack getGasType() - { - return this.gasType; - } - - public Class getBaseConduitType() - { - return IGasConduit.class; - } - - public void addConduit(T con) - { - super.addConduit(con); - con.setGasType(this.gasType); - } - - public boolean setGasType(GasStack newType) - { - if ((this.gasType != null) && (this.gasType.isGasEqual(newType))) { - return false; - } - if (newType != null) - { - this.gasType = newType.copy(); - this.gasType.amount = 0; - } - else - { - this.gasType = null; - } - for (AbstractGasTankConduit conduit : this.conduits) { - conduit.setGasType(this.gasType); - } - return true; - } - - public boolean canAcceptGas(GasStack acceptable) - { - return areGassCompatable(this.gasType, acceptable); - } - - public static boolean areGassCompatable(GasStack a, GasStack b) - { - if ((a == null) || (b == null)) { - return true; - } - return a.isGasEqual(b); - } - - public int getTotalVolume() - { - int totalVolume = 0; - for (T con : this.conduits) { - totalVolume += con.getTank().getStored(); - } - return totalVolume; - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/ConduitGasTank.java b/src/Java/miscutil/enderio/conduit/gas/ConduitGasTank.java deleted file mode 100644 index 3e944a2f2c..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/ConduitGasTank.java +++ /dev/null @@ -1,160 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTank; -import net.minecraft.nbt.NBTTagCompound; - -public class ConduitGasTank - extends GasTank -{ - private int capacity; - - ConduitGasTank(int capacity) - { - super(capacity); - this.capacity = capacity; - } - - public float getFilledRatio() - { - if (getStored() <= 0) { - return 0.0F; - } - if (getMaxGas() <= 0) { - return -1.0F; - } - float res = getStored() / getMaxGas(); - return res; - } - - public boolean isFull() - { - return getStored() >= getMaxGas(); - } - - public void setAmount(int amount) - { - if (this.stored != null) { - this.stored.amount = amount; - } - } - - public int getAvailableSpace() - { - return getMaxGas() - getStored(); - } - - public void addAmount(int amount) - { - setAmount(getStored() + amount); - } - - public int getMaxGas() - { - return this.capacity; - } - - public void setCapacity(int capacity) - { - this.capacity = capacity; - if (getStored() > capacity) { - setAmount(capacity); - } - } - - public int receive(GasStack resource, boolean doReceive) - { - if ((resource == null) || (resource.getGas().getID() < 0)) { - return 0; - } - if ((this.stored == null) || (this.stored.getGas().getID() < 0)) - { - if (resource.amount <= this.capacity) - { - if (doReceive) { - setGas(resource.copy()); - } - return resource.amount; - } - if (doReceive) - { - this.stored = resource.copy(); - this.stored.amount = this.capacity; - } - return this.capacity; - } - if (!this.stored.isGasEqual(resource)) { - return 0; - } - int space = this.capacity - this.stored.amount; - if (resource.amount <= space) - { - if (doReceive) { - addAmount(resource.amount); - } - return resource.amount; - } - if (doReceive) { - this.stored.amount = this.capacity; - } - return space; - } - - public GasStack draw(int maxDrain, boolean doDraw) - { - if ((this.stored == null) || (this.stored.getGas().getID() < 0)) { - return null; - } - if (this.stored.amount <= 0) { - return null; - } - int used = maxDrain; - if (this.stored.amount < used) { - used = this.stored.amount; - } - if (doDraw) { - addAmount(-used); - } - GasStack drained = new GasStack(this.stored.getGas().getID(), used); - if (this.stored.amount < 0) { - this.stored.amount = 0; - } - return drained; - } - - public String getGasName() - { - return this.stored != null ? this.stored.getGas().getLocalizedName() : null; - } - - public boolean containsValidGas() - { - return GasUtil.isGasValid(this.stored); - } - - public NBTTagCompound write(NBTTagCompound nbt) - { - if (containsValidGas()) { - this.stored.write(nbt); - } else { - nbt.setBoolean("emptyGasTank", true); - } - return nbt; - } - - public void read(NBTTagCompound nbt) - { - if (!nbt.hasKey("emptyGasTank")) - { - GasStack gas = GasStack.readFromNBT(nbt); - if (gas != null) { - setGas(gas); - } - } - } - - public boolean isEmpty() - { - return (this.stored == null) || (this.stored.amount == 0); - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/GasConduit.java b/src/Java/miscutil/enderio/conduit/gas/GasConduit.java deleted file mode 100644 index bac24cabfd..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/GasConduit.java +++ /dev/null @@ -1,258 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.HashMap; -import java.util.Map; - -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasStack; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import crazypants.enderio.EnderIO; -import crazypants.enderio.conduit.AbstractConduitNetwork; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.geom.CollidableComponent; -import crazypants.enderio.config.Config; -import crazypants.render.IconUtil; -import crazypants.util.BlockCoord; - -public class GasConduit - extends AbstractGasTankConduit -{ - public static final int CONDUIT_VOLUME = 1000; - public static final String ICON_KEY = "enderio:gasConduit"; - public static final String ICON_CORE_KEY = "enderio:gasConduitCore"; - public static final String ICON_EXTRACT_KEY = "enderio:gasConduitInput"; - public static final String ICON_INSERT_KEY = "enderio:gasConduitOutput"; - public static final String ICON_EMPTY_EDGE = "enderio:gasConduitEdge"; - static final Map ICONS = new HashMap(); - private GasConduitNetwork network; - - @SideOnly(Side.CLIENT) - public static void initIcons() - { - IconUtil.addIconProvider(new IconUtil.IIconProvider() - { - public void registerIcons(IIconRegister register) - { - GasConduit.ICONS.put("enderio:gasConduit", register.registerIcon("enderio:gasConduit")); - GasConduit.ICONS.put("enderio:gasConduitCore", register.registerIcon("enderio:gasConduitCore")); - GasConduit.ICONS.put("enderio:gasConduitInput", register.registerIcon("enderio:gasConduitInput")); - GasConduit.ICONS.put("enderio:gasConduitOutput", register.registerIcon("enderio:gasConduitOutput")); - GasConduit.ICONS.put("enderio:gasConduitEdge", register.registerIcon("enderio:gasConduitEdge")); - } - - public int getTextureType() - { - return 0; - } - }); - } - - private long ticksSinceFailedExtract = 0L; - public static final int MAX_EXTRACT_PER_TICK = Config.gasConduitExtractRate; - public static final int MAX_IO_PER_TICK = Config.gasConduitMaxIoRate; - - public GasConduit() - { - updateTank(); - } - - public void updateEntity(World world) - { - super.updateEntity(world); - if (world.isRemote) { - return; - } - doExtract(); - if (this.stateDirty) - { - getBundle().dirty(); - this.stateDirty = false; - } - } - - private void doExtract() - { - BlockCoord loc = getLocation(); - if (!hasConnectionMode(ConnectionMode.INPUT)) { - return; - } - if (this.network == null) { - return; - } - this.ticksSinceFailedExtract += 1L; - if ((this.ticksSinceFailedExtract > 25L) && (this.ticksSinceFailedExtract % 10L != 0L)) { - return; - } - Gas f = this.tank.getGas() == null ? null : this.tank.getGas().getGas(); - for (ForgeDirection dir : this.externalConnections) { - if ((autoExtractForDir(dir)) && - (this.network.extractFrom(this, dir, MAX_EXTRACT_PER_TICK))) { - this.ticksSinceFailedExtract = 0L; - } - } - } - - protected void updateTank() - { - this.tank.setCapacity(1000); - if (this.network != null) { - this.network.updateConduitVolumes(); - } - } - - public ItemStack createItem() - { - return new ItemStack(EnderIO.itemGasConduit); - } - - public AbstractConduitNetwork getNetwork() - { - return this.network; - } - - public boolean setNetwork(AbstractConduitNetwork network) - { - if (network == null) - { - this.network = null; - return true; - } - if (!(network instanceof GasConduitNetwork)) { - return false; - } - GasConduitNetwork n = (GasConduitNetwork)network; - if (this.tank.getGas() == null) { - this.tank.setGas(n.getGasType() == null ? null : n.getGasType().copy()); - } else if (n.getGasType() == null) { - n.setGasType(this.tank.getGas()); - } else if (!this.tank.getGas().isGasEqual(n.getGasType())) { - return false; - } - this.network = n; - return true; - } - - public boolean canConnectToConduit(ForgeDirection direction, IConduit con) - { - if (!super.canConnectToConduit(direction, con)) { - return false; - } - if (!(con instanceof GasConduit)) { - return false; - } - if ((getGasType() != null) && (((GasConduit)con).getGasType() == null)) { - return false; - } - return GasConduitNetwork.areGassCompatable(getGasType(), ((GasConduit)con).getGasType()); - } - - public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) - { - super.setConnectionMode(dir, mode); - refreshInputs(dir); - } - - private void refreshInputs(ForgeDirection dir) - { - if (this.network == null) { - return; - } - GasOutput lo = new GasOutput(getLocation().getLocation(dir), dir.getOpposite()); - this.network.removeInput(lo); - if ((getConnectionMode(dir).acceptsOutput()) && (containsExternalConnection(dir))) { - this.network.addInput(lo); - } - } - - public void externalConnectionAdded(ForgeDirection fromDirection) - { - super.externalConnectionAdded(fromDirection); - refreshInputs(fromDirection); - } - - public void externalConnectionRemoved(ForgeDirection fromDirection) - { - super.externalConnectionRemoved(fromDirection); - refreshInputs(fromDirection); - } - - public IIcon getTextureForState(CollidableComponent component) - { - if (component.dir == ForgeDirection.UNKNOWN) { - return (IIcon)ICONS.get("enderio:gasConduitCore"); - } - return (IIcon)ICONS.get("enderio:gasConduit"); - } - - public IIcon getTextureForInputMode() - { - return (IIcon)ICONS.get("enderio:gasConduitInput"); - } - - public IIcon getTextureForOutputMode() - { - return (IIcon)ICONS.get("enderio:gasConduitOutput"); - } - - public IIcon getNotSetEdgeTexture() - { - return (IIcon)ICONS.get("enderio:gasConduitEdge"); - } - - public IIcon getTransmitionTextureForState(CollidableComponent component) - { - if ((isActive()) && (this.tank.containsValidGas())) { - return this.tank.getGas().getGas().getIcon(); - } - return null; - } - - public int receiveGas(ForgeDirection from, GasStack resource) - { - if ((this.network == null) || (!getConnectionMode(from).acceptsInput())) { - return 0; - } - return this.network.fill(from, resource, true); - } - - public GasStack drawGas(ForgeDirection from, int maxDrain) - { - if ((this.network == null) || (!getConnectionMode(from).acceptsOutput())) { - return null; - } - return this.network.drain(from, maxDrain, true); - } - - public boolean canReceiveGas(ForgeDirection from, Gas gas) - { - if (this.network == null) { - return false; - } - return (getConnectionMode(from).acceptsInput()) && (GasConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0))); - } - - public boolean canDrawGas(ForgeDirection from, Gas gas) - { - if (this.network == null) { - return false; - } - return (getConnectionMode(from).acceptsOutput()) && (GasConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0))); - } - - protected boolean canJoinNeighbour(IGasConduit n) - { - return n instanceof GasConduit; - } - - public AbstractGasTankConduitNetwork getTankNetwork() - { - return this.network; - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java b/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java deleted file mode 100644 index a93a418627..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java +++ /dev/null @@ -1,317 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.gameevent.TickEvent; -import crazypants.enderio.conduit.ConduitNetworkTickHandler; -import crazypants.enderio.conduit.IConduit; -import crazypants.util.BlockCoord; - -public class GasConduitNetwork - extends AbstractGasTankConduitNetwork -{ - private final ConduitGasTank tank = new ConduitGasTank(0); - private final Set outputs = new HashSet(); - private Iterator outputIterator; - private int ticksActiveUnsynced; - private boolean lastSyncedActive = false; - private int lastSyncedVolume = -1; - private long timeAtLastApply; - private final InnerTickHandler tickHandler = new InnerTickHandler(); - - public GasConduitNetwork() - { - super(GasConduit.class); - } - - public Class getBaseConduitType() - { - return IGasConduit.class; - } - - public void addConduit(GasConduit con) - { - this.tank.setCapacity(this.tank.getMaxGas() + 1000); - if (con.getTank().containsValidGas()) { - this.tank.addAmount(con.getTank().getStored()); - } - for (ForgeDirection dir : con.getExternalConnections()) { - if (con.getConnectionMode(dir).acceptsOutput()) { - this.outputs.add(new GasOutput(con.getLocation().getLocation(dir), dir.getOpposite())); - } - } - this.outputIterator = null; - super.addConduit(con); - } - - public boolean setGasType(GasStack newType) - { - if (super.setGasType(newType)) - { - GasStack ft = getGasType(); - this.tank.setGas(ft == null ? null : ft.copy()); - return true; - } - return false; - } - - public void destroyNetwork() - { - setConduitVolumes(); - this.outputs.clear(); - super.destroyNetwork(); - } - - private void setConduitVolumes() - { - GasStack gasPerConduit; - int leftOvers; - if ((this.tank.containsValidGas()) && (!this.conduits.isEmpty())) - { - gasPerConduit = this.tank.getGas().copy(); - int numCons = this.conduits.size(); - leftOvers = gasPerConduit.amount % numCons; - gasPerConduit.amount /= numCons; - for (GasConduit con : this.conduits) - { - GasStack f = gasPerConduit.copy(); - if (leftOvers > 0) - { - f.amount += 1; - leftOvers--; - } - con.getTank().setGas(f); - BlockCoord bc = con.getLocation(); - con.getBundle().getEntity().getWorldObj().markTileEntityChunkModified(bc.x, bc.y, bc.z, con.getBundle().getEntity()); - } - } - } - - public void onUpdateEntity(IConduit conduit) - { - World world = conduit.getBundle().getEntity().getWorldObj(); - if (world == null) { - return; - } - if (world.isRemote) { - return; - } - long curTime = world.getTotalWorldTime(); - if ((curTime > 0L) && (curTime != this.timeAtLastApply)) - { - this.timeAtLastApply = curTime; - ConduitNetworkTickHandler.instance.addListener(this.tickHandler); - } - } - - private void doTick() - { - if ((this.gasType == null) || (this.outputs.isEmpty()) || (!this.tank.containsValidGas()) || (this.tank.isEmpty())) - { - updateActiveState(); - return; - } - if ((this.outputIterator == null) || (!this.outputIterator.hasNext())) { - this.outputIterator = this.outputs.iterator(); - } - updateActiveState(); - - int numVisited = 0; - while ((!this.tank.isEmpty()) && (numVisited < this.outputs.size())) - { - if (!this.outputIterator.hasNext()) { - this.outputIterator = this.outputs.iterator(); - } - GasOutput output = (GasOutput)this.outputIterator.next(); - if (output != null) - { - IGasHandler cont = getTankContainer(output.location); - if (cont != null) - { - GasStack offer = this.tank.getGas().copy(); - int filled = cont.receiveGas(output.dir, offer); - if (filled > 0) { - this.tank.addAmount(-filled); - } - } - } - numVisited++; - } - } - - private void updateActiveState() - { - boolean isActive = (this.tank.containsValidGas()) && (!this.tank.isEmpty()); - if (this.lastSyncedActive != isActive) { - this.ticksActiveUnsynced += 1; - } else { - this.ticksActiveUnsynced = 0; - } - if ((this.ticksActiveUnsynced >= 10) || ((this.ticksActiveUnsynced > 0) && (isActive))) - { - if (!isActive) { - setGasType(null); - } - for (IConduit con : this.conduits) { - con.setActive(isActive); - } - this.lastSyncedActive = isActive; - this.ticksActiveUnsynced = 0; - } - } - - public int fill(ForgeDirection from, GasStack resource, boolean doFill) - { - if (resource == null) { - return 0; - } - resource.amount = Math.min(resource.amount, GasConduit.MAX_IO_PER_TICK); - boolean gasWasValid = this.tank.containsValidGas(); - int res = this.tank.receive(resource, doFill); - if ((doFill) && (res > 0) && (gasWasValid)) - { - int vol = this.tank.getStored(); - setGasType(resource); - this.tank.setAmount(vol); - } - return res; - } - - public GasStack drain(ForgeDirection from, GasStack resource, boolean doDrain) - { - if ((resource == null) || (this.tank.isEmpty()) || (!this.tank.containsValidGas()) || (!areGassCompatable(getGasType(), resource))) { - return null; - } - int amount = Math.min(resource.amount, this.tank.getStored()); - amount = Math.min(amount, GasConduit.MAX_IO_PER_TICK); - GasStack result = resource.copy(); - result.amount = amount; - if (doDrain) { - this.tank.addAmount(-amount); - } - return result; - } - - public GasStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - if ((this.tank.isEmpty()) || (!this.tank.containsValidGas())) { - return null; - } - int amount = Math.min(maxDrain, this.tank.getStored()); - GasStack result = this.tank.getGas().copy(); - result.amount = amount; - if (doDrain) { - this.tank.addAmount(-amount); - } - return result; - } - - public boolean extractFrom(GasConduit advancedGasConduit, ForgeDirection dir, int maxExtractPerTick) - { - if (this.tank.isFull()) { - return false; - } - IGasHandler extTank = getTankContainer(advancedGasConduit, dir); - if (extTank != null) - { - int maxExtract = Math.min(maxExtractPerTick, this.tank.getAvailableSpace()); - if ((this.gasType == null) || (!this.tank.containsValidGas())) - { - GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract); - if ((drained == null) || (drained.amount <= 0)) { - return false; - } - setGasType(drained); - this.tank.setGas(drained.copy()); - return true; - } - GasStack couldDrain = this.gasType.copy(); - couldDrain.amount = maxExtract; - - - - - - - - - GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract); - if ((drained == null) || (drained.amount == 0)) { - return false; - } - if (drained.isGasEqual(getGasType())) { - this.tank.addAmount(drained.amount); - } - return true; - } - return false; - } - - public IGasHandler getTankContainer(BlockCoord bc) - { - World w = getWorld(); - if (w == null) { - return null; - } - TileEntity te = w.getTileEntity(bc.x, bc.y, bc.z); - if ((te instanceof IGasHandler)) { - return (IGasHandler)te; - } - return null; - } - - public IGasHandler getTankContainer(GasConduit con, ForgeDirection dir) - { - BlockCoord bc = con.getLocation().getLocation(dir); - return getTankContainer(bc); - } - - World getWorld() - { - if (this.conduits.isEmpty()) { - return null; - } - return ((GasConduit)this.conduits.get(0)).getBundle().getWorld(); - } - - public void removeInput(GasOutput lo) - { - this.outputs.remove(lo); - this.outputIterator = null; - } - - public void addInput(GasOutput lo) - { - this.outputs.add(lo); - this.outputIterator = null; - } - - public void updateConduitVolumes() - { - if (this.tank.getStored() == this.lastSyncedVolume) { - return; - } - setConduitVolumes(); - this.lastSyncedVolume = this.tank.getStored(); - } - - private class InnerTickHandler - implements ConduitNetworkTickHandler.TickListener - { - private InnerTickHandler() {} - - public void tickStart(TickEvent.ServerTickEvent evt) {} - - public void tickEnd(TickEvent.ServerTickEvent evt) - { - GasConduitNetwork.this.doTick(); - } - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/GasConduitRenderer.java b/src/Java/miscutil/enderio/conduit/gas/GasConduitRenderer.java deleted file mode 100644 index b8b6450a47..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/GasConduitRenderer.java +++ /dev/null @@ -1,176 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.List; - -import mekanism.api.gas.GasStack; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.IIcon; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.EnderIO; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.IConduitBundle; -import crazypants.enderio.conduit.geom.CollidableComponent; -import crazypants.enderio.conduit.geom.ConnectionModeGeometry; -import crazypants.enderio.conduit.geom.Offset; -import crazypants.enderio.conduit.render.ConduitBundleRenderer; -import crazypants.enderio.conduit.render.DefaultConduitRenderer; -import crazypants.render.BoundingBox; -import crazypants.render.CubeRenderer; -import crazypants.render.RenderUtil; -import crazypants.vecmath.Vector3d; -import crazypants.vecmath.Vertex; - -public class GasConduitRenderer - extends DefaultConduitRenderer -{ - public boolean isRendererForConduit(IConduit conduit) - { - return conduit instanceof GasConduit; - } - - public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x, double y, double z, float partialTick, float worldLight, RenderBlocks rb) - { - super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight, rb); - if ((!conduit.hasConnectionMode(ConnectionMode.INPUT)) && (!conduit.hasConnectionMode(ConnectionMode.OUTPUT))) { - return; - } - GasConduit pc = (GasConduit)conduit; - for (ForgeDirection dir : conduit.getExternalConnections()) - { - IIcon tex = null; - if (conduit.getConnectionMode(dir) == ConnectionMode.INPUT) { - tex = pc.getTextureForInputMode(); - } else if (conduit.getConnectionMode(dir) == ConnectionMode.OUTPUT) { - tex = pc.getTextureForOutputMode(); - } - if (tex != null) - { - Offset offset = te.getOffset(IGasConduit.class, dir); - ConnectionModeGeometry.renderModeConnector(dir, offset, tex, true); - } - } - } - - protected void renderConduit(IIcon tex, IConduit conduit, CollidableComponent component, float brightness) - { - super.renderConduit(tex, conduit, component, brightness); - if (isNSEWUD(component.dir)) - { - GasConduit lc = (GasConduit)conduit; - - GasStack gas = lc.getGasType(); - IIcon texture = null; - if (gas != null) { - texture = gas.getGas().getIcon(); - } - if (texture == null) { - texture = lc.getNotSetEdgeTexture(); - } - float scaleFactor = 0.75F; - float xLen = Math.abs(component.dir.offsetX) == 1 ? 1.0F : scaleFactor; - float yLen = Math.abs(component.dir.offsetY) == 1 ? 1.0F : scaleFactor; - float zLen = Math.abs(component.dir.offsetZ) == 1 ? 1.0F : scaleFactor; - - BoundingBox cube = component.bound; - BoundingBox bb = cube.scale(xLen, yLen, zLen); - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - if ((d != component.dir) && (d != component.dir.getOpposite())) - { - ForgeDirection vDir = RenderUtil.getVDirForFace(d); - if ((component.dir == ForgeDirection.UP) || (component.dir == ForgeDirection.DOWN)) { - vDir = RenderUtil.getUDirForFace(d); - } else if (((component.dir == ForgeDirection.NORTH) || (component.dir == ForgeDirection.SOUTH)) && (d.offsetY != 0)) { - vDir = RenderUtil.getUDirForFace(d); - } - float minU = texture.getMinU(); - float maxU = texture.getMaxU(); - float minV = texture.getMinV(); - float maxV = texture.getMaxV(); - - float sideScale = Math.max(bb.sizeX(), bb.sizeY()) * 2.0F / 16.0F; - sideScale = Math.max(sideScale, bb.sizeZ() * 2.0F / 16.0F); - float width = Math.min(bb.sizeX(), bb.sizeY()) * 15.0F / 16.0F; - - List corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV); - moveEdgeCorners(corners, vDir, width); - moveEdgeCorners(corners, component.dir.getOpposite(), sideScale); - for (Vertex c : corners) { - CubeRenderer.addVecWithUV(c.xyz, c.uv.x, c.uv.y); - } - corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV); - moveEdgeCorners(corners, vDir.getOpposite(), width); - moveEdgeCorners(corners, component.dir.getOpposite(), sideScale); - for (Vertex c : corners) { - CubeRenderer.addVecWithUV(c.xyz, c.uv.x, c.uv.y); - } - } - } - if (conduit.getConnectionMode(component.dir) == ConnectionMode.DISABLED) - { - tex = EnderIO.blockConduitBundle.getConnectorIcon(component.data); - List corners = component.bound.getCornersWithUvForFace(component.dir, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV()); - Tessellator tessellator = Tessellator.instance; - for (Vertex c : corners) { - CubeRenderer.addVecWithUV(c.xyz, c.uv.x, c.uv.y); - } - for (int i = corners.size() - 1; i >= 0; i--) - { - Vertex c = (Vertex)corners.get(i); - CubeRenderer.addVecWithUV(c.xyz, c.uv.x, c.uv.y); - } - } - } - } - - protected void renderTransmission(IConduit conduit, IIcon tex, CollidableComponent component, float selfIllum) - { - super.renderTransmission(conduit, tex, component, selfIllum); - } - - private void moveEdgeCorners(List vertices, ForgeDirection edge, float scaleFactor) - { - int[] indices = getClosest(edge, vertices); - ((Vertex)vertices.get(indices[0])).xyz.x -= scaleFactor * edge.offsetX; - ((Vertex)vertices.get(indices[1])).xyz.x -= scaleFactor * edge.offsetX; - ((Vertex)vertices.get(indices[0])).xyz.y -= scaleFactor * edge.offsetY; - ((Vertex)vertices.get(indices[1])).xyz.y -= scaleFactor * edge.offsetY; - ((Vertex)vertices.get(indices[0])).xyz.z -= scaleFactor * edge.offsetZ; - ((Vertex)vertices.get(indices[1])).xyz.z -= scaleFactor * edge.offsetZ; - } - - private int[] getClosest(ForgeDirection edge, List vertices) - { - int[] res = { -1, -1 }; - boolean highest = (edge.offsetX > 0) || (edge.offsetY > 0) || (edge.offsetZ > 0); - double minMax = /*highest ? -1.797693134862316E+308D :*/ 1.7976931348623157E+308D; - int index = 0; - for (Vertex v : vertices) - { - double val = get(v.xyz, edge); - if (highest ? val >= minMax : val <= minMax) - { - if (val != minMax) { - res[0] = index; - } else { - res[1] = index; - } - minMax = val; - } - index++; - } - return res; - } - - private double get(Vector3d xyz, ForgeDirection edge) - { - if ((edge == ForgeDirection.EAST) || (edge == ForgeDirection.WEST)) { - return xyz.x; - } - if ((edge == ForgeDirection.UP) || (edge == ForgeDirection.DOWN)) { - return xyz.y; - } - return xyz.z; - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/GasOutput.java b/src/Java/miscutil/enderio/conduit/gas/GasOutput.java deleted file mode 100644 index ff0c699700..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/GasOutput.java +++ /dev/null @@ -1,57 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.util.BlockCoord; - -public class GasOutput -{ - final ForgeDirection dir; - final BlockCoord location; - - public GasOutput(BlockCoord bc, ForgeDirection dir) - { - this.dir = dir; - this.location = bc; - } - - public int hashCode() - { - int prime = 31; - int result = 1; - result = 31 * result + (this.location == null ? 0 : this.location.hashCode()); - result = 31 * result + (this.dir == null ? 0 : this.dir.hashCode()); - return result; - } - - public boolean equals(Object obj) - { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - GasOutput other = (GasOutput)obj; - if (this.location == null) - { - if (other.location != null) { - return false; - } - } - else if (!this.location.equals(other.location)) { - return false; - } - if (this.dir != other.dir) { - return false; - } - return true; - } - - public String toString() - { - return "GasOutput [dir=" + this.dir + ", location=" + this.location + "]"; - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/GasUtil.java b/src/Java/miscutil/enderio/conduit/gas/GasUtil.java deleted file mode 100644 index 7b85ee017b..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/GasUtil.java +++ /dev/null @@ -1,79 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; -import crazypants.enderio.conduit.IConduitBundle; -import crazypants.enderio.config.Config; -import crazypants.util.BlockCoord; - -public final class GasUtil -{ - private static boolean useCheckPerformed = false; - private static boolean isGasConduitEnabled = false; - - public static boolean isGasConduitEnabled() - { - if (!useCheckPerformed) - { - String configOption = Config.isGasConduitEnabled; - if (configOption.equalsIgnoreCase("auto")) - { - isGasConduitEnabled = Loader.isModLoaded("Mekanism"); - if (isGasConduitEnabled) { - isGasConduitEnabled = ((ModContainer)Loader.instance().getIndexedModList().get("Mekanism")).getVersion().startsWith("7"); - } - } - else if (configOption.equalsIgnoreCase("true")) - { - isGasConduitEnabled = true; - } - else - { - isGasConduitEnabled = false; - } - useCheckPerformed = true; - } - return isGasConduitEnabled; - } - - public static IGasHandler getExternalGasHandler(IBlockAccess world, BlockCoord bc) - { - IGasHandler con = getGasHandler(world, bc); - return (con != null) && (!(con instanceof IConduitBundle)) ? con : null; - } - - public static IGasHandler getGasHandler(IBlockAccess world, BlockCoord bc) - { - return getGasHandler(world, bc.x, bc.y, bc.z); - } - - public static IGasHandler getGasHandler(IBlockAccess world, int x, int y, int z) - { - TileEntity te = world.getTileEntity(x, y, z); - return getGasHandler(te); - } - - public static IGasHandler getGasHandler(TileEntity te) - { - if ((te instanceof IGasHandler)) { - return (IGasHandler)te; - } - return null; - } - - public static boolean isGasValid(GasStack gas) - { - if (gas != null) - { - String name = gas.getGas().getLocalizedName(); - if ((name != null) && (!name.trim().isEmpty())) { - return true; - } - } - return false; - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/IGasConduit.java b/src/Java/miscutil/enderio/conduit/gas/IGasConduit.java deleted file mode 100644 index 1f79988a82..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/IGasConduit.java +++ /dev/null @@ -1,14 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import mekanism.api.gas.IGasHandler; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.IExtractor; - -public abstract interface IGasConduit - extends IConduit, IGasHandler, IExtractor -{ - public abstract boolean canOutputToDir(ForgeDirection paramForgeDirection); - - public abstract boolean isExtractingFromDir(ForgeDirection paramForgeDirection); -} diff --git a/src/Java/miscutil/enderio/conduit/gas/ItemGasConduit.java b/src/Java/miscutil/enderio/conduit/gas/ItemGasConduit.java deleted file mode 100644 index 887b0edd28..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/ItemGasConduit.java +++ /dev/null @@ -1,72 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import crazypants.enderio.ModObject; -import crazypants.enderio.conduit.AbstractItemConduit; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.ItemConduitSubtype; -import crazypants.enderio.config.Config; -import crazypants.enderio.gui.IAdvancedTooltipProvider; -import crazypants.enderio.gui.TooltipAddera; -import crazypants.util.Lang; - -public class ItemGasConduit - extends AbstractItemConduit - implements IAdvancedTooltipProvider -{ - private static ItemConduitSubtype[] subtypes = { new ItemConduitSubtype(ModObject.itemGasConduit.name(), "enderio:itemGasConduit") }; - - public static ItemGasConduit create() - { - ItemGasConduit result = new ItemGasConduit(); - if (GasUtil.isGasConduitEnabled()) { - result.init(); - } - return result; - } - - protected ItemGasConduit() - { - super(ModObject.itemGasConduit, subtypes); - if (!GasUtil.isGasConduitEnabled()) { - setCreativeTab(null); - } - } - - public Class getBaseConduitType() - { - return IGasConduit.class; - } - - public IConduit createConduit(ItemStack stack, EntityPlayer player) - { - return new GasConduit(); - } - - @SideOnly(Side.CLIENT) - public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {} - - @SideOnly(Side.CLIENT) - public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {} - - @SideOnly(Side.CLIENT) - public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - String gpt = " " + Lang.localize("gas.gasTick"); - int extractRate = Config.gasConduitExtractRate; - int maxIo = Config.gasConduitMaxIoRate; - list.add(Lang.localize("itemGasConduit.tooltip.maxExtract") + " " + extractRate + gpt); - list.add(Lang.localize("itemGasConduit.tooltip.maxIo") + " " + maxIo + gpt); - TooltipAddera.addDetailedTooltipFromResources(list, "enderio.itemGasConduit"); - } - - public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) - { - return true; - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/PacketGasLevel.java b/src/Java/miscutil/enderio/conduit/gas/PacketGasLevel.java deleted file mode 100644 index a7f90f67a4..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/PacketGasLevel.java +++ /dev/null @@ -1,44 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import io.netty.buffer.ByteBuf; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.common.network.ByteBufUtils; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import crazypants.enderio.network.MessageTileEntity; - -public class PacketGasLevel - extends MessageTileEntity - implements IMessageHandler -{ - public NBTTagCompound tc; - - public PacketGasLevel() {} - - public PacketGasLevel(IGasConduit conduit) - { - super(conduit.getBundle().getEntity()); - this.tc = new NBTTagCompound(); - conduit.writeToNBT(this.tc); - } - - public void toBytes(ByteBuf buf) - { - super.toBytes(buf); - ByteBufUtils.writeTag(buf, this.tc); - } - - public void fromBytes(ByteBuf buf) - { - super.fromBytes(buf); - this.tc = ByteBufUtils.readTag(buf); - } - - public IMessage onMessage(PacketGasLevel message, MessageContext ctx) - { - //ClientUtil.doGasLevelUpdate(message.x, message.y, message.z, message); - return null; - } -} diff --git a/src/Java/miscutil/gregtech/enums/MaterialsNew.java b/src/Java/miscutil/gregtech/enums/MaterialsNew.java new file mode 100644 index 0000000000..ae3ed019cd --- /dev/null +++ b/src/Java/miscutil/gregtech/enums/MaterialsNew.java @@ -0,0 +1,44 @@ +package miscutil.gregtech.enums; + +import miscutil.core.util.reflection.EnumBuster; + + +public class MaterialsNew { + + EnumBuster EB = new EnumBuster(null, null); +/* + public static void getGregMaterials() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, SecurityException{ + Utils.LOG_WARNING("Stepping through the process of Greg's materials."); + + Constructor con = Materials.class.getDeclaredConstructors()[0]; + Utils.LOG_WARNING("Logging Value for Variable "+"Constructor"+":"+con.getName()); + java.lang.reflect.Method[] methods = con.getClass().getDeclaredMethods(); + Utils.LOG_WARNING("Logging Value for Variable "+"methods"+":"+methods.toString()); + for (java.lang.reflect.Method m1 : methods) { + Utils.LOG_WARNING("Logging Value for Variable "+"m1"+":"+m1.getName()+"| Accessible? "+m1.isAccessible()); + if (m1.getName().equals("acquireConstructorAccessor")) { + Utils.LOG_WARNING("Logging Value for Variable "+"m1"+":"+m1.getName()+"| Accessible? "+m1.isAccessible()); + m1.setAccessible(true); + Utils.LOG_WARNING("Logging Value for Variable "+"m1"+":"+m1.toGenericString()); + m1.invoke(con, new Object[0]);} + } + Field[] fields = con.getClass().getDeclaredFields(); + Utils.LOG_WARNING("Logging Value for Variable "+"fields"+":"+fields.toString()+"|"+fields.getClass()); + Object ca = null; + for (Field f : fields) { + Utils.LOG_WARNING("Logging Value for Variable "+"f"+":"+f.getName()+"|"+f.getModifiers()+"|"+f.isAccessible()); + if (f.getName().equals("constructorAccessor")) { + Utils.LOG_WARNING("Logging Value for Variable "+"f"+":"+f.isAccessible()); + f.setAccessible(true); + ca = f.get(con); + Utils.LOG_WARNING("Logging Value for Variable "+"ca"+":"+ca.toString()+"|"+ca.getClass()); + } + } + Method m = ca.getClass().getMethod( "newInstance", new Class[] { Object[].class }); + Utils.LOG_WARNING("Logging Value for Variable "+"m"+":"+m.getModifiers()+"|"+m.getName()+"|"+m.toGenericString()+"|"+m.isAccessible()); + m.setAccessible(true); + Materials v = (Materials) m.invoke(ca, new Object[] { new Object[] { "NEWMATERIAL", Integer.MAX_VALUE } }); + System.out.println(v.getClass() + ":" + v.name() + ":" + v.ordinal()); + +}*/ +} diff --git a/src/Java/miscutil/gregtech/gui/CONTAINER_SteamCondenser.java b/src/Java/miscutil/gregtech/gui/CONTAINER_SteamCondenser.java new file mode 100644 index 0000000000..c466839c9d --- /dev/null +++ b/src/Java/miscutil/gregtech/gui/CONTAINER_SteamCondenser.java @@ -0,0 +1,92 @@ +package miscutil.gregtech.gui; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import java.util.Iterator; + +import miscutil.gregtech.metatileentity.implementations.base.GregtechMetaBoilerBase; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CONTAINER_SteamCondenser extends GT_ContainerMetaTile_Machine +{ + public CONTAINER_SteamCondenser(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aSteamCapacity) + { + super(aInventoryPlayer, aTileEntity); + this.mSteamCapacity = aSteamCapacity; + } + + public void addSlots(InventoryPlayer aInventoryPlayer) + { + addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); + } + + public int getSlotCount() + { + return 4; + } + + public int getShiftClickSlotCount() + { + return 1; + } + + public int mWaterAmount = 0; + public int mSteamAmount = 0; + public int mProcessingEnergy = 0; + public int mTemperature = 2; + private final int mSteamCapacity; + public long mTickingTime = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).RI; + + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + this.mTemperature = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mTemperature; + this.mProcessingEnergy = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; + this.mSteamAmount = (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mSteam == null ? 0 : ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mSteam.amount); + this.mWaterAmount = (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mFluid == null ? 0 : ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mFluid.amount); + this.mTickingTime = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).RI; + + this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); + this.mSteamAmount = Math.min(54, Math.max(0, this.mSteamAmount * 54 / (this.mSteamCapacity - 100))); + this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterAmount * 54 / 15900)); + this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, this.mProcessingEnergy * 14 / 1000)); + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) + { + ICrafting var1 = (ICrafting)var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mTemperature); + var1.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); + var1.sendProgressBarUpdate(this, 102, this.mSteamAmount); + var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) + { + super.updateProgressBar(par1, par2); + switch (par1) + { + case 100: + this.mTemperature = par2; break; + case 101: + this.mProcessingEnergy = par2; break; + case 102: + this.mSteamAmount = par2; break; + case 103: + this.mWaterAmount = par2; + } + } +} \ No newline at end of file diff --git a/src/Java/miscutil/gregtech/gui/GUI_SteamCondenser.java b/src/Java/miscutil/gregtech/gui/GUI_SteamCondenser.java new file mode 100644 index 0000000000..f758e5c693 --- /dev/null +++ b/src/Java/miscutil/gregtech/gui/GUI_SteamCondenser.java @@ -0,0 +1,53 @@ +package miscutil.gregtech.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import miscutil.core.lib.Strings; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_SteamCondenser extends GT_GUIContainerMetaTile_Machine +{ + long tickTime = 0; + + public GUI_SteamCondenser(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aTextureName, int aSteamCapacity) + { + super(new CONTAINER_SteamCondenser(aInventoryPlayer, aTileEntity, aSteamCapacity), Strings.MODID + ":" + "textures/gui/" + aTextureName); + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + this.fontRendererObj.drawString("Condenser", 8, 4, 4210752); + if (!Strings.DEBUG){ + tickTime = ((CONTAINER_SteamCondenser)this.mContainer).mTickingTime; + this.fontRendererObj.drawString("Tick Time: "+tickTime, 8, 12, 4210752); + } + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) + { + + int tScale = ((CONTAINER_SteamCondenser)this.mContainer).mSteamAmount; + if (tScale > 0) { + drawTexturedModalRect(x + 70, y + 25 + 54 - tScale, 194, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser)this.mContainer).mWaterAmount; + if (tScale > 0) { + drawTexturedModalRect(x + 83, y + 25 + 54 - tScale, 204, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser)this.mContainer).mTemperature; + if (tScale > 0) { + drawTexturedModalRect(x + 96, y + 25 + 54 - tScale, 214, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser)this.mContainer).mProcessingEnergy; + if (tScale > 0) { + drawTexturedModalRect(x + 115, y + 44 + 2/* - tScale*/, 177, 14 - tScale, 15, 1+tScale); + } + } + } +} \ No newline at end of file diff --git a/src/Java/miscutil/gregtech/init/machines/GregtechCobbleGenerator.java b/src/Java/miscutil/gregtech/init/machines/GregtechCobbleGenerator.java index 79e70e0625..306f4f45f1 100644 --- a/src/Java/miscutil/gregtech/init/machines/GregtechCobbleGenerator.java +++ b/src/Java/miscutil/gregtech/init/machines/GregtechCobbleGenerator.java @@ -6,7 +6,7 @@ import gregtech.api.enums.OreDictNames; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import miscutil.gregtech.enums.GregtechItemList; -import miscutil.gregtech.metatileentity.implementations.GregtechSteelBoiler; +import miscutil.gregtech.metatileentity.implementations.base.GregtechSteelBoiler; import cpw.mods.fml.common.FMLLog; public class GregtechCobbleGenerator diff --git a/src/Java/miscutil/gregtech/init/machines/GregtechSteamCondenser.java b/src/Java/miscutil/gregtech/init/machines/GregtechSteamCondenser.java new file mode 100644 index 0000000000..767321de7b --- /dev/null +++ b/src/Java/miscutil/gregtech/init/machines/GregtechSteamCondenser.java @@ -0,0 +1,36 @@ +package miscutil.gregtech.init.machines; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import miscutil.core.util.Utils; +import miscutil.gregtech.enums.GregtechItemList; +import miscutil.gregtech.metatileentity.implementations.GregtechMetaCondensor; + +public class GregtechSteamCondenser +{ + + + + public static void run() + { + if (miscutil.core.lib.LoadedMods.Gregtech){ + Utils.LOG_INFO("MiscUtils: Gregtech5u Content | Registering Steam Condensor."); + run1(); + } + + } + + private static void run1() + { + //Steam Condensors + GregtechItemList.Condensor_MAX.set(new GregtechMetaCondensor(780, "steamcondensor.01.tier.single", "Steam Condensor").getStackForm(1L)); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Condensor_MAX.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('W'),OrePrefixes.wireGt04.get(Materials.Nickel),Character.valueOf('T'), ItemList.Pump_MV }); + /*Steam Condensors + GregtechItemList.Condensor_MAX.set(new GregtechMetaCondensorII(780, "steamcondensor.01.tier.single", "Steam CondensorII").getStackForm(1L)); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Condensor_MAX.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('W'),OrePrefixes.wireGt04.get(Materials.Nickel),Character.valueOf('T'), ItemList.Pump_MV }); + */ + + } +} diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java new file mode 100644 index 0000000000..9a0baf38f6 --- /dev/null +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java @@ -0,0 +1,164 @@ +package miscutil.gregtech.metatileentity.implementations; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import miscutil.core.util.Utils; +import miscutil.gregtech.gui.CONTAINER_SteamCondenser; +import miscutil.gregtech.gui.GUI_SteamCondenser; +import miscutil.gregtech.metatileentity.implementations.base.GregtechMetaBoilerBase; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +public class GregtechMetaCondensor extends GregtechMetaBoilerBase{ + + public GregtechMetaCondensor(int aID, String aName, String aNameRegional) + { + super(aID, aName, aNameRegional, "A Steam condenser - [IC2->Steam]", new ITexture[0]); + } + + public GregtechMetaCondensor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) + { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {mDescription, "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus"}; + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) + { + ITexture[][][] rTextures = new ITexture[5][17][]; + for (byte i = -1; i < 16; i++){ + rTextures[0][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa))}; + rTextures[1][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; + rTextures[2][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; + rTextures[3][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB) }; + rTextures[4][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE) }; + } + return rTextures; + } + + public int maxProgresstime() + { + return 1000; + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new CONTAINER_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, 32000); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new GUI_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GregtechMetaCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) + { + this.RI = Utils.randLong(5L, 30L); + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) + { + if (this.mTemperature <= 5) + { + this.mTemperature = 5; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 10) + { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) + { + IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) + { + FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) + { + int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + } + if (aTick % 10L == 0L) { + if (this.mTemperature > 5) + { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) + { + this.mHadNoWater = true; + } + else + { + if (this.mHadNoWater) + { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(30L); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 30; + } else { + this.mSteam = GT_ModHandler.getSteam(30L); + } + } + } + else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && + (this.mSteam.amount > 32000)) + { + sendSound((byte)1); + this.mSteam.amount = 24000; + } + /*if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && + (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(IC2.getItemFromBlock(p_150898_0_))))) + { + this.mProcessingEnergy += 1000; + aBaseMetaTileEntity.decrStackSize(2, 1); + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); + }*/ + if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % RI == 0L)) + { + this.mProcessingEnergy -= 40; + this.mTemperature += 2; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + + public final int fill(FluidStack aFluid, boolean doFill) + { + if ((Utils.isIC2Steam(aFluid)) && (this.mProcessingEnergy < 50)) + { + int tFilledAmount = Math.min(50, aFluid.amount); + if (doFill) { + this.mProcessingEnergy += tFilledAmount; + } + return tFilledAmount; + } + return super.fill(aFluid, doFill); + } +} diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaEnergyBuffer.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaEnergyBuffer.java index 7f70b7bff6..7d6a8b61bd 100644 --- a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaEnergyBuffer.java +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaEnergyBuffer.java @@ -24,6 +24,7 @@ import java.util.List; import miscutil.core.handler.GuiHandler; import miscutil.core.util.Utils; import miscutil.core.waila.IWailaInfoProvider; +import miscutil.gregtech.metatileentity.implementations.base.GregtechMetaTileEntity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaTileEntity.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaTileEntity.java deleted file mode 100644 index 669786c423..0000000000 --- a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaTileEntity.java +++ /dev/null @@ -1,66 +0,0 @@ -package miscutil.gregtech.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.GT; -import gregtech.api.interfaces.ITexture; -import gregtech.api.metatileentity.MetaTileEntity; - -public abstract class GregtechMetaTileEntity extends MetaTileEntity { - /** - * Value between [0 - 9] to describe the Tier of this Machine. - */ - public final byte mTier; - - /** - * A simple Description. - */ - public final String mDescription; - - /** - * Contains all Textures used by this Block. - */ - public final ITexture[][][] mTextures; - - public GregtechMetaTileEntity(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aInvSlotCount); - mTier = (byte)Math.max(0, Math.min(aTier, 9)); - mDescription = aDescription; - - // must always be the last call! - if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null; - } - - public GregtechMetaTileEntity(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aInvSlotCount); - mTier = (byte)aTier; - mDescription = aDescription; - mTextures = aTextures; - - } - - @Override - public byte getTileEntityBaseType() { - return (byte)(Math.min(3, mTier<=0?0:1+((mTier-1) / 4))); - } - - @Override - public long getInputTier() { - return mTier; - } - - @Override - public long getOutputTier() { - return mTier; - } - - @Override - public String[] getDescription() { - return new String[] {mDescription}; - } - - /** - * Used Client Side to get a Texture Set for this Block. - * Called after setting the Tier and the Description so that those two are accessible. - * @param aTextures is the optional Array you can give to the Constructor. - */ - public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); -} \ No newline at end of file diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechSteelBoiler.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechSteelBoiler.java deleted file mode 100644 index 45b6fa5f86..0000000000 --- a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechSteelBoiler.java +++ /dev/null @@ -1,290 +0,0 @@ -package miscutil.gregtech.metatileentity.implementations; - -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.common.gui.GT_Container_Boiler; -import gregtech.common.gui.GT_GUIContainer_Boiler; -import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; - -public class GregtechSteelBoiler - extends GT_MetaTileEntity_Boiler -{ - public GregtechSteelBoiler(int aID, String aName, String aNameRegional, int aTier, String aDescription) - { - super(aID, aName, aNameRegional, "Put it to good use!", new ITexture[0]); - } - - public GregtechSteelBoiler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) - { - super(aName, aTier, aDescription, aTextures); - } - - public ITexture[][][] getTextureSet(ITexture[] aTextures) - { - ITexture[][][] rTextures = new ITexture[5][17][]; - for (byte i = -1; i < 16; i = (byte)(i + 1)) - {ITexture[] tmp0 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa)) }; - rTextures[0][(i + 1)] = tmp0; - ITexture[] tmp1 ={ new GT_RenderedTexture(Textures.BlockIcons.STEAM_TURBINE_SIDE)}; -rTextures[1][(i + 1)] = tmp1; - ITexture[] tmp2 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; -rTextures[2][(i + 1)] = tmp2; - ITexture[] tmp4 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; -rTextures[3][(i + 1)] = tmp4; - ITexture[] tmp5 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; -rTextures[4][(i + 1)] = tmp5; - } - return rTextures; - } - - public int maxProgresstime() - { - return 1000; - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) - { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 32000); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) - { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) - { - return new GregtechSteelBoiler(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) - { - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) - { - if (this.mTemperature <= 20) - { - this.mTemperature = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 40) - { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { - if (i != aBaseMetaTileEntity.getFrontFacing()) - { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) - { - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) - { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - } - if (aTick % 10L == 0L) { - if (this.mTemperature > 100) - { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) - { - this.mHadNoWater = true; - } - else - { - if (this.mHadNoWater) - { - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(150L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 150; - } else { - this.mSteam = GT_ModHandler.getSteam(150L); - } - } - } - else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > 32000)) - { - sendSound((byte)1); - this.mSteam.amount = 24000; - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (this.mInventory[2] != null)) { - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal)))) - { - this.mProcessingEnergy += 160; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); - } - } - else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Charcoal)))) - { - this.mProcessingEnergy += 160; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); - } - } - else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) - { - this.mProcessingEnergy += 640; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(2) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); - } - } - else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite)))) - { - this.mProcessingEnergy += 40; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(8) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); - } - } - } - if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) - { - this.mProcessingEnergy -= 2; - this.mTemperature += 1; - } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); - } - } - -@Override -public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - // TODO Auto-generated method stub - return null; -} - -@Override -public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, - int p_102007_3_) { - // TODO Auto-generated method stub - return false; -} - -@Override -public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, - int p_102008_3_) { - // TODO Auto-generated method stub - return false; -} - -@Override -public int getSizeInventory() { - // TODO Auto-generated method stub - return 0; -} - -@Override -public ItemStack getStackInSlot(int p_70301_1_) { - // TODO Auto-generated method stub - return null; -} - -@Override -public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { - // TODO Auto-generated method stub - return null; -} - -@Override -public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - // TODO Auto-generated method stub - return null; -} - -@Override -public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - // TODO Auto-generated method stub - -} - -@Override -public String getInventoryName() { - // TODO Auto-generated method stub - return null; -} - -@Override -public boolean hasCustomInventoryName() { - // TODO Auto-generated method stub - return false; -} - -@Override -public int getInventoryStackLimit() { - // TODO Auto-generated method stub - return 0; -} - -@Override -public void markDirty() { - // TODO Auto-generated method stub - -} - -@Override -public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - // TODO Auto-generated method stub - return false; -} - -@Override -public void openInventory() { - // TODO Auto-generated method stub - -} - -@Override -public void closeInventory() { - // TODO Auto-generated method stub - -} - -@Override -public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - // TODO Auto-generated method stub - return false; -} -} - - - -/* Location: F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar - - * Qualified Name: gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler_Steel - - * JD-Core Version: 0.7.0.1 - - */ \ No newline at end of file diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaBoilerBase.java b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaBoilerBase.java new file mode 100644 index 0000000000..553740d28a --- /dev/null +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaBoilerBase.java @@ -0,0 +1,328 @@ +package miscutil.gregtech.metatileentity.implementations.base; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import miscutil.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +public abstract class GregtechMetaBoilerBase extends GT_MetaTileEntity_BasicTank +{ + public int mTemperature = 20; + public int mProcessingEnergy = 0; + public int mLossTimer = 0; + public FluidStack mSteam = null; + public boolean mHadNoWater = false; + public long RI = Utils.randLong(5L, 30L); + + public GregtechMetaBoilerBase(int aID, String aName, String aNameRegional, String aDescription, ITexture... aTextures) + { + super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); + } + + public GregtechMetaBoilerBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) + { + super(aName, aTier, 4, aDescription, aTextures); + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) + { + ITexture[] tmp = mTextures[aSide >= 2 ? aSide != aFacing ? 2 : ((byte)(aActive ? 4 : 3)) : aSide][aColorIndex + 1]; + //mTextures[(aSide==aFacing?(aActive?4:3):aSide==GT_Utility.getOppositeSide(aFacing)?2:aSide==0?0:aSide==1?1:2)][aColorIndex+1]; + if(aSide!=aFacing&&tmp.length==2){ + tmp = new ITexture[]{tmp[0]}; + } + return tmp; + } + + public boolean isElectric() + { + return false; + } + + public boolean isPneumatic() + { + return false; + } + + public boolean isSteampowered() + { + return false; + } + + public boolean isSimpleMachine() + { + return false; + } + + public boolean isFacingValid(byte aFacing) + { + return aFacing > 1; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) + { + return true; + } + + public boolean isValidSlot(int aIndex) + { + return true; + } + + public int getProgresstime() + { + return this.mTemperature; + } + + public int maxProgresstime() + { + return 500; + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) + { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + if (aPlayer != null) { + if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1))) + { + fill(Materials.Water.getFluid(1000 * aPlayer.getCurrentEquippedItem().stackSize), true); + aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket); + } + else + { + aBaseMetaTileEntity.openGUI(aPlayer); + } + } + return true; + } + + public boolean doesFillContainers() + { + return true; + } + + public boolean doesEmptyContainers() + { + return true; + } + + public boolean canTankBeFilled() + { + return true; + } + + public boolean canTankBeEmptied() + { + return true; + } + + public boolean displaysItemStack() + { + return false; + } + + public boolean displaysStackSize() + { + return false; + } + + public boolean isFluidInputAllowed(FluidStack aFluid) + { + return GT_ModHandler.isWater(aFluid); + } + + public FluidStack getDrainableStack() + { + return this.mSteam; + } + + public FluidStack setDrainableStack(FluidStack aFluid) + { + this.mSteam = aFluid;return this.mSteam; + } + + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) + { + return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover(); + } + + public void saveNBTData(NBTTagCompound aNBT) + { + super.saveNBTData(aNBT); + aNBT.setInteger("mLossTimer", this.mLossTimer); + aNBT.setInteger("mTemperature", this.mTemperature); + aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy); + if (this.mSteam != null) { + try + { + aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound())); + } + catch (Throwable e) {} + } + } + + public void loadNBTData(NBTTagCompound aNBT) + { + super.loadNBTData(aNBT); + this.mLossTimer = aNBT.getInteger("mLossTimer"); + this.mTemperature = aNBT.getInteger("mTemperature"); + this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy"); + this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam")); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) + { + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) + { + if (this.mTemperature <= 20) + { + this.mTemperature = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 40) + { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) + { + IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) + { + FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) + { + int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + } + if (aTick % 10L == 0L) { + if (this.mTemperature > 100) + { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) + { + this.mHadNoWater = true; + } + else + { + if (this.mHadNoWater) + { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(150L); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 150; + } else { + this.mSteam = GT_ModHandler.getSteam(150L); + } + } + } + else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && + (this.mSteam.amount > 32000)) + { + sendSound((byte)1); + this.mSteam.amount = 24000; + } + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && + (this.mInventory[2] != null)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal)))) + { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal))) + { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } + else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) + { + this.mProcessingEnergy += 640; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(2) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } + else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite)))) + { + this.mProcessingEnergy += 40; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(8) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + } + if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) + { + this.mProcessingEnergy -= 2; + this.mTemperature += 1; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) + { + return (aIndex == 1) || (aIndex == 3); + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) + { + return aIndex == 2; + } + + public void doSound(byte aIndex, double aX, double aY, double aZ) + { + if (aIndex == 1) + { + GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(Integer.valueOf(4)), 2, 1.0F, aX, aY, aZ); + for (int l = 0; l < 8; l++) { + getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5D + Math.random(), aY, aZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + } + } + } + + public int getCapacity() + { + return 16000; + } + + public int getTankPressure() + { + return 100; + } +} diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaTileEntity.java b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaTileEntity.java new file mode 100644 index 0000000000..bc3d2f4967 --- /dev/null +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaTileEntity.java @@ -0,0 +1,67 @@ +package miscutil.gregtech.metatileentity.implementations.base; + +import static gregtech.api.enums.GT_Values.GT; +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.MetaTileEntity; +import net.minecraft.util.EnumChatFormatting; + +public abstract class GregtechMetaTileEntity extends MetaTileEntity { + /** + * Value between [0 - 9] to describe the Tier of this Machine. + */ + public final byte mTier; + + /** + * A simple Description. + */ + public final String mDescription; + + /** + * Contains all Textures used by this Block. + */ + public final ITexture[][][] mTextures; + + public GregtechMetaTileEntity(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aInvSlotCount); + mTier = (byte)Math.max(0, Math.min(aTier, 9)); + mDescription = aDescription; + + // must always be the last call! + if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null; + } + + public GregtechMetaTileEntity(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aInvSlotCount); + mTier = (byte)aTier; + mDescription = aDescription; + mTextures = aTextures; + + } + + @Override + public byte getTileEntityBaseType() { + return (byte)(Math.min(3, mTier<=0?0:1+((mTier-1) / 4))); + } + + @Override + public long getInputTier() { + return mTier; + } + + @Override + public long getOutputTier() { + return mTier; + } + + @Override + public String[] getDescription() { + return new String[] {mDescription, "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus"}; + } + + /** + * Used Client Side to get a Texture Set for this Block. + * Called after setting the Tier and the Description so that those two are accessible. + * @param aTextures is the optional Array you can give to the Constructor. + */ + public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); +} \ No newline at end of file diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechSteelBoiler.java b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechSteelBoiler.java new file mode 100644 index 0000000000..511cb0e8df --- /dev/null +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechSteelBoiler.java @@ -0,0 +1,290 @@ +package miscutil.gregtech.metatileentity.implementations.base; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.gui.GT_Container_Boiler; +import gregtech.common.gui.GT_GUIContainer_Boiler; +import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +public class GregtechSteelBoiler + extends GT_MetaTileEntity_Boiler +{ + public GregtechSteelBoiler(int aID, String aName, String aNameRegional, int aTier, String aDescription) + { + super(aID, aName, aNameRegional, "Put it to good use!", new ITexture[0]); + } + + public GregtechSteelBoiler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) + { + super(aName, aTier, aDescription, aTextures); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) + { + ITexture[][][] rTextures = new ITexture[5][17][]; + for (byte i = -1; i < 16; i = (byte)(i + 1)) + {ITexture[] tmp0 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa)) }; + rTextures[0][(i + 1)] = tmp0; + ITexture[] tmp1 ={ new GT_RenderedTexture(Textures.BlockIcons.STEAM_TURBINE_SIDE)}; +rTextures[1][(i + 1)] = tmp1; + ITexture[] tmp2 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; +rTextures[2][(i + 1)] = tmp2; + ITexture[] tmp4 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; +rTextures[3][(i + 1)] = tmp4; + ITexture[] tmp5 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; +rTextures[4][(i + 1)] = tmp5; + } + return rTextures; + } + + public int maxProgresstime() + { + return 1000; + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 32000); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GregtechSteelBoiler(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) + { + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) + { + if (this.mTemperature <= 20) + { + this.mTemperature = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 40) + { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) + { + IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) + { + FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) + { + int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + } + if (aTick % 10L == 0L) { + if (this.mTemperature > 100) + { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) + { + this.mHadNoWater = true; + } + else + { + if (this.mHadNoWater) + { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(150L); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 150; + } else { + this.mSteam = GT_ModHandler.getSteam(150L); + } + } + } + else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && + (this.mSteam.amount > 32000)) + { + sendSound((byte)1); + this.mSteam.amount = 24000; + } + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && + (this.mInventory[2] != null)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal)))) + { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Charcoal)))) + { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } + else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) + { + this.mProcessingEnergy += 640; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(2) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } + else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite)))) + { + this.mProcessingEnergy += 40; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(8) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + } + if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) + { + this.mProcessingEnergy -= 2; + this.mTemperature += 1; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + +@Override +public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + // TODO Auto-generated method stub + return null; +} + +@Override +public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, + int p_102007_3_) { + // TODO Auto-generated method stub + return false; +} + +@Override +public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, + int p_102008_3_) { + // TODO Auto-generated method stub + return false; +} + +@Override +public int getSizeInventory() { + // TODO Auto-generated method stub + return 0; +} + +@Override +public ItemStack getStackInSlot(int p_70301_1_) { + // TODO Auto-generated method stub + return null; +} + +@Override +public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + // TODO Auto-generated method stub + return null; +} + +@Override +public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + // TODO Auto-generated method stub + return null; +} + +@Override +public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + // TODO Auto-generated method stub + +} + +@Override +public String getInventoryName() { + // TODO Auto-generated method stub + return null; +} + +@Override +public boolean hasCustomInventoryName() { + // TODO Auto-generated method stub + return false; +} + +@Override +public int getInventoryStackLimit() { + // TODO Auto-generated method stub + return 0; +} + +@Override +public void markDirty() { + // TODO Auto-generated method stub + +} + +@Override +public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + // TODO Auto-generated method stub + return false; +} + +@Override +public void openInventory() { + // TODO Auto-generated method stub + +} + +@Override +public void closeInventory() { + // TODO Auto-generated method stub + +} + +@Override +public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + // TODO Auto-generated method stub + return false; +} +} + + + +/* Location: F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar + + * Qualified Name: gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler_Steel + + * JD-Core Version: 0.7.0.1 + + */ \ No newline at end of file diff --git a/src/Java/miscutil/gregtech/objects/GregMaterialStack.java b/src/Java/miscutil/gregtech/objects/GregMaterialStack.java deleted file mode 100644 index 2be3341ad9..0000000000 --- a/src/Java/miscutil/gregtech/objects/GregMaterialStack.java +++ /dev/null @@ -1,42 +0,0 @@ -package miscutil.gregtech.objects; - -import miscutil.gregtech.enums.Materials2; - - -public class GregMaterialStack implements Cloneable { - public long mAmount; - public Materials2 mMaterial; - - public GregMaterialStack(Materials2 nitrogen, long aAmount) { - mMaterial = nitrogen==null?Materials2._NULL:nitrogen; - mAmount = aAmount; - } - - public GregMaterialStack copy(long aAmount) { - return new GregMaterialStack(mMaterial, aAmount); - } - - @Override - public GregMaterialStack clone() { - return new GregMaterialStack(mMaterial, mAmount); - } - - @Override - public boolean equals(Object aObject) { - if (aObject == this) return true; - if (aObject == null) return false; - if (aObject instanceof Materials2) return aObject == mMaterial; - if (aObject instanceof GregMaterialStack) return ((GregMaterialStack)aObject).mMaterial == mMaterial && (mAmount < 0 || ((GregMaterialStack)aObject).mAmount < 0 || ((GregMaterialStack)aObject).mAmount == mAmount); - return false; - } - - @Override - public String toString() { - return (mMaterial.mMaterialList.size() > 1 && mAmount > 1 ? "(" : "") + mMaterial.getToolTip(true) + (mMaterial.mMaterialList.size() > 1 && mAmount > 1 ? ")" : "") + (mAmount > 1 ? mAmount : ""); - } - - @Override - public int hashCode() { - return mMaterial.hashCode(); - } -} \ No newline at end of file diff --git a/src/Java/miscutil/mcmod.info b/src/Java/miscutil/mcmod.info index 0c2b859007..85720427ff 100644 --- a/src/Java/miscutil/mcmod.info +++ b/src/Java/miscutil/mcmod.info @@ -6,7 +6,7 @@ [ { "modid" : "miscutils" , "name" : "miscutils" , "description" : "Adds a few various things. Supported mods include GregTech, EnderIO, Big Reactors, Thaumcraft, ExtraUtils, Pnuematicraft & Simply Jetpacks." - , "version" : "0.7.8gtu" + , "version" : "0.9.2-gtu" , "mcversion" : "1.7.10" , "url" : "" , "updateUrl" : "" -- cgit