From c863c73e498fa083f216465b1f2f9d86d0d60248 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Tue, 4 Oct 2016 19:57:33 +1000 Subject: + Added the last of my dependencies. + Bumped version in CORE.java - Removed some Gradle files that aren't required. - Removed some Deobf libs and gregtech/api/metatileentity/implementations/GregtechMetaBasicTank.java. --- .../implementations/GregtechMetaBasicTank.java | 261 --------------------- 1 file changed, 261 deletions(-) delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaBasicTank.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaBasicTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaBasicTank.java deleted file mode 100644 index c199114daa..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaBasicTank.java +++ /dev/null @@ -1,261 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.ItemList; -import gregtech.api.gui.GT_Container_BasicTank; -import gregtech.api.gui.GT_GUIContainer_BasicTank; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually - */ -public abstract class GregtechMetaBasicTank extends GregtechMetaTieredMachineBlock { - - public FluidStack mFluid; - public FluidStack mInternal; - /** - * @param aInvSlotCount should be 3 - */ - public GregtechMetaBasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GregtechMetaBasicTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex != getStackDisplaySlot(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - } - - public abstract boolean doesFillContainers(); - - public abstract boolean doesEmptyContainers(); - - public abstract boolean canTankBeFilled(); - - public abstract boolean canTankBeEmptied(); - - public abstract boolean displaysItemStack(); - - public abstract boolean displaysStackSize(); - - public int getInputSlot() { - return 0; - } - - public int getOutputSlot() { - return 1; - } - - public int getStackDisplaySlot() { - return 2; - } - - public boolean isFluidInputAllowed(FluidStack aFluid) { - return true; - } - - public boolean isFluidChangingAllowed() { - return true; - } - - public FluidStack getFillableStack() { - return mFluid; - } - - public FluidStack setFillableStack(FluidStack aFluid) { - mFluid = aFluid; - return mFluid; - } - - public FluidStack setInternalStack(FluidStack aFluid) { - mInternal = aFluid; - return mInternal; - } - - public FluidStack getInternalStack() { - return mInternal; - } - - public FluidStack getDrainableStack() { - return mFluid; - } - - public FluidStack setDrainableStack(FluidStack aFluid) { - mFluid = aFluid; - return mFluid; - } - - public FluidStack getDisplayedFluid() { - return getDrainableStack(); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) - setFillableStack(null); - if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount >= 1) - setInternalStack(getFillableStack()); - if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { - if (getDisplayedFluid() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) - mInventory[getStackDisplaySlot()] = null; - } else { - mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); - } - } - - if (doesEmptyContainers()) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); - if (tFluid != null && isFluidInputAllowed(tFluid)) { - if (getFillableStack() == null) { - if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - setFillableStack(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } else { - if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - getFillableStack().amount += tFluid.amount; - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } - } - } - - if (doesFillContainers()) { - ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); - if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - if (tFluid != null) getDrainableStack().amount -= tFluid.amount; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); - } - } - } - } - - @Override - public FluidStack getFluid() { - return getDrainableStack(); - } - - @Override - public int getFluidAmount() { - return getDrainableStack() != null ? getDrainableStack().amount : 0; - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) - return 0; - - if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { - if (aFluid.amount <= getCapacity()) { - if (doFill) { - setFillableStack(aFluid.copy()); - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - setFillableStack(aFluid.copy()); - getFillableStack().amount = getCapacity(); - getBaseMetaTileEntity().markDirty(); - } - return getCapacity(); - } - - if (!getFillableStack().isFluidEqual(aFluid)) - return 0; - - int space = getCapacity() - getFillableStack().amount; - if (aFluid.amount <= space) { - if (doFill) { - getFillableStack().amount += aFluid.amount; - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) - getFillableStack().amount = getCapacity(); - return space; - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - if (getDrainableStack() == null || !canTankBeEmptied()) return null; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - return null; - } - - int used = maxDrain; - if (getDrainableStack().amount < used) - used = getDrainableStack().amount; - - if (doDrain) { - getDrainableStack().amount -= used; - getBaseMetaTileEntity().markDirty(); - } - - FluidStack drained = getDrainableStack().copy(); - drained.amount = used; - - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - } - - return drained; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == getOutputSlot(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == getInputSlot(); - } -} \ No newline at end of file -- cgit From 0ca4f1177cd2e5ee6bd2be38f6d0f2a60e143e33 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Tue, 4 Oct 2016 20:54:10 +1000 Subject: $ Fixed a client crashing bug where aspects didn't register properly due to the changes I made in AspectStack handling. % Changed how logging is done for cable reflection tasks. --- .classpath | 2 +- src/Java/gtPlusPlus/core/util/Utils.java | 49 ++++++++++++++++------ .../base/GregtechMetaPipeEntityBase_Cable.java | 10 +++-- 3 files changed, 44 insertions(+), 17 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/.classpath b/.classpath index f64ee72b03..37602a4409 100644 --- a/.classpath +++ b/.classpath @@ -13,6 +13,6 @@ - + diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 090d05e3b1..bee5de98ea 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -44,6 +44,9 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; + +import org.apache.commons.lang3.EnumUtils; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.registry.EntityRegistry; @@ -90,32 +93,52 @@ public class Utils { if (aspect.toUpperCase() == "COGNITIO"){ //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "COGNITIO")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); - + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } } else if (aspect.toUpperCase() == "EXANIMUS"){ - //Adds in Compat for older GT Versions which Misspell aspects. + //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "EXANIMUS")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } + + } else if (aspect.toUpperCase() == "PRAECANTATIO"){ - //Adds in Compat for older GT Versions which Misspell aspects. + //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "PRAECANTATIO")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); - } + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } } else { + Utils.LOG_WARNING("TC Aspect found - "+aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java index 585987797c..e9947464be 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java @@ -16,6 +16,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Proxy; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; @@ -71,13 +72,14 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements } private int getGT5Var(){ - Class clazz = GT_Mod.gregtechproxy.getClass(); + Class clazz = GT_Mod.gregtechproxy.getClass(); String lookingForValue = "mWireHeatingTicks"; int temp = 4; Field field; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ try { field = clazz.getClass().getField(lookingForValue); - Class clazzType = field.getType(); + Class clazzType = field.getType(); if (clazzType.toString().equals("int")){ temp = (field.getInt(clazz)); } @@ -85,10 +87,12 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements temp = 4; } } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { - Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + //Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); Utils.LOG_WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); Utils.LOG_ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + temp = 4; } + } return temp; } -- cgit From b988ff17b27caa4dc09c0c334ee34e0c48d55846 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Tue, 4 Oct 2016 21:00:26 +1000 Subject: $ Fixed void metal pipes using ERROR ingots when generated. $ Fixed the block texture for the matter fabricators internal space. --- .../xmod/gregtech/api/enums/GregtechOrePrefixes.java | 2 +- .../gregtech/registration/gregtech/GregtechConduits.java | 2 +- .../assets/miscutils/textures/blocks/blockMFEffect.png | Bin 0 -> 205 bytes 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 src/resources/assets/miscutils/textures/blocks/blockMFEffect.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java index 238f535505..9a1ef1376d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java @@ -328,7 +328,7 @@ public enum GregtechOrePrefixes { Staballoy(30, TextureSet.SET_ROUGH, 10.0F, 5120, 4, 1 | 2 | 16 | 32 | 64 | 128, 68, 75, 66, 0, "Staballoy", 0, 0, 1500, 2800, true, false, 1, 3, 1, Dyes.dyeGreen, 2, Arrays.asList(new MaterialStack(Materials.Titanium, 1), new MaterialStack(Materials.Uranium, 9)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), Bedrockium(31, TextureSet.SET_FINE, 8.0F, 8196, 3, 1 | 2 | 16 | 32 | 64 | 128, 39, 39, 39, 0, "Bedrockium", 0, 0, -1, 0, false, false, 1, 5, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Materials.Carbon, 63), new MaterialStack(Materials.Carbon, 56)), Arrays.asList(getTcAspectStack(TC_Aspects.VACUOS, 8), getTcAspectStack(TC_Aspects.TUTAMEN, 3))), BloodSteel(32, TextureSet.SET_METALLIC, 11.0F, 768, 4, 1 | 2 | 16 | 32 | 64 | 128, 142, 28, 0, 0, "Blood Steel", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeRed, 2, Arrays.asList(new MaterialStack(Materials.Steel, 3)), Arrays.asList(getTcAspectStack(TC_Aspects.VICTUS, 8), getTcAspectStack(TC_Aspects.IGNIS, 3))), - VoidMetal(33, TextureSet.SET_METALLIC, 6.0F, 1280, 3, 1 | 2 | 16 | 32 | 64 | 128, 82, 17, 82, 0, "Void Metal", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeBlack, Arrays.asList(getTcAspectStack("PRAECANTATIO", 5), getTcAspectStack(TC_Aspects.VACUOS, 7))), + Void(33, TextureSet.SET_METALLIC, 6.0F, 1280, 3, 1 | 2 | 16 | 32 | 64 | 128, 82, 17, 82, 0, "Void Metal", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeBlack, Arrays.asList(getTcAspectStack("PRAECANTATIO", 5), getTcAspectStack(TC_Aspects.VACUOS, 7))), ConductiveIron(34, TextureSet.SET_METALLIC, 5.0F, 256, 2, 1 | 2, 164, 109, 100, 0, "Conductive Iron", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeRed, 2, Arrays.asList(new MaterialStack(Materials.Iron, 6), new MaterialStack(Materials.Redstone, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.POTENTIA, 2), getTcAspectStack(TC_Aspects.METALLUM, 2))), ElectricalSteel(35, TextureSet.SET_METALLIC, 7.0F, 768, 3, 1 | 2 | 64 | 128, 194, 194, 194, 0, "Electrical Steel", 0, 0, 1811, 1000, true, false, 3, 1, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Materials.Iron, 3), new MaterialStack(Materials.Coal, 2), new MaterialStack(Materials.Silicon, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.MAGNETO, 2), getTcAspectStack(TC_Aspects.ELECTRUM, 5))), EnergeticAlloy(36, TextureSet.SET_SHINY, 5.0F, 512, 3, 1 | 2 | 64 | 128, 252, 152, 45, 0, "Energetic Alloy", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeOrange, 2, Arrays.asList(new MaterialStack(Materials.Gold, 3), new MaterialStack(Materials.Glowstone, 2), new MaterialStack(Materials.Redstone, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.POTENTIA, 4), getTcAspectStack(TC_Aspects.LUX, 3))), diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java index 28b86a8b10..6526e93b13 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java @@ -61,7 +61,7 @@ public class GregtechConduits { generateNonGTFluidPipes(GT_Materials.Tantalloy60, BasePipeID+5, 5000, 4250, true); generateNonGTFluidPipes(GT_Materials.Tantalloy61, BasePipeID+10, 6000, 5800, true); if (LoadedMods.Thaumcraft){ - generateNonGTFluidPipes(GT_Materials.VoidMetal, BasePipeID+15, 250, 25000, true);} + generateNonGTFluidPipes(GT_Materials.Void, BasePipeID+15, 250, 25000, true);} generateGTFluidPipes(Materials.Europium, BasePipeID+20, 12000, 7500, true); generateNonGTFluidPipes(GT_Materials.Potin, BasePipeID+25, 375, 2000, true); generateNonGTFluidPipes(GT_Materials.MaragingSteel300, BasePipeID+30, 7000, 2500, true); diff --git a/src/resources/assets/miscutils/textures/blocks/blockMFEffect.png b/src/resources/assets/miscutils/textures/blocks/blockMFEffect.png new file mode 100644 index 0000000000..8e48e12070 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/blockMFEffect.png differ -- cgit From e230c773e0fc305bff3e3c4d1ed1e36878b02b29 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Thu, 6 Oct 2016 00:46:53 +1000 Subject: + Added the Big Shovels, which are 3x3 shovels. + Updated Generated Tools and their damage taken when mining blocks. > Now meta-tools only generate if they have a valid colour, durability and recipe contains valid components. $ Fixed Fluid Cell Recipes between .08/.09 branches. % Cleaned up some old textures. + Added a log message to output total recipes the mod has added for crafting table use. + Started the base work for extra NBT data saving for GT TileEntities. --- .classpath | 2 +- .../api/metatileentity/BaseMetaTileEntityEx.java | 2081 ++++++++++++++++++++ .../api/metatileentity/MetaTileEntityEx.java | 972 +++++++++ .../GT_MetaTileEntity_BasicMachineEx.java | 798 ++++++++ .../GT_MetaTileEntity_BasicTankEx.java | 251 +++ .../GT_MetaTileEntity_TieredMachineBlockEx.java | 67 + src/Java/gtPlusPlus/GTplusplus.java | 3 + src/Java/gtPlusPlus/core/item/ModItems.java | 13 +- .../core/item/tool/staballoy/MultiPickaxeBase.java | 60 +- .../core/item/tool/staballoy/MultiSpadeBase.java | 115 ++ .../core/item/tool/staballoy/StaballoyPickaxe.java | 46 +- .../core/item/tool/staballoy/StaballoySpade.java | 316 +++ src/Java/gtPlusPlus/core/lib/CORE.java | 10 +- src/Java/gtPlusPlus/core/util/item/UtilsItems.java | 41 +- .../xmod/gregtech/api/enums/GregtechTextures.java | 32 +- .../xmod/gregtech/common/Meta_GT_Proxy.java | 31 + .../common/blocks/GregtechBlockMachines.java | 50 +- .../common/items/MetaGeneratedGregtechItems.java | 18 +- .../common/tileentities/storage/GT_NBT_Tank.java | 202 ++ .../xmod/gregtech/loaders/Gregtech_Blocks.java | 29 +- .../gregtech/GregtechTieredFluidTanks.java | 19 + .../assets/miscutils/textures/items/itemShovel.png | Bin 0 -> 154 bytes 22 files changed, 5065 insertions(+), 91 deletions(-) create mode 100644 src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java create mode 100644 src/Java/gregtech/api/metatileentity/MetaTileEntityEx.java create mode 100644 src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachineEx.java create mode 100644 src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTankEx.java create mode 100644 src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlockEx.java create mode 100644 src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java create mode 100644 src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java create mode 100644 src/resources/assets/miscutils/textures/items/itemShovel.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/.classpath b/.classpath index 37602a4409..3e8a66c867 100644 --- a/.classpath +++ b/.classpath @@ -13,6 +13,6 @@ - + diff --git a/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java b/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java new file mode 100644 index 0000000000..1669a11f9a --- /dev/null +++ b/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java @@ -0,0 +1,2081 @@ +package gregtech.api.metatileentity; + +import static gregtech.api.enums.GT_Values.NW; +import static gregtech.api.enums.GT_Values.V; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IEnergyConnected; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet_TileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import ic2.api.Direction; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFire; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + *

+ * This is the main TileEntity for EVERYTHING. + */ +public class BaseMetaTileEntityEx extends BaseTileEntity implements IGregTechTileEntity { + private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; + protected MetaTileEntityEx mMetaTileEntity; + protected long mStoredEnergy = 0, mStoredSteam = 0; + protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; + protected boolean mReleaseEnergy = false; + protected int[] mAverageEUInput = new int[]{0, 0, 0, 0, 0}, mAverageEUOutput = new int[]{0, 0, 0, 0, 0}; + private boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; + private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; + private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; + + + //TODO + //TODO + //TODO + //TODO + private boolean mHasEnoughEnergy = true; + private boolean mRunningThroughTick = false; + private boolean mInputDisabled = false; + private boolean mOutputDisabled = false; + private boolean mMuffler = false; + private boolean mLockUpgrade = false; + private boolean mActive = false; + private boolean mRedstone = false; + private boolean mWorkUpdate = false; + private boolean mSteamConverter = false; + private boolean mInventoryChanged = false; + private boolean mWorks = true; + private boolean mNeedsUpdate = true; + private boolean mNeedsBlockUpdate = true; + private boolean mSendClientData = false; + private boolean oRedstone = false; + //TODO + //TODO + + // Create a new NBT Tag List to store itemstacks as NBT Tags + protected NBTTagList mInventoryItems = new NBTTagList(); + protected ItemStack[] mInventory; + //TODO + //TODO + //TODO + + private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; + private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; + private short mID = 0; + private long mTickTimer = 0, oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; + private String mOwnerName = ""; + private NBTTagCompound mRecipeStuff = new NBTTagCompound(); + + public BaseMetaTileEntityEx() { + /* this.mInventory = mMetaTileEntity.mInventory; + Utils.LOG_INFO(UtilsItems.getArrayStackNames(mInventory));*/ + } + + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + try { + super.writeToNBT(aNBT); + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + try { + aNBT.setInteger("mID", mID); + aNBT.setLong("mStoredSteam", mStoredSteam); + aNBT.setLong("mStoredEnergy", mStoredEnergy); + aNBT.setIntArray("mCoverData", mCoverData); + aNBT.setIntArray("mCoverSides", mCoverSides); + aNBT.setByteArray("mRedstoneSided", mSidedRedstone); + aNBT.setByte("mColor", mColor); + aNBT.setByte("mLightValue", mLightValue); + aNBT.setByte("mOtherUpgrades", mOtherUpgrades); + aNBT.setByte("mWorkData", mWorkData); + aNBT.setByte("mStrongRedstone", mStrongRedstone); + aNBT.setShort("mFacing", mFacing); + aNBT.setString("mOwnerName", mOwnerName); + aNBT.setBoolean("mLockUpgrade", mLockUpgrade); + aNBT.setBoolean("mMuffler", mMuffler); + aNBT.setBoolean("mSteamConverter", mSteamConverter); + aNBT.setBoolean("mActive", mActive); + aNBT.setBoolean("mRedstone", mRedstone); + aNBT.setBoolean("mWorks", !mWorks); + aNBT.setBoolean("mInputDisabled", mInputDisabled); + aNBT.setBoolean("mOutputDisabled", mOutputDisabled); + aNBT.setTag("GT.CraftingComponents", mRecipeStuff); + + //Let's try save the contents of the inventory + // Create a new NBT Tag List to store itemstacks as NBT Tags + NBTTagList items = new NBTTagList(); + + for (int i = 0; i < getSizeInventory(); ++i) + { + // Only write stacks that contain items + if (getStackInSlot(i) != null){ + // Make a new NBT Tag Compound to write the itemstack and slot index to + NBTTagCompound item = new NBTTagCompound(); + item.setInteger("Slot", i); + // Writes the itemstack in slot(i) to the Tag Compound we just made + getStackInSlot(i).writeToNBT(item); + // add the tag compound to our tag list + items.appendTag(item); + } + } + // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" + aNBT.setTag("TileEntityInventory", items); + + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + try { + if (hasValidMetaTileEntity()) { + NBTTagList tItemList = new NBTTagList(); + for (int i = 0; i < mMetaTileEntity.getRealInventory().length; i++) { + ItemStack tStack = mMetaTileEntity.getRealInventory()[i]; + if (tStack != null) { + NBTTagCompound tTag = new NBTTagCompound(); + tTag.setInteger("IntSlot", i); + tStack.writeToNBT(tTag); + tItemList.appendTag(tTag); + } + } + aNBT.setTag("Inventory", tItemList); + + try { + mMetaTileEntity.saveNBTData(aNBT); + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + } + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + } + + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + setInitialValuesAsNBT(aNBT, (short) 0); + } + + + @Override + public void setInitialValuesAsNBT(NBTTagCompound aNBT, short aID) { + if (aNBT == null) { + if (aID > 0) mID = aID; + else mID = mID > 0 ? mID : 0; + if (mID != 0) createNewMetatileEntity(mID); + mSidedRedstone = (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior() ? new byte[]{0, 0, 0, 0, 0, 0} : new byte[]{15, 15, 15, 15, 15, 15}); + } else { + if (aID <= 0) mID = (short) aNBT.getInteger("mID"); + else mID = aID; + mStoredSteam = aNBT.getInteger("mStoredSteam"); + mStoredEnergy = aNBT.getInteger("mStoredEnergy"); + mColor = aNBT.getByte("mColor"); + mLightValue = aNBT.getByte("mLightValue"); + mWorkData = aNBT.getByte("mWorkData"); + mStrongRedstone = aNBT.getByte("mStrongRedstone"); + mFacing = oFacing = (byte) aNBT.getShort("mFacing"); + mOwnerName = aNBT.getString("mOwnerName"); + mLockUpgrade = aNBT.getBoolean("mLockUpgrade"); + mMuffler = aNBT.getBoolean("mMuffler"); + mSteamConverter = aNBT.getBoolean("mSteamConverter"); + mActive = aNBT.getBoolean("mActive"); + mRedstone = aNBT.getBoolean("mRedstone"); + mWorks = !aNBT.getBoolean("mWorks"); + mInputDisabled = aNBT.getBoolean("mInputDisabled"); + mOutputDisabled = aNBT.getBoolean("mOutputDisabled"); + mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries")); + mCoverSides = aNBT.getIntArray("mCoverSides"); + mCoverData = aNBT.getIntArray("mCoverData"); + mSidedRedstone = aNBT.getByteArray("mRedstoneSided"); + mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); + + //Loading Invetory contents + // Gets the custom taglist we wrote to this compound, if any + NBTTagList items = aNBT.getTagList("TileEntityInventory", Constants.NBT.TAG_COMPOUND); + for (int i = 0; i < items.tagCount(); ++i){ + NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i); + int slot = item.getInteger("Slot"); + // Just double-checking that the saved slot index is within our inventory array bounds + if (slot >= 0 && slot < getSizeInventory()) { + mInventory[slot] = ItemStack.loadItemStackFromNBT(item); + } + } + + if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0}; + if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; + if (mSidedRedstone.length != 6) + if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior()) + mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; + else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; + + for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); + + if (mID != 0 && createNewMetatileEntity(mID)) { + NBTTagList tItemList = aNBT.getTagList("Inventory", 10); + for (int i = 0; i < tItemList.tagCount(); i++) { + NBTTagCompound tTag = tItemList.getCompoundTagAt(i); + int tSlot = tTag.getInteger("IntSlot"); + if (tSlot >= 0 && tSlot < mMetaTileEntity.getRealInventory().length) { + mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag); + } + } + + try { + mMetaTileEntity.loadNBTData(aNBT); + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + } + } + + if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0}; + if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; + if (mSidedRedstone.length != 6) + if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior()) + mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; + else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; + + for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); + } + + private boolean createNewMetatileEntity(short aID) { + if (aID <= 0 || aID >= Meta_GT_Proxy.METATILEENTITIES.length || Meta_GT_Proxy.METATILEENTITIES[aID] == null) { + GT_Log.err.println("GT++ - MetaID " + aID + " not loadable => locking TileEntity!"); + } else { + if (aID != 0) { + if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); + Meta_GT_Proxy.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); + mTickTimer = 0; + mID = aID; + return true; + } + } + return false; + } + + /** + * Used for ticking special BaseMetaTileEntities, which need that for Energy Conversion + * It's called right before onPostTick() + */ + public void updateStatus() { + // + } + + /** + * Called when trying to charge Items + */ + public void chargeItem(ItemStack aStack) { + decreaseStoredEU(GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()), false, false), true); + } + + /** + * Called when trying to discharge Items + */ + public void dischargeItem(ItemStack aStack) { + increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getEUCapacity() - getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), false, false, false), true); + } + + + @Override + public void updateEntity() { + super.updateEntity(); + + if (!hasValidMetaTileEntity()) { + if (mMetaTileEntity == null) return; + mMetaTileEntity.setBaseMetaTileEntity(this); + } + + mRunningThroughTick = true; + long tTime = System.currentTimeMillis(); + + for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { + try { + switch (tCode) { + case 0: + tCode++; + if (mTickTimer++ == 0) { + oX = xCoord; + oY = yCoord; + oZ = zCoord; + if (isServerSide()) for (byte i = 0; i < 6; i++) + if (getCoverIDAtSide(i) != 0) + if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) + dropCover(i, i, true); + + worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); + + mMetaTileEntity.onFirstTick(this); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + } + case 1: + tCode++; + if (isClientSide()) { + if (mColor != oColor) { + mMetaTileEntity.onColorChangeClient(oColor = mColor); + issueTextureUpdate(); + } + + if (mLightValue != oLightValueClient) { + worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); + oLightValueClient = mLightValue; + issueTextureUpdate(); + } + + if (mNeedsUpdate) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + //worldObj.func_147479_m(xCoord, yCoord, zCoord); + mNeedsUpdate = false; + } + } + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + if (isServerSide() && mTickTimer > 10) { + for (byte i = (byte) (tCode - 2); i < 6; i++) + if (getCoverIDAtSide(i) != 0) { + tCode++; + GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); + int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); + if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { + mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + } + } + + } + case 8: + tCode = 9; + if (isServerSide()) { + if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0; + if (++mAverageEUOutputIndex >= mAverageEUOutput.length) mAverageEUOutputIndex = 0; + + mAverageEUInput[mAverageEUInputIndex] = 0; + mAverageEUOutput[mAverageEUOutputIndex] = 0; + } + case 9: + tCode++; + mMetaTileEntity.onPreTick(this, mTickTimer); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + case 10: + tCode++; + if (isServerSide()) { + if (mRedstone != oRedstone || mTickTimer == 10) { + for (byte i = 0; i < 6; i++) + mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); + oRedstone = mRedstone; + issueBlockUpdate(); + } + + if (xCoord != oX || yCoord != oY || zCoord != oZ) { + oX = xCoord; + oY = yCoord; + oZ = zCoord; + issueClientUpdate(); + clearTileEntityBuffer(); + } + + if (mFacing != oFacing) { + oFacing = mFacing; + for (byte i = 0; i < 6; i++) + if (getCoverIDAtSide(i) != 0) + if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) + dropCover(i, i, true); + issueBlockUpdate(); + } + + if (mTickTimer > 20 && mMetaTileEntity.isElectric()) { + mAcceptedAmperes = 0; + + if (getOutputVoltage() != oOutput) { + oOutput = getOutputVoltage(); + } + + if (mMetaTileEntity.isEnetOutput() || mMetaTileEntity.isEnetInput()) { + for (byte i = 0; i < 6; i++) { + boolean + temp = isEnergyInputSide(i); + if (temp != mActiveEUInputs[i]) { + mActiveEUInputs[i] = temp; + } + temp = isEnergyOutputSide(i); + if (temp != mActiveEUOutputs[i]) { + mActiveEUOutputs[i] = temp; + } + } + } + + if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { + long tOutputVoltage = Math.max(oOutput, oOutput + (1 << GT_Utility.getTier(oOutput))), tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); + if (tUsableAmperage > 0) { + long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); + mAverageEUOutput[mAverageEUOutputIndex] += tEU; + decreaseStoredEU(tEU, true); + } + } + if (getEUCapacity() > 0) { + if (GregTech_API.sMachineFireExplosions && getRandomNumber(1000) == 0) { + Block tBlock = getBlockAtSide((byte) getRandomNumber(6)); + if (tBlock != null && tBlock instanceof BlockFire) doEnergyExplosion(); + } + + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + + if (getRandomNumber(1000) == 0) { + if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) + || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord) + || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord) + || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord) + || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) { + if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { + if (getRandomNumber(10) == 0) { + try { + GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); + } catch (Exception e) { + } + doEnergyExplosion(); + } else setOnFire(); + } + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) { + try { + GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); + } catch (Exception e) { + } + doEnergyExplosion(); + } + } + } + } + } + + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + } + case 11: + tCode++; + if (isServerSide()) { + if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { + for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { + if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { + dischargeItem(mMetaTileEntity.mInventory[i]); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) + mMetaTileEntity.mInventory[i] = null; + mInventoryChanged = true; + } + } + } + } + case 12: + tCode++; + if (isServerSide()) { + if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { + for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { + if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { + chargeItem(mMetaTileEntity.mInventory[i]); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) + mMetaTileEntity.mInventory[i] = null; + mInventoryChanged = true; + } + } + } + } + case 13: + tCode++; + updateStatus(); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + case 14: + tCode++; + mMetaTileEntity.onPostTick(this, mTickTimer); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + case 15: + tCode++; + if (isServerSide()) { + if (mTickTimer % 10 == 0) { + if (mSendClientData) { + NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord); + mSendClientData = false; + } + } + + if (mTickTimer > 10) { + byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)); + if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); + tData = mMetaTileEntity.getUpdateData(); + if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); + if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); + tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); + if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); + if (mLightValue != oLightValue) { + worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); + issueTextureUpdate(); + sendBlockEvent((byte) 7, oLightValue = mLightValue); + } + } + + if (mNeedsBlockUpdate) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); + mNeedsBlockUpdate = false; + } + } + default: + tCode = -1; + break; + } + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + } + + if (isServerSide() && hasValidMetaTileEntity()) { + tTime = System.currentTimeMillis() - tTime; + if (mTimeStatistics.length > 0) + mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime; + if (tTime > 0 && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10) + System.out.println("GT++ - WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime + "ms caused by an instance of " + getMetaTileEntity().getClass()); + } + + mWorkUpdate = mInventoryChanged = mRunningThroughTick = false; + } + + + @Override + public Packet getDescriptionPacket() { + issueClientUpdate(); + return null; + } + + + @Override + public boolean receiveClientEvent(int aEventID, int aValue) { + super.receiveClientEvent(aEventID, aValue); + + if (hasValidMetaTileEntity()) { + try { + mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue); + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + } + + if (isClientSide()) { + issueTextureUpdate(); + switch (aEventID) { + case 0: + mFacing = (byte) (aValue & 7); + mActive = ((aValue & 8) != 0); + mRedstone = ((aValue & 16) != 0); + //mLockUpgrade = ((aValue&32) != 0); + break; + case 1: + if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte) aValue); + break; + case 2: + if (aValue > 16 || aValue < 0) aValue = 0; + mColor = (byte) aValue; + break; + case 3: + mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0); + mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0); + mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0); + mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0); + mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0); + mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0); + break; + case 4: + if (hasValidMetaTileEntity() && mTickTimer > 20) + mMetaTileEntity.doSound((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + break; + case 5: + if (hasValidMetaTileEntity() && mTickTimer > 20) + mMetaTileEntity.startSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + break; + case 6: + if (hasValidMetaTileEntity() && mTickTimer > 20) + mMetaTileEntity.stopSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + break; + case 7: + mLightValue = (byte) aValue; + break; + } + } + return true; + } + + public ArrayList getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { + ArrayList tList = new ArrayList(); + if (aLogLevel > 2) { + tList.add("GT++ - Meta-ID: " + mID + (canAccessData() ? " valid" : " invalid") + (mMetaTileEntity == null ? " MetaTileEntity == null!" : " ")); + } + if (aLogLevel > 1) { + if (mTimeStatistics.length > 0) { + double tAverageTime = 0; + for (int tTime : mTimeStatistics) tAverageTime += tTime; + tList.add("GT++ - This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + "ms over the last " + mTimeStatistics.length + " ticks."); + } + if (mLagWarningCount > 0) { + tList.add("GT++ - This TileEntity has also caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); + } + tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : " not ") + "accessible for you"); + } + if (aLogLevel > 0) { + if (getSteamCapacity() > 0 && hasSteamEngineUpgrade()) + tList.add(getStoredSteam() + " of " + getSteamCapacity() + " Steam"); + tList.add("Machine is " + (mActive ? "active" : "inactive")); + if (!mHasEnoughEnergy) + tList.add("GT++ - ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process."); + } + return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); + } + + + @Override + public void issueTextureUpdate() { + mNeedsUpdate = true; + } + + + @Override + public void issueBlockUpdate() { + mNeedsBlockUpdate = true; + } + + + @Override + public void issueClientUpdate() { + mSendClientData = true; + } + + + @Override + public void issueCoverUpdate(byte aSide) { + issueClientUpdate(); + } + + + @Override + public byte getStrongestRedstone() { + return (byte) Math.max(getInternalInputRedstoneSignal((byte) 0), Math.max(getInternalInputRedstoneSignal((byte) 1), Math.max(getInternalInputRedstoneSignal((byte) 2), Math.max(getInternalInputRedstoneSignal((byte) 3), Math.max(getInternalInputRedstoneSignal((byte) 4), getInternalInputRedstoneSignal((byte) 5)))))); + } + + + @Override + public boolean getRedstone() { + return getRedstone((byte) 0) || getRedstone((byte) 1) || getRedstone((byte) 2) || getRedstone((byte) 3) || getRedstone((byte) 4) || getRedstone((byte) 5); + } + + + @Override + public boolean getRedstone(byte aSide) { + return getInternalInputRedstoneSignal(aSide) > 0; + } + + public ITexture getCoverTexture(byte aSide) { + return GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide))); + } + + + @Override + public boolean isGivingInformation() { + if (canAccessData()) return mMetaTileEntity.isGivingInformation(); + return false; + } + + + @Override + public boolean isValidFacing(byte aSide) { + if (canAccessData()) return mMetaTileEntity.isFacingValid(aSide); + return false; + } + + + @Override + public byte getBackFacing() { + return GT_Utility.getOppositeSide(mFacing); + } + + + @Override + public byte getFrontFacing() { + return mFacing; + } + + + @Override + public void setFrontFacing(byte aFacing) { + if (isValidFacing(aFacing)) { + mFacing = aFacing; + mMetaTileEntity.onFacingChange(); + onMachineBlockUpdate(); + } + } + + + @Override + public int getSizeInventory() { + if (canAccessData()) return mMetaTileEntity.getSizeInventory(); + return 0; + } + + + @Override + public ItemStack getStackInSlot(int aIndex) { + if (canAccessData()) return mMetaTileEntity.getStackInSlot(aIndex); + return null; + } + + + @Override + public void setInventorySlotContents(int aIndex, ItemStack aStack) { + mInventoryChanged = true; + if (canAccessData()) + mMetaTileEntity.setInventorySlotContents(aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); + } + + + @Override + public String getInventoryName() { + if (canAccessData()) return mMetaTileEntity.getInventoryName(); + if (Meta_GT_Proxy.METATILEENTITIES[mID] != null) return Meta_GT_Proxy.METATILEENTITIES[mID].getInventoryName(); + return ""; + } + + + @Override + public int getInventoryStackLimit() { + if (canAccessData()) return mMetaTileEntity.getInventoryStackLimit(); + return 64; + } + + + @Override + public void openInventory() { + if (canAccessData()) mMetaTileEntity.onOpenGUI(); + } + + + @Override + public void closeInventory() { + if (canAccessData()) mMetaTileEntity.onCloseGUI(); + } + + + @Override + public boolean isUseableByPlayer(EntityPlayer aPlayer) { + return canAccessData() && playerOwnsThis(aPlayer, false) && mTickTimer > 40 && getTileEntityOffset(0, 0, 0) == this && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 && mMetaTileEntity.isAccessAllowed(aPlayer); + } + + + @Override + public void validate() { + super.validate(); + mTickTimer = 0; + } + + + @Override + public void invalidate() { + tileEntityInvalid = false; + if (canAccessData()) { + mMetaTileEntity.onRemoval(); + mMetaTileEntity.setBaseMetaTileEntity(null); + } + super.invalidate(); + } + + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + } + + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + ItemStack stack = getStackInSlot(slot); + if (stack != null) setInventorySlotContents(slot, null); + return stack; + } + + + @Override + public void onMachineBlockUpdate() { + if (canAccessData()) mMetaTileEntity.onMachineBlockUpdate(); + } + + + @Override + public int getProgress() { + return canAccessData() ? mMetaTileEntity.getProgresstime() : 0; + } + + + @Override + public int getMaxProgress() { + return canAccessData() ? mMetaTileEntity.maxProgresstime() : 0; + } + + + @Override + public boolean increaseProgress(int aProgressAmountInTicks) { + return canAccessData() ? mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks : false; + } + + + @Override + public boolean hasThingsToDo() { + return getMaxProgress() > 0; + } + + + @Override + public void enableWorking() { + if (!mWorks) mWorkUpdate = true; + mWorks = true; + } + + + @Override + public void disableWorking() { + mWorks = false; + } + + + @Override + public boolean isAllowedToWork() { + return mWorks; + } + + + @Override + public boolean hasWorkJustBeenEnabled() { + return mWorkUpdate; + } + + + @Override + public byte getWorkDataValue() { + return mWorkData; + } + + + @Override + public void setWorkDataValue(byte aValue) { + mWorkData = aValue; + } + + + @Override + public int getMetaTileID() { + return mID; + } + + + @Override + public int setMetaTileID(short aID) { + return mID = aID; + } + + + @Override + public boolean isActive() { + return mActive; + } + + + @Override + public void setActive(boolean aActive) { + mActive = aActive; + } + + + @Override + public long getTimer() { + return mTickTimer; + } + + + @Override + public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { + if (!canAccessData()) return false; + return mHasEnoughEnergy = decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || decreaseStoredSteam(aEnergy, false) || (aIgnoreTooLessEnergy && (decreaseStoredSteam(aEnergy, true))); + } + + + @Override + public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { + if (!canAccessData()) return false; + if (getStoredEU() < getEUCapacity() || aIgnoreTooMuchEnergy) { + setStoredEU(mMetaTileEntity.getEUVar() + aEnergy); + return true; + } + return false; + } + + + @Override + public boolean inputEnergyFrom(byte aSide) { + if (aSide == 6) return true; + if (isServerSide()) return (aSide >= 0 && aSide < 6 ? mActiveEUInputs[aSide] : false) && !mReleaseEnergy; + return isEnergyInputSide(aSide); + } + + + @Override + public boolean outputsEnergyTo(byte aSide) { + if (aSide == 6) return true; + if (isServerSide()) return (aSide >= 0 && aSide < 6 ? mActiveEUOutputs[aSide] : false) || mReleaseEnergy; + return isEnergyOutputSide(aSide); + } + + + @Override + public long getOutputAmperage() { + if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesOut(); + return 0; + } + + + @Override + public long getOutputVoltage() { + if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) + return mMetaTileEntity.maxEUOutput(); + return 0; + } + + + @Override + public long getInputAmperage() { + if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesIn(); + return 0; + } + + + @Override + public long getInputVoltage() { + if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxEUInput(); + return Integer.MAX_VALUE; + } + + + @Override + public boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy) { + if (!canAccessData()) return false; + if (mMetaTileEntity.getSteamVar() < getSteamCapacity() || aIgnoreTooMuchEnergy) { + setStoredSteam(mMetaTileEntity.getSteamVar() + aEnergy); + return true; + } + return false; + } + + + @Override + public String[] getDescription() { + if (canAccessData()) return mMetaTileEntity.getDescription(); + return new String[0]; + } + + + @Override + public boolean isValidSlot(int aIndex) { + if (canAccessData()) return mMetaTileEntity.isValidSlot(aIndex); + return false; + } + + + @Override + public long getUniversalEnergyStored() { + return Math.max(getStoredEU(), getStoredSteam()); + } + + + @Override + public long getUniversalEnergyCapacity() { + return Math.max(getEUCapacity(), getSteamCapacity()); + } + + + @Override + public long getStoredEU() { + if (canAccessData()) return Math.min(mMetaTileEntity.getEUVar(), getEUCapacity()); + return 0; + } + + + @Override + public long getEUCapacity() { + if (canAccessData()) return mMetaTileEntity.maxEUStore(); + return 0; + } + + + @Override + public long getStoredSteam() { + if (canAccessData()) return Math.min(mMetaTileEntity.getSteamVar(), getSteamCapacity()); + return 0; + } + + + @Override + public long getSteamCapacity() { + if (canAccessData()) return mMetaTileEntity.maxSteamStore(); + return 0; + } + + @Override + public ITexture[] getTexture(byte aSide) { + ITexture rIcon = getCoverTexture(aSide); + if (rIcon != null) return new ITexture[]{rIcon}; + if (hasValidMetaTileEntity()) + return mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0); + return Textures.BlockIcons.ERROR_RENDERING; + } + + private boolean isEnergyInputSide(byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (!getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) + return false; + if (isInvalid() || mReleaseEnergy) return false; + if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetInput()) + return mMetaTileEntity.isInputFacing(aSide); + } + return false; + } + + private boolean isEnergyOutputSide(byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (!getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) + return false; + if (isInvalid() || mReleaseEnergy) return mReleaseEnergy; + if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) + return mMetaTileEntity.isOutputFacing(aSide); + } + return false; + } + + + protected boolean hasValidMetaTileEntity() { + return mMetaTileEntity != null && mMetaTileEntity.getBaseMetaTileEntity() == this; + } + + + protected boolean canAccessData() { + return !isDead && hasValidMetaTileEntity(); + } + + + public boolean setStoredEU(long aEnergy) { + if (!canAccessData()) return false; + if (aEnergy < 0) aEnergy = 0; + mMetaTileEntity.setEUVar(aEnergy); + return true; + } + + + public boolean setStoredSteam(long aEnergy) { + if (!canAccessData()) return false; + if (aEnergy < 0) aEnergy = 0; + mMetaTileEntity.setSteamVar(aEnergy); + return true; + } + + + public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { + if (!canAccessData()) { + return false; + } + if (mMetaTileEntity.getEUVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) { + setStoredEU(mMetaTileEntity.getEUVar() - aEnergy); + if (mMetaTileEntity.getEUVar() < 0) { + setStoredEU(0); + return false; + } + return true; + } + return false; + } + + + public boolean decreaseStoredSteam(long aEnergy, boolean aIgnoreTooLessEnergy) { + if (!canAccessData()) return false; + if (mMetaTileEntity.getSteamVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) { + setStoredSteam(mMetaTileEntity.getSteamVar() - aEnergy); + if (mMetaTileEntity.getSteamVar() < 0) { + setStoredSteam(0); + return false; + } + return true; + } + return false; + } + + + public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) { + if (!canAccessData()) return false; + if (aCheckPrecicely || privateAccess() || mOwnerName.equals("")) + if (mOwnerName.equals("") && isServerSide()) setOwnerName(aPlayer.getDisplayName()); + else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName())) + return false; + return true; + } + + + public boolean privateAccess() { + if (!canAccessData()) return mLockUpgrade; + return mLockUpgrade || mMetaTileEntity.ownerControl(); + } + + + public void doEnergyExplosion() { + if (getUniversalEnergyCapacity() > 0 && getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 5) { + doExplosion(oOutput * (getUniversalEnergyStored() >= getUniversalEnergyCapacity() ? 4 : getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 2 ? 2 : 1)); + GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems"); + } + } + + + @Override + public void doExplosion(long aAmount) { + if (canAccessData()) { + // This is only for Electric Machines + if (GregTech_API.sMachineWireFire && mMetaTileEntity.isElectric()) { + try { + mReleaseEnergy = true; + IEnergyConnected.Util.emitEnergyToNetwork(V[5], Math.max(1, getStoredEU() / V[5]), this); + } catch (Exception e) {/* Fun Fact: all these "do nothing" Comments you see in my Code, are just there to let Eclipse shut up about the intended empty Brackets, but I need eclipse to yell at me in some of the regular Cases where I forget to add Code */} + } + mReleaseEnergy = false; + // Normal Explosion Code + mMetaTileEntity.onExplosion(); + mMetaTileEntity.doExplosion(aAmount); + } + } + + + + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + + + @Override + public ArrayList getDrops() { + ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, mID); + NBTTagCompound tNBT = new NBTTagCompound(); + if (mRecipeStuff != null && !mRecipeStuff.hasNoTags()) tNBT.setTag("GT.CraftingComponents", mRecipeStuff); + if (mMuffler) tNBT.setBoolean("mMuffler", mMuffler); + if (mLockUpgrade) tNBT.setBoolean("mLockUpgrade", mLockUpgrade); + if (mSteamConverter) tNBT.setBoolean("mSteamConverter", mSteamConverter); + if (mColor > 0) tNBT.setByte("mColor", mColor); + if (mOtherUpgrades > 0) tNBT.setByte("mOtherUpgrades", mOtherUpgrades); + if (mStrongRedstone > 0) tNBT.setByte("mStrongRedstone", mStrongRedstone); + for (byte i = 0; i < mCoverSides.length; i++) { + if (mCoverSides[i] != 0) { + tNBT.setIntArray("mCoverData", mCoverData); + tNBT.setIntArray("mCoverSides", mCoverSides); + break; + } + } + if (hasValidMetaTileEntity()) mMetaTileEntity.setItemNBT(tNBT); + if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT); + return new ArrayList(Arrays.asList(rStack)); + } + + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + //TODO + + + public int getUpgradeCount() { + return (mMuffler ? 1 : 0) + (mLockUpgrade ? 1 : 0) + (mSteamConverter ? 1 : 0) + mOtherUpgrades; + } + + + @Override + public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + if (isClientSide()) { + if (getCoverBehaviorAtSide(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) return true; + if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) + return false; + } + if (isServerSide()) { + if (!privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(getOwnerName())) { + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null) { + if (getColorization() >= 0 && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) { + tCurrentItem.func_150996_a(Items.bucket); + setColorization((byte) (getColorization() >= 16 ? -2 : -1)); + return true; + } + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { + if (mMetaTileEntity.onWrenchRightClick(aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) { + GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + } + return true; + } + + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { + if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { + setCoverDataAtSide(aSide, getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)); + mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + } + return true; + } + + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) { + if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + mInputDisabled = !mInputDisabled; + if (mInputDisabled) mOutputDisabled = !mOutputDisabled; + GT_Utility.sendChatToPlayer(aPlayer, "Auto-Input: " + (mInputDisabled ? "Disabled" : "Enabled") + " Auto-Output: " + (mOutputDisabled ? "Disabled" : "Enabled")); + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, zCoord); + } + return true; + } + + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) { + if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + if (mWorks) disableWorking(); + else enableWorking(); + GT_Utility.sendChatToPlayer(aPlayer, "Machine Processing: " + (isAllowedToWork() ? "Enabled" : "Disabled")); + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1, xCoord, yCoord, zCoord); + } + return true; + } + + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { + byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); + if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { + mStrongRedstone ^= (1 << tSide); + GT_Utility.sendChatToPlayer(aPlayer, "Redstone Output at Side " + tSide + " set to: " + ((mStrongRedstone & (1 << tSide)) != 0 ? "Strong" : "Weak")); + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); + } + return true; + } + + if (getCoverIDAtSide(aSide) == 0) { + if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { + if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(aSide, new GT_ItemStack(tCurrentItem), this) && mMetaTileEntity.allowCoverOnSide(aSide, new GT_ItemStack(tCurrentItem))) { + setCoverItemAtSide(aSide, tCurrentItem); + if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--; + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + } + return true; + } + } else { + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) { + if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(0), 1.0F, -1, xCoord, yCoord, zCoord); + dropCover(aSide, aSide, false); + } + return true; + } + } + } + + if (getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)) + return true; + + if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) + return false; + + if (isUpgradable() && aPlayer.inventory.getCurrentItem() != null) {/* + if (ItemList.Upgrade_SteamEngine.isStackEqual(aPlayer.inventory.getCurrentItem())) { + if (addSteamEngineUpgrade()) { + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); + if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; + } + return true; + }*/ + if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) { + if (addMufflerUpgrade()) { + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); + if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; + } + return true; + } + if (ItemList.Upgrade_Lock.isStackEqual(aPlayer.inventory.getCurrentItem())) { + if (isUpgradable() && !mLockUpgrade) { + mLockUpgrade = true; + setOwnerName(aPlayer.getDisplayName()); + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); + if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; + } + return true; + } + } + } + } + + try { + if (hasValidMetaTileEntity()) return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + + return true; + } + + + @Override + public void onLeftclick(EntityPlayer aPlayer) { + try { + if (aPlayer != null && hasValidMetaTileEntity()) mMetaTileEntity.onLeftclick(this, aPlayer); + } catch (Throwable e) { + GT_Log.err.println("GT++ - Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } + } + + + @Override + public boolean isDigitalChest() { + if (canAccessData()) return mMetaTileEntity.isDigitalChest(); + return false; + } + + + @Override + public ItemStack[] getStoredItemData() { + if (canAccessData()) return mMetaTileEntity.getStoredItemData(); + return null; + } + + + @Override + public void setItemCount(int aCount) { + if (canAccessData()) mMetaTileEntity.setItemCount(aCount); + } + + + @Override + public int getMaxItemCount() { + if (canAccessData()) return mMetaTileEntity.getMaxItemCount(); + return 0; + } + + /** + * Can put aStack into Slot + */ + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + return canAccessData() && mMetaTileEntity.isItemValidForSlot(aIndex, aStack); + } + + /** + * returns all valid Inventory Slots, no matter which Side (Unless it's covered). + * The Side Stuff is done in the following two Functions. + */ + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) { + if (canAccessData() && (getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this))) + return mMetaTileEntity.getAccessibleSlotsFromSide(aSide); + return new int[0]; + } + + /** + * Can put aStack into Slot at Side + */ + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return canAccessData() && (mRunningThroughTick || !mInputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); + } + + /** + * Can pull aStack out of Slot from Side + */ + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); + } + + + @Override + public boolean isUpgradable() { + return canAccessData() && getUpgradeCount() < 8; + } + + + @Override + public byte getInternalInputRedstoneSignal(byte aSide) { + return (byte) (getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) & 15); + } + + + @Override + public byte getInputRedstoneSignal(byte aSide) { + return (byte) (worldObj.getIndirectPowerLevelTo(getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide) & 15); + } + + + @Override + public byte getOutputRedstoneSignal(byte aSide) { + return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : 0; + // return (byte)(getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) || (mRedstone && getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))?mSidedRedstone[aSide]&15:0); + } + + + @Override + public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) { + if (!getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) + setOutputRedstoneSignal(aSide, aStrength); + } + + + @Override + public void setOutputRedstoneSignal(byte aSide, byte aStrength) { + aStrength = (byte) Math.min(Math.max(0, aStrength), 15); + if (aSide >= 0 && aSide < 6 && mSidedRedstone[aSide] != aStrength) { + mSidedRedstone[aSide] = aStrength; + issueBlockUpdate(); + } + } + + + @Override + public boolean isSteamEngineUpgradable() { + return isUpgradable() && !hasSteamEngineUpgrade() && getSteamCapacity() > 0; + } + + + @Override + public boolean addSteamEngineUpgrade() { + if (isSteamEngineUpgradable()) { + issueBlockUpdate(); + mSteamConverter = true; + return true; + } + return false; + } + + + @Override + public boolean hasSteamEngineUpgrade() { + if (canAccessData() && mMetaTileEntity.isSteampowered()) return true; + return mSteamConverter; + } + + + @Override + public boolean hasMufflerUpgrade() { + return mMuffler; + } + + + @Override + public boolean isMufflerUpgradable() { + return isUpgradable() && !hasMufflerUpgrade(); + } + + + @Override + public boolean addMufflerUpgrade() { + if (isMufflerUpgradable()) return mMuffler = true; + return false; + } + + + @Override + public boolean hasInventoryBeenModified() { + return mInventoryChanged; + } + + + @Override + public void setGenericRedstoneOutput(boolean aOnOff) { + mRedstone = aOnOff; + } + + + @Override + public int getErrorDisplayID() { + return mDisplayErrorCode; + } + + + @Override + public void setErrorDisplayID(int aErrorID) { + mDisplayErrorCode = aErrorID; + } + + + @Override + public IMetaTileEntity getMetaTileEntity() { + return hasValidMetaTileEntity() ? mMetaTileEntity : null; + } + + + @Override + public void setMetaTileEntity(IMetaTileEntity aMetaTileEntity) { + mMetaTileEntity = (MetaTileEntityEx) aMetaTileEntity; + } + + + @Override + public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) { + return aSide >= 0 && aSide < mCoverBehaviors.length ? mCoverBehaviors[aSide] : GregTech_API.sNoBehavior; + } + + + @Override + public void setCoverIDAtSide(byte aSide, int aID) { + if (aSide >= 0 && aSide < 6) { + mCoverSides[aSide] = aID; + mCoverData[aSide] = 0; + mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID); + issueCoverUpdate(aSide); + issueBlockUpdate(); + } + } + + + @Override + public void setCoverItemAtSide(byte aSide, ItemStack aCover) { + GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this); + } + + + @Override + public int getCoverIDAtSide(byte aSide) { + if (aSide >= 0 && aSide < 6) return mCoverSides[aSide]; + return 0; + } + + + @Override + public ItemStack getCoverItemAtSide(byte aSide) { + return GT_Utility.intToStack(getCoverIDAtSide(aSide)); + } + + + @Override + public boolean canPlaceCoverIDAtSide(byte aSide, int aID) { + return getCoverIDAtSide(aSide) == 0; + } + + + @Override + public boolean canPlaceCoverItemAtSide(byte aSide, ItemStack aCover) { + return getCoverIDAtSide(aSide) == 0; + } + + + @Override + public void setCoverDataAtSide(byte aSide, int aData) { + if (aSide >= 0 && aSide < 6) mCoverData[aSide] = aData; + } + + + @Override + public int getCoverDataAtSide(byte aSide) { + if (aSide >= 0 && aSide < 6) return mCoverData[aSide]; + return 0; + } + + + public byte getLightValue() { + return mLightValue; + } + + + @Override + public void setLightValue(byte aLightValue) { + mLightValue = (byte) (aLightValue & 15); + } + + + @Override + public long getAverageElectricInput() { + int rEU = 0; + for (int tEU : mAverageEUInput) rEU += tEU; + return rEU / mAverageEUInput.length; + } + + + @Override + public long getAverageElectricOutput() { + int rEU = 0; + for (int tEU : mAverageEUOutput) rEU += tEU; + return rEU / mAverageEUOutput.length; + } + + + @Override + public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { + if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) { + ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this); + if (tStack != null) { + tStack.setTagCompound(null); + EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack); + tEntity.motionX = 0; + tEntity.motionY = 0; + tEntity.motionZ = 0; + worldObj.spawnEntityInWorld(tEntity); + } + setCoverIDAtSide(aSide, 0); + if (mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { + setOutputRedstoneSignal(aSide, (byte) 0); + } else { + setOutputRedstoneSignal(aSide, (byte) 15); + } + return true; + } + return false; + } + + + @Override + public String getOwnerName() { + if (GT_Utility.isStringInvalid(mOwnerName)) return "Player"; + return mOwnerName; + } + + + @Override + public String setOwnerName(String aName) { + if (GT_Utility.isStringInvalid(aName)) return mOwnerName = "Player"; + return mOwnerName = aName; + } + + + @Override + public byte getComparatorValue(byte aSide) { + return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0; + } + + + @Override + public byte getStrongOutputRedstoneSignal(byte aSide) { + return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 ? (byte) (mSidedRedstone[aSide] & 15) : 0; + } + + + @Override + public void setStrongOutputRedstoneSignal(byte aSide, byte aStrength) { + mStrongRedstone |= (1 << aSide); + setOutputRedstoneSignal(aSide, aStrength); + } + + + @Override + public ItemStack decrStackSize(int aIndex, int aAmount) { + if (canAccessData()) { + mInventoryChanged = true; + return mMetaTileEntity.decrStackSize(aIndex, aAmount); + } + return null; + } + + + @Override + public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + if (!canAccessData() || !mMetaTileEntity.isElectric() || !inputEnergyFrom(aSide) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) + return 0; + if (aVoltage > getInputVoltage()) { + doExplosion(aVoltage); + return 0; + } + if (increaseStoredEnergyUnits(aVoltage * (aAmperage = Math.min(aAmperage, Math.min(mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), true)) { + mAverageEUInput[mAverageEUInputIndex] += aVoltage * aAmperage; + mAcceptedAmperes += aAmperage; + return aAmperage; + } + return 0; + } + + + @Override + public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + if (!canAccessData() || !mMetaTileEntity.isElectric() || !outputsEnergyTo(aSide) || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) + return false; + if (decreaseStoredEU(aVoltage * aAmperage, false)) { + mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage; + return true; + } + return false; + } + + + @Override + public boolean acceptsRotationalEnergy(byte aSide) { + if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; + return mMetaTileEntity.acceptsRotationalEnergy(aSide); + } + + + @Override + public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { + if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; + return mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy); + } + + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) + return mMetaTileEntity.fill(aSide, aFluid, doFill); + return 0; + } + + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this)))) + return mMetaTileEntity.drain(aSide, maxDrain, doDrain); + return null; + } + + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) + return mMetaTileEntity.drain(aSide, aFluid, doDrain); + return null; + } + + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) + return mMetaTileEntity.canFill(aSide, aFluid); + return false; + } + + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) + return mMetaTileEntity.canDrain(aSide, aFluid); + return false; + } + + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)))) + return mMetaTileEntity.getTankInfo(aSide); + return new FluidTankInfo[]{}; + } + + + public double getOutputEnergyUnitsPerTick() { + return oOutput; + } + + + public boolean isTeleporterCompatible(ForgeDirection aSide) { + return canAccessData() && mMetaTileEntity.isTeleporterCompatible(); + } + + + public double demandedEnergyUnits() { + if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; + return getEUCapacity() - getStoredEU(); + } + + + public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { + return injectEnergyUnits((byte) aDirection.ordinal(), (int) aAmount, 1) > 0 ? 0 : aAmount; + } + + + public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { + return inputEnergyFrom((byte) aDirection.ordinal()); + } + + + public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { + return outputsEnergyTo((byte) aDirection.ordinal()); + } + + + public double getOfferedEnergy() { + return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) ? Math.max(0, oOutput) : 0; + } + + + public void drawEnergy(double amount) { + mAverageEUOutput[mAverageEUOutputIndex] += amount; + decreaseStoredEU((int) amount, true); + } + + + public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { + return injectEnergyUnits((byte) aForgeDirection.ordinal(), aAmount, 1) > 0 ? 0 : aAmount; + } + + + public int addEnergy(int aEnergy) { + if (!canAccessData()) return 0; + if (aEnergy > 0) + increaseStoredEnergyUnits(aEnergy, true); + else + decreaseStoredEU(-aEnergy, true); + return (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getEUVar()); + } + + + public boolean isAddedToEnergyNet() { + return false; + } + + + public int demandsEnergy() { + if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; + return getCapacity() - getStored(); + } + + + public int getCapacity() { + return (int) Math.min(Integer.MAX_VALUE, getEUCapacity()); + } + + + public int getStored() { + return (int) Math.min(Integer.MAX_VALUE, Math.min(getStoredEU(), getCapacity())); + } + + + public void setStored(int aEU) { + if (canAccessData()) setStoredEU(aEU); + } + + + public int getMaxSafeInput() { + return (int) Math.min(Integer.MAX_VALUE, getInputVoltage()); + } + + + public int getMaxEnergyOutput() { + if (mReleaseEnergy) return Integer.MAX_VALUE; + return getOutput(); + } + + + public int getOutput() { + return (int) Math.min(Integer.MAX_VALUE, oOutput); + } + + + public int injectEnergy(Direction aDirection, int aAmount) { + return injectEnergyUnits((byte) aDirection.toSideValue(), aAmount, 1) > 0 ? 0 : aAmount; + } + + + public boolean isTeleporterCompatible(Direction aSide) { + return canAccessData() && mMetaTileEntity.isTeleporterCompatible(); + } + + + public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) { + return inputEnergyFrom((byte) aDirection.toSideValue()); + } + + + public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) { + return outputsEnergyTo((byte) aDirection.toSideValue()); + } + + + @Override + public boolean isInvalidTileEntity() { + return isInvalid(); + } + + + @Override + public boolean addStackToSlot(int aIndex, ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return true; + if (aIndex < 0 || aIndex >= getSizeInventory()) return false; + ItemStack tStack = getStackInSlot(aIndex); + if (GT_Utility.isStackInvalid(tStack)) { + setInventorySlotContents(aIndex, aStack); + return true; + } + aStack = GT_OreDictUnificator.get(aStack); + if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { + tStack.stackSize += aStack.stackSize; + return true; + } + return false; + } + + + @Override + public boolean addStackToSlot(int aIndex, ItemStack aStack, int aAmount) { + return addStackToSlot(aIndex, GT_Utility.copyAmount(aAmount, aStack)); + } + + + @Override + public byte getColorization() { + return (byte) (mColor - 1); + } + + + @Override + public byte setColorization(byte aColor) { + if (aColor > 15 || aColor < -1) aColor = -1; + if (canAccessData()) mMetaTileEntity.onColorChangeServer(aColor); + return mColor = (byte) (aColor + 1); + } + + + @Override + public float getBlastResistance(byte aSide) { + return canAccessData() ? Math.max(0, getMetaTileEntity().getExplosionResistance(aSide)) : 10.0F; + } + + + @Override + public boolean isUniversalEnergyStored(long aEnergyAmount) { + if (getUniversalEnergyStored() >= aEnergyAmount) return true; + mHasEnoughEnergy = false; + return false; + } + + + @Override + public String[] getInfoData() { + { + if (canAccessData()) return getMetaTileEntity().getInfoData(); + return new String[]{}; + } + } + + + @Override + public void markDirty() { + super.markDirty(); + mInventoryChanged = true; + } + + + @Override + public int getLightOpacity() { + return mMetaTileEntity == null ? getLightValue() > 0 ? 0 : 255 : mMetaTileEntity.getLightOpacity(); + } + + + @Override + public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { + mMetaTileEntity.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + } + + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + return mMetaTileEntity.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + + @Override + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { + mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + } +} \ No newline at end of file diff --git a/src/Java/gregtech/api/metatileentity/MetaTileEntityEx.java b/src/Java/gregtech/api/metatileentity/MetaTileEntityEx.java new file mode 100644 index 0000000000..acfcf083be --- /dev/null +++ b/src/Java/gregtech/api/metatileentity/MetaTileEntityEx.java @@ -0,0 +1,972 @@ +package gregtech.api.metatileentity; + +import static gregtech.api.enums.GT_Values.GT; +import static gregtech.api.enums.GT_Values.V; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + *

+ * Extend this Class to add a new MetaMachine + * Call the Constructor with the desired ID at the load-phase (not preload and also not postload!) + * Implement the newMetaEntity-Method to return a new ready instance of your MetaTileEntity + *

+ * Call the Constructor like the following example inside the Load Phase, to register it. + * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");" + */ +public abstract class MetaTileEntityEx implements IMetaTileEntity { + /** + * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName. + */ + public final String mName; + /** + * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO! + */ + public final ItemStack[] mInventory; + public boolean doTickProfilingInThisTick = true; + /** + * accessibility to this Field is no longer given, see below + */ + private IGregTechTileEntity mBaseMetaTileEntity; + + /** + * This registers your Machine at the List. + * Use only ID's larger than 2048, because i reserved these ones. + * See also the List in the API, as it has a Description containing all the reservations. + * + * @param aID the ID + * @example for Constructor overload. + *

+ * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) { + * super(aID, mName, mNameRegional); + * } + */ + public MetaTileEntityEx(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { + if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) + throw new IllegalAccessError("This Constructor has to be called in the load Phase"); + if (Meta_GT_Proxy.METATILEENTITIES[aID] == null) { + Meta_GT_Proxy.METATILEENTITIES[aID] = this; + } else { + Utils.LOG_INFO("Taken by: "+Meta_GT_Proxy.METATILEENTITIES[aID].getMetaName()); + throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); + } + mName = aBasicName.replaceAll(" ", "_").toLowerCase(); + setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntity()); + getBaseMetaTileEntity().setMetaTileID((short) aID); + GT_LanguageManager.addStringLocalization("gt.plusplus.blockmachines." + mName + ".name", aRegionalName); + mInventory = new ItemStack[aInvSlotCount]; + + if (GT.isClientSide()) { + ItemStack tStack = new ItemStack(ModBlocks.blockMetaTileEntity, 1, aID); + tStack.getItem().addInformation(tStack, null, new ArrayList(), true); + } + } + + /** + * This is the normal Constructor. + */ + public MetaTileEntityEx(String aName, int aInvSlotCount) { + mInventory = new ItemStack[aInvSlotCount]; + mName = aName; + } + + + @Override + public IGregTechTileEntity getBaseMetaTileEntity() { + return mBaseMetaTileEntity; + } + + + @Override + public void setBaseMetaTileEntity(IGregTechTileEntity aBaseMetaTileEntity) { + if (mBaseMetaTileEntity != null && aBaseMetaTileEntity == null) { + mBaseMetaTileEntity.getMetaTileEntity().inValidate(); + mBaseMetaTileEntity.setMetaTileEntity(null); + } + mBaseMetaTileEntity = aBaseMetaTileEntity; + if (mBaseMetaTileEntity != null) { + mBaseMetaTileEntity.setMetaTileEntity(this); + } + } + + + @Override + public ItemStack getStackForm(long aAmount) { + return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, getBaseMetaTileEntity().getMetaTileID()); + } + + public String getLocalName() { + return GT_LanguageManager.getTranslation("gt.plusplus.blockmachines." + mName + ".name"); + } + + + @Override + public void onServerStart() {/*Do nothing*/} + + + @Override + public void onWorldSave(File aSaveDirectory) {/*Do nothing*/} + + + @Override + public void onWorldLoad(File aSaveDirectory) {/*Do nothing*/} + + + @Override + public void onConfigLoad(GT_Config aConfig) {/*Do nothing*/} + + + @Override + public void setItemNBT(NBTTagCompound aNBT) {/*Do nothing*/} + + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) {/*Do nothing*/} + + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return true; + } + + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {/*Do nothing*/} + + + @Override + public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) { + getBaseMetaTileEntity().setFrontFacing(aWrenchingSide); + return true; + } + return false; + } + + + @Override + public void onExplosion() {/*Do nothing*/} + + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/} + + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} + + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} + + + @Override + public void inValidate() {/*Do nothing*/} + + + @Override + public void onRemoval() {/*Do nothing*/} + + + @Override + public void initDefaultModes(NBTTagCompound aNBT) {/*Do nothing*/} + + /** + * When a GUI is opened + */ + public void onOpenGUI() {/*Do nothing*/} + + /** + * When a GUI is closed + */ + public void onCloseGUI() {/*Do nothing*/} + + /** + * a Player rightclicks the Machine + * Sneaky rightclicks are not getting passed to this! + */ + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + return false; + } + + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + return onRightclick(aBaseMetaTileEntity, aPlayer); + } + + + @Override + public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {/*Do nothing*/} + + + @Override + public void onValueUpdate(byte aValue) {/*Do nothing*/} + + + @Override + public byte getUpdateData() { + return 0; + } + + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} + + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} + + + @Override + public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) {/*Do nothing*/} + + /** + * @return true if this Device emits Energy at all + */ + public boolean isElectric() { + return true; + } + + /** + * @return true if this Device emits Energy at all + */ + public boolean isPneumatic() { + return false; + } + + /** + * @return true if this Device emits Energy at all + */ + public boolean isSteampowered() { + return false; + } + + /** + * @return true if this Device emits Energy at all + */ + public boolean isEnetOutput() { + return false; + } + + /** + * @return true if this Device consumes Energy at all + */ + public boolean isEnetInput() { + return false; + } + + /** + * @return the amount of EU, which can be stored in this Device. Default is 0 EU. + */ + + public long maxEUStore() { + return 0; + } + + /** + * @return the amount of EU/t, which can be accepted by this Device before it explodes. + */ + + public long maxEUInput() { + return 0; + } + + /** + * @return the amount of EU/t, which can be outputted by this Device. + */ + + public long maxEUOutput() { + return 0; + } + + /** + * @return the amount of E-net Impulses of the maxEUOutput size, which can be outputted by this Device. + * Default is 1 Pulse, this shouldn't be set to smaller Values than 1, as it won't output anything in that Case! + */ + + public long maxAmperesOut() { + return 1; + } + + /** + * How many Amperes this Block can suck at max. Surpassing this value won't blow it up. + */ + + public long maxAmperesIn() { + return 1; + } + + /** + * @return true if that Side is an Output. + */ + + public boolean isOutputFacing(byte aSide) { + return false; + } + + /** + * @return true if that Side is an Input. + */ + + public boolean isInputFacing(byte aSide) { + return false; + } + + /** + * @return true if Transformer Upgrades increase Packet Amount. + */ + + public boolean isTransformingLowEnergy() { + return true; + } + + + @Override + public boolean isFacingValid(byte aFacing) { + return false; + } + + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return false; + } + + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + + @Override + public boolean setStackToZeroInsteadOfNull(int aIndex) { + return false; + } + + /** + * This is used to get the internal Energy. I use this for the IDSU. + */ + public long getEUVar() { + return ((BaseMetaTileEntityEx) mBaseMetaTileEntity).mStoredEnergy; + } + + /** + * This is used to set the internal Energy to the given Parameter. I use this for the IDSU. + */ + public void setEUVar(long aEnergy) { + ((BaseMetaTileEntityEx) mBaseMetaTileEntity).mStoredEnergy = aEnergy; + } + + /** + * This is used to get the internal Steam Energy. + */ + public long getSteamVar() { + return ((BaseMetaTileEntityEx) mBaseMetaTileEntity).mStoredSteam; + } + + /** + * This is used to set the internal Steam Energy to the given Parameter. + */ + public void setSteamVar(long aSteam) { + ((BaseMetaTileEntityEx) mBaseMetaTileEntity).mStoredSteam = aSteam; + } + + /** + * @return the amount of Steam, which can be stored in this Device. Default is 0 EU. + */ + + public long maxSteamStore() { + return 0; + } + + /** + * @return the amount of EU, which this Device stores before starting to emit Energy. + * useful if you don't want to emit stored Energy until a certain Level is reached. + */ + + public long getMinimumStoredEU() { + return 512; + } + + /** + * Determines the Tier of the Machine, used for de-charging Tools. + */ + + public long getInputTier() { + return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); + } + + /** + * Determines the Tier of the Machine, used for charging Tools. + */ + + public long getOutputTier() { + return GT_Utility.getTier(getBaseMetaTileEntity().getOutputVoltage()); + } + + /** + * gets the first RechargerSlot + */ + + public int rechargerSlotStartIndex() { + return 0; + } + + /** + * gets the amount of RechargerSlots + */ + + public int rechargerSlotCount() { + return 0; + } + + /** + * gets the first DechargerSlot + */ + + public int dechargerSlotStartIndex() { + return 0; + } + + /** + * gets the amount of DechargerSlots + */ + + public int dechargerSlotCount() { + return 0; + } + + /** + * gets if this is protected from other Players per default or not + */ + + public boolean ownerControl() { + return false; + } + + + @Override + public ArrayList getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList aList) { + return aList; + } + + + @Override + public boolean isLiquidInput(byte aSide) { + return true; + } + + + @Override + public boolean isLiquidOutput(byte aSide) { + return true; + } + + /** + * gets the contained Liquid + */ + + @Override + public FluidStack getFluid() { + return null; + } + + /** + * tries to fill this Tank + */ + + @Override + public int fill(FluidStack resource, boolean doFill) { + return 0; + } + + /** + * tries to empty this Tank + */ + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return null; + } + + /** + * Tank pressure + */ + + public int getTankPressure() { + return 0; + } + + /** + * Liquid Capacity + */ + + @Override + public int getCapacity() { + return 0; + } + + + @Override + public void onMachineBlockUpdate() {/*Do nothing*/} + + + @Override + public void receiveClientEvent(byte aEventID, byte aValue) {/*Do nothing*/} + + + @Override + public boolean isSimpleMachine() { + return false; + } + + /** + * If this accepts up to 4 Overclockers + */ + + public boolean isOverclockerUpgradable() { + return false; + } + + /** + * If this accepts Transformer Upgrades + */ + + public boolean isTransformerUpgradable() { + return false; + } + + /** + * Progress this machine has already made + */ + + public int getProgresstime() { + return 0; + } + + /** + * Progress this Machine has to do to produce something + */ + + public int maxProgresstime() { + return 0; + } + + /** + * Increases the Progress, returns the overflown Progress. + */ + + public int increaseProgress(int aProgress) { + return 0; + } + + /** + * If this TileEntity makes use of Sided Redstone behaviors. + * Determines only, if the Output Redstone Array is getting filled with 0 for true, or 15 for false. + */ + + public boolean hasSidedRedstoneOutputBehavior() { + return false; + } + + /** + * When the Facing gets changed. + */ + + public void onFacingChange() {/*Do nothing*/} + + /** + * if the IC2 Teleporter can drain from this. + */ + + public boolean isTeleporterCompatible() { + return isEnetOutput() && getBaseMetaTileEntity().getOutputVoltage() >= 128 && getBaseMetaTileEntity().getUniversalEnergyCapacity() >= 500000; + } + + /** + * Gets the Output for the comparator on the given Side + */ + + @Override + public byte getComparatorValue(byte aSide) { + return 0; + } + + + @Override + public boolean acceptsRotationalEnergy(byte aSide) { + return false; + } + + + @Override + public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { + return false; + } + + + @Override + public String getSpecialVoltageToolTip() { + return null; + } + + + @Override + public boolean isGivingInformation() { + return false; + } + + + @Override + public String[] getInfoData() { + return new String[]{}; + } + + + public boolean isDigitalChest() { + return false; + } + + + public ItemStack[] getStoredItemData() { + return null; + } + + + public void setItemCount(int aCount) {/*Do nothing*/} + + + public int getMaxItemCount() { + return 0; + } + + + @Override + public int getSizeInventory() { + return mInventory.length; + } + + + @Override + public ItemStack getStackInSlot(int aIndex) { + if (aIndex >= 0 && aIndex < mInventory.length) return mInventory[aIndex]; + return null; + } + + + @Override + public void setInventorySlotContents(int aIndex, ItemStack aStack) { + if (aIndex >= 0 && aIndex < mInventory.length) mInventory[aIndex] = aStack; + } + + + @Override + public String getInventoryName() { + if (GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()] != null) + return GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()].getMetaName(); + return ""; + } + + + @Override + public int getInventoryStackLimit() { + return 64; + } + + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + return getBaseMetaTileEntity().isValidSlot(aIndex); + } + + + @Override + public ItemStack decrStackSize(int aIndex, int aAmount) { + ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack); + if (tStack != null) { + if (tStack.stackSize <= aAmount) { + if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0; + else setInventorySlotContents(aIndex, null); + } else { + rStack = tStack.splitStack(aAmount); + if (tStack.stackSize == 0 && !setStackToZeroInsteadOfNull(aIndex)) + setInventorySlotContents(aIndex, null); + } + } + return rStack; + } + + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) { + ArrayList tList = new ArrayList(); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); + boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity); + for (int i = 0; i < getSizeInventory(); i++) + if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity))) + tList.add(i); + int[] rArray = new int[tList.size()]; + for (int i = 0; i < rArray.length; i++) rArray[i] = tList.get(i); + return rArray; + } + + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + } + + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + } + + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + return fill(aSide, new FluidStack(aFluid, 1), false) == 1; + } + + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + return drain(aSide, new FluidStack(aFluid, 1), false) != null; + } + + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{}; + return new FluidTankInfo[]{getInfo()}; + } + + + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + return fill(aFluid, doFill); + } + + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (getBaseMetaTileEntity().hasSteamEngineUpgrade() && GT_ModHandler.isSteam(aFluid) && aFluid.amount > 1) { + int tSteam = (int) Math.min(Integer.MAX_VALUE, Math.min(aFluid.amount / 2, getBaseMetaTileEntity().getSteamCapacity() - getBaseMetaTileEntity().getStoredSteam())); + if (tSteam > 0) { + if (doFill) getBaseMetaTileEntity().increaseStoredSteam(tSteam, true); + return tSteam * 2; + } + } else { + return fill_default(aSide, aFluid, doFill); + } + return 0; + } + + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + if (getFluid() != null && aFluid != null && getFluid().isFluidEqual(aFluid)) + return drain(aFluid.amount, doDrain); + return null; + } + + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + return drain(maxDrain, doDrain); + } + + + @Override + public int getFluidAmount() { + return 0; + } + + + @Override + public FluidTankInfo getInfo() { + return new FluidTankInfo(this); + } + + + @Override + public String getMetaName() { + return mName; + } + + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return null; + } + + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + + @Override + public boolean doTickProfilingMessageDuringThisTick() { + return doTickProfilingInThisTick; + } + + + @Override + public void markDirty() { + // + } + + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return false; + } + + + @Override + public void openInventory() { + // + } + + + @Override + public void closeInventory() { + // + } + + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + + @Override + public boolean connectsToItemPipe(byte aSide) { + return false; + } + + + @Override + public float getExplosionResistance(byte aSide) { + return 10.0F; + } + + + @Override + public ItemStack[] getRealInventory() { + return mInventory; + } + + + @Override + public void onColorChangeServer(byte aColor) { + // + } + + + @Override + public void onColorChangeClient(byte aColor) { + // + } + + + @Override + @SideOnly(Side.CLIENT) + public boolean renderInInventory(Block aBlock, int aMeta, RenderBlocks aRenderer) { + return false; + } + + + @Override + @SideOnly(Side.CLIENT) + public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { + return false; + } + + + @Override + public void doExplosion(long aExplosionPower) { + float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < V[4] * 2 ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F; + int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); + World tWorld = getBaseMetaTileEntity().getWorld(); + GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); + tWorld.setBlock(tX, tY, tZ, Blocks.air); + if (GregTech_API.sMachineExplosions) + tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); + } + + + @Override + public int getLightOpacity() { + return ((BaseMetaTileEntityEx) getBaseMetaTileEntity()).getLightValue() > 0 ? 0 : 255; + } + + + @Override + public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { + AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) outputAABB.add(axisalignedbb1); + } + + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); + } + + + @Override + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { + // + } + + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + // + } +} \ No newline at end of file diff --git a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachineEx.java b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachineEx.java new file mode 100644 index 0000000000..fbf59d4de5 --- /dev/null +++ b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachineEx.java @@ -0,0 +1,798 @@ +package gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.V; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_BasicMachine; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; + +import java.util.Arrays; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + *

+ * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public abstract class GT_MetaTileEntity_BasicMachineEx extends GT_MetaTileEntity_BasicTankEx { + /** + * return values for checkRecipe() + */ + protected static final int + DID_NOT_FIND_RECIPE = 0, + FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, + FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; + private static final int OTHER_SLOT_COUNT = 4; + public final ItemStack[] mOutputItems; + public final int mInputSlotCount, mAmperage; + public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; + public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public FluidStack mOutputFluid; + public String mGUIName = "", mNEIName = ""; + private NBTTagCompound mRecipeStuff = new NBTTagCompound(); + /** + * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered + */ + protected GT_Recipe mLastRecipe = null; + private FluidStack mFluidOut; + + /** + * @param aOverlays 0 = SideFacingActive + * 1 = SideFacingInactive + * 2 = FrontFacingActive + * 3 = FrontFacingInactive + * 4 = TopFacingActive + * 5 = TopFacingInactive + * 6 = BottomFacingActive + * 7 = BottomFacingInactive + * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- + * 8 = BottomFacingPipeActive + * 9 = BottomFacingPipeInactive + * 10 = TopFacingPipeActive + * 11 = TopFacingPipeInactive + * 12 = SideFacingPipeActive + * 13 = SideFacingPipeInactive + */ + public GT_MetaTileEntity_BasicMachineEx(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { + super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public GT_MetaTileEntity_BasicMachineEx(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + aTextures = Arrays.copyOf(aTextures, 14); + + for (int i = 0; i < aTextures.length; i++) + if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { + if (rTextures[i][c + 1] == null) + rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; + } + + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return mMainFacing > 1 || aFacing > 1; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public boolean isLiquidOutput(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 16; + } + + @Override + public long maxEUStore() { + return V[mTier] * 64; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxSteamStore() { + return maxEUStore(); + } + + @Override + public long maxAmperesIn() { + return (mEUt * 2) / V[mTier] + 1; + } + + @Override + public int getInputSlot() { + return OTHER_SLOT_COUNT; + } + + @Override + public int getOutputSlot() { + return OTHER_SLOT_COUNT + mInputSlotCount; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + @Override + public int rechargerSlotStartIndex() { + return 1; + } + + @Override + public int dechargerSlotStartIndex() { + return 1; + } + + @Override + public int rechargerSlotCount() { + return mCharge ? 1 : 0; + } + + @Override + public int dechargerSlotCount() { + return mDecharge ? 1 : 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + mProgresstime += aProgress; + return mMaxProgresstime - mProgresstime; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return true; + } + + @Override + public FluidStack getDisplayedFluid() { + return displaysOutputFluid() ? getDrainableStack() : null; + } + + @Override + public FluidStack getDrainableStack() { + return mFluidOut; + } + + @Override + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluidOut = aFluid; + return mFluidOut; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); + } + + @Override + public void initDefaultModes(NBTTagCompound aNBT) { + mMainFacing = -1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mFluidTransfer", mFluidTransfer); + aNBT.setBoolean("mItemTransfer", mItemTransfer); + aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); + aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mMainFacing", mMainFacing); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + aNBT.setTag("GT.CraftingComponents", mRecipeStuff); + if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); + if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); + + for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) + aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); + mItemTransfer = aNBT.getBoolean("mItemTransfer"); + mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); + mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); + mEUt = aNBT.getInteger("mEUt"); + mMainFacing = aNBT.getInteger("mMainFacing"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); + mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); + mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); + + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide()) { + mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; + mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; + + doDisplayThings(); + + boolean tSucceeded = false; + + if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { + aBaseMetaTileEntity.setActive(true); + if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { + if (++mProgresstime >= mMaxProgresstime) { + for (int i = 0; i < mOutputItems.length; i++) + for (int j = 0; j < mOutputItems.length; j++) + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) + break; + if (mOutputFluid != null) + if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); + else if (mOutputFluid.isFluidEqual(getDrainableStack())) + getDrainableStack().amount += mOutputFluid.amount; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + mEUt = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mStuttering = false; + tSucceeded = true; + endProcess(); + } + if (mProgresstime > 5) mStuttering = false; + } else { + if (!mStuttering) { + stutterProcess(); + if (canHaveInsufficientEnergy()) mProgresstime = -100; + mStuttering = true; + } + } + } else { + aBaseMetaTileEntity.setActive(false); + } + + boolean tRemovedOutputFluid = false; + + if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTank != null) { + FluidStack tDrained = drain(1000, false); + if (tDrained != null) { + int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + if (tFilledAmount > 0) + tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); + } + } + if (getDrainableStack() == null) tRemovedOutputFluid = true; + } + + if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { + TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); + for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { + tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); + } + } + + if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; + else mOutputBlocked++; + + if (allowToCheckRecipe()) { + if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { + if (checkRecipe() == 2) { + if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + for (int i = 0; i < mOutputItems.length; i++) { + mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); + if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) + mOutputItems[i].stackSize = 64; + mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); + } + if (mFluid != null && mFluid.amount <= 0) mFluid = null; + mMaxProgresstime = Math.max(1, mMaxProgresstime); + if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { + mEUt = mMaxProgresstime = 1; + } + startProcess(); + } else { + mMaxProgresstime = 0; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + } + } + } else { + if (!mStuttering) { + stutterProcess(); + mStuttering = true; + } + } + } + } + + protected void doDisplayThings() { + if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { + mMainFacing = getBaseMetaTileEntity().getFrontFacing(); + } + if (mMainFacing >= 2 && !mHasBeenUpdated) { + mHasBeenUpdated = true; + getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); + } + + if (displaysInputFluid()) { + int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + if (getFillableStack() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) + mInventory[tDisplayStackSlot] = null; + } else { + mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); + } + } + } + + protected boolean hasEnoughEnergyToCheckRecipe() { + return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); + } + + protected boolean drainEnergyForProcess(long aEUt) { + return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); + } + + protected void calculateOverclockedNess(GT_Recipe aRecipe) { + calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); + } + + protected void calculateOverclockedNess(int aEUt, int aDuration) { + if (aEUt <= 16) { + mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); + mMaxProgresstime = aDuration / (1 << (mTier - 1)); + } else { + mEUt = aEUt; + mMaxProgresstime = aDuration; + while (mEUt <= V[mTier - 1] * mAmperage) { + mEUt *= 4; + mMaxProgresstime /= 2; + } + } + } + + protected ItemStack getSpecialSlot() { + return mInventory[3]; + } + + protected ItemStack getOutputAt(int aIndex) { + return mInventory[getOutputSlot() + aIndex]; + } + + protected ItemStack[] getAllOutputs() { + ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; + for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); + return rOutputs; + } + + protected boolean canOutput(GT_Recipe aRecipe) { + return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); + } + + protected boolean canOutput(ItemStack... aOutputs) { + if (aOutputs == null) return true; + ItemStack[] tOutputSlots = getAllOutputs(); + for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) + if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { + mOutputBlocked++; + return false; + } + return true; + } + + protected boolean canOutput(FluidStack aOutput) { + return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); + } + + protected ItemStack getInputAt(int aIndex) { + return mInventory[getInputSlot() + aIndex]; + } + + protected ItemStack[] getAllInputs() { + ItemStack[] rInputs = new ItemStack[mInputSlotCount]; + for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); + return rInputs; + } + + protected boolean isOutputEmpty() { + boolean rIsEmpty = true; + for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; + return rIsEmpty; + } + + protected boolean displaysInputFluid() { + return true; + } + + protected boolean displaysOutputFluid() { + return true; + } + + @Override + public void onValueUpdate(byte aValue) { + mMainFacing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) mMainFacing; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + super.doSound(aIndex, aX, aY, aZ); + if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); + } + + public boolean doesAutoOutput() { + return mItemTransfer; + } + + public boolean doesAutoOutputFluids() { + return mFluidTransfer; + } + + public boolean allowToCheckRecipe() { + return true; + } + + public boolean showPipeFacing() { + return true; + } + + /** + * Called whenever the Machine successfully started a Process, useful for Sound Effects + */ + public void startProcess() { + // + } + + /** + * Called whenever the Machine successfully finished a Process, useful for Sound Effects + */ + public void endProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process, useful for Sound Effects + */ + public void abortProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects + */ + public void stutterProcess() { + if (useStandardStutterSound()) sendSound((byte) 8); + } + + /** + * If this Machine can have the Insufficient Energy Line Problem + */ + public boolean canHaveInsufficientEnergy() { + return true; + } + + public boolean useStandardStutterSound() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + mRecipeStuff.toString(), + mNEIName, + "Progress:", (mProgresstime / 20) + " secs", + (mMaxProgresstime / 20) + " secs", + "Stored Energy:", + getBaseMetaTileEntity().getStoredEU() + "EU", + getBaseMetaTileEntity().getEUCapacity() + "EU"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { + mAllowInputFromOutputSide = !mAllowInputFromOutputSide; + GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); + } + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) + return false; + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; + return true; + } + + /** + * @return the Recipe List which is used for this Machine, this is a useful Default Handler + */ + public GT_Recipe_Map getRecipeList() { + return null; + } + + /** + * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case + *

+ * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. + *

+ * Funny how Eclipse marks the word Enum as not correctly spelled. + * + * @return see constants above + */ + public int checkRecipe() { + GT_Recipe_Map tMap = getRecipeList(); + if (tMap == null) return DID_NOT_FIND_RECIPE; + GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); + if (tRecipe == null) return DID_NOT_FIND_RECIPE; + if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; + if (!canOutput(tRecipe)) { + mOutputBlocked++; + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + + for (int i = 0; i < mOutputItems.length; i++) + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) + mOutputItems[i] = tRecipe.getOutput(i); + mOutputFluid = tRecipe.getFluidOutput(0); + calculateOverclockedNess(tRecipe); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } +} \ No newline at end of file diff --git a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTankEx.java b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTankEx.java new file mode 100644 index 0000000000..46f347cba2 --- /dev/null +++ b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTankEx.java @@ -0,0 +1,251 @@ +package gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.ItemList; +import gregtech.api.gui.GT_Container_BasicTank; +import gregtech.api.gui.GT_GUIContainer_BasicTank; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + *

+ * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually + */ +public abstract class GT_MetaTileEntity_BasicTankEx extends GT_MetaTileEntity_TieredMachineBlockEx { + + public FluidStack mFluid; + + /** + * @param aInvSlotCount should be 3 + */ + public GT_MetaTileEntity_BasicTankEx(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_BasicTankEx(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex != getStackDisplaySlot(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + } + + public abstract boolean doesFillContainers(); + + public abstract boolean doesEmptyContainers(); + + public abstract boolean canTankBeFilled(); + + public abstract boolean canTankBeEmptied(); + + public abstract boolean displaysItemStack(); + + public abstract boolean displaysStackSize(); + + public int getInputSlot() { + return 0; + } + + public int getOutputSlot() { + return 1; + } + + public int getStackDisplaySlot() { + return 2; + } + + public boolean isFluidInputAllowed(FluidStack aFluid) { + return true; + } + + public boolean isFluidChangingAllowed() { + return true; + } + + public FluidStack getFillableStack() { + return mFluid; + } + + public FluidStack setFillableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; + } + + public FluidStack getDrainableStack() { + return mFluid; + } + + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; + } + + public FluidStack getDisplayedFluid() { + return getDrainableStack(); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) + setFillableStack(null); + + if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { + if (getDisplayedFluid() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) + mInventory[getStackDisplaySlot()] = null; + } else { + mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); + } + } + + if (doesEmptyContainers()) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); + if (tFluid != null && isFluidInputAllowed(tFluid)) { + if (getFillableStack() == null) { + if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + setFillableStack(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + getFillableStack().amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + } + + if (doesFillContainers()) { + ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); + if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + if (tFluid != null) getDrainableStack().amount -= tFluid.amount; + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); + } + } + } + } + + @Override + public FluidStack getFluid() { + return getDrainableStack(); + } + + @Override + public int getFluidAmount() { + return getDrainableStack() != null ? getDrainableStack().amount : 0; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) + return 0; + + if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { + if (aFluid.amount <= getCapacity()) { + if (doFill) { + setFillableStack(aFluid.copy()); + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + setFillableStack(aFluid.copy()); + getFillableStack().amount = getCapacity(); + getBaseMetaTileEntity().markDirty(); + } + return getCapacity(); + } + + if (!getFillableStack().isFluidEqual(aFluid)) + return 0; + + int space = getCapacity() - getFillableStack().amount; + if (aFluid.amount <= space) { + if (doFill) { + getFillableStack().amount += aFluid.amount; + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) + getFillableStack().amount = getCapacity(); + return space; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (getDrainableStack() == null || !canTankBeEmptied()) return null; + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { + setDrainableStack(null); + getBaseMetaTileEntity().markDirty(); + return null; + } + + int used = maxDrain; + if (getDrainableStack().amount < used) + used = getDrainableStack().amount; + + if (doDrain) { + getDrainableStack().amount -= used; + getBaseMetaTileEntity().markDirty(); + } + + FluidStack drained = getDrainableStack().copy(); + drained.amount = used; + + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { + setDrainableStack(null); + getBaseMetaTileEntity().markDirty(); + } + + return drained; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getOutputSlot(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getInputSlot(); + } +} \ No newline at end of file diff --git a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlockEx.java b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlockEx.java new file mode 100644 index 0000000000..7e70c8dafb --- /dev/null +++ b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlockEx.java @@ -0,0 +1,67 @@ +package gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.GT; +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.MetaTileEntityEx; + +public abstract class GT_MetaTileEntity_TieredMachineBlockEx extends MetaTileEntityEx { + /** + * 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 GT_MetaTileEntity_TieredMachineBlockEx(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 GT_MetaTileEntity_TieredMachineBlockEx(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/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 537dc7963f..89988a1248 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -15,6 +15,7 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import gtPlusPlus.core.commands.CommandMath; import gtPlusPlus.core.common.CommonProxy; +import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.handler.events.LoginEventHandler; import gtPlusPlus.core.item.general.RF2EU_Battery; import gtPlusPlus.core.lib.CORE; @@ -165,6 +166,8 @@ implements ActionListener Utils.LOG_INFO("Activating GT OreDictionary Handler, this can take some time."); Utils.LOG_INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Utils.LOG_INFO("| Recipes succesfully Loaded: "+RegistrationHandler.recipesSuccess+" | Failed: "+RegistrationHandler.recipesFailed + " |"); + Utils.LOG_INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Meta_GT_Proxy.activateOreDictHandler(); Utils.LOG_INFO("Finally, we are finished. Have some cripsy bacon as a reward."); } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index fd7d005e55..27488794bc 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -21,6 +21,7 @@ import gtPlusPlus.core.item.general.fuelrods.FuelRod_Base; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.tool.misc.SandstoneHammer; import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; import gtPlusPlus.core.item.tool.staballoy.StaballoyAxe; import gtPlusPlus.core.item.tool.staballoy.StaballoyPickaxe; import gtPlusPlus.core.lib.CORE; @@ -109,6 +110,7 @@ public final class ModItems { public static Item itemPersonalHealingDevice; public static MultiPickaxeBase MP_GTMATERIAL; + public static MultiSpadeBase MS_GTMATERIAL; public static ItemStack FluidCell; @@ -231,8 +233,15 @@ public final class ModItems { boolean gtStyleTools = LoadedMods.Gregtech; + + Materials[] rm = Materials.values(); + for (Materials m : rm){ + MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, m); + MS_GTMATERIAL = UtilsItems.generateMultiShovel(gtStyleTools, m); + } + - MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Wood); + /*MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Wood); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Cobblestone); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Iron); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.WroughtIron); @@ -277,7 +286,7 @@ public final class ModItems { MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.BlueSteel); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Neodymium); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Desh); - MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.ElectrumFlux); + MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.ElectrumFlux);*/ //EnderIO Resources if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){ diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java index 60353f2d1b..2978579d0b 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -37,6 +37,7 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ protected ItemStack thisPickaxe = null; protected final int colour; protected final String materialName; + public boolean isValid = true; public MultiPickaxeBase(String unlocalizedName, ToolMaterial material, int materialDurability, int colour) { super(Utils.sanitizeString(unlocalizedName), material); @@ -46,12 +47,15 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ this.setMaxStackSize(1); this.setMaxDamage(materialDurability); this.colour = colour; - this.materialName = material.name(); - GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + this.materialName = material.name(); this.setCreativeTab(AddToCreativeTab.tabTools); - try {addRecipe();} catch (Throwable e){} + try {isValid = addRecipe();} catch (Throwable e){} + if (colour != 0 && isValid){ + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + } + } - + /* * * @@ -61,25 +65,35 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ * * */ - - private void addRecipe(){ + + private boolean addRecipe(){ String plateDense = "plateDense"+materialName; String rodLong = "stickLong"+materialName; String toolHammer = "craftingToolHardHammer"; String toolWrench = "craftingToolWrench"; String toolFile = "craftingToolFile"; String toolScrewDriver = "craftingToolScrewdriver"; + + if (null == UtilsItems.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ + return false; + } + if (null == UtilsItems.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)){ + return false; + } + UtilsRecipe.recipeBuilder( plateDense, plateDense, plateDense, toolFile, rodLong, toolHammer, toolWrench, rodLong, toolScrewDriver, UtilsItems.getSimpleStack(this)); + + return true; } - + public final String getMaterialName() { return materialName; } - + @Override public String getItemStackDisplayName(ItemStack iStack) { @@ -113,7 +127,7 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ return colour; } - + @SuppressWarnings("static-method") private float calculateDurabilityLoss(World world, int X, int Y, int Z){ float bDurabilityLoss = 0; @@ -127,7 +141,7 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ bHardness = removalist.getBlockHardness(world, X, Y, Z)*100; Utils.LOG_WARNING("Hardness: "+bHardness); - bDurabilityLoss = bHardness; + bDurabilityLoss = 100; //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); correctTool = canPickaxeBlock(removalist, world); @@ -154,21 +168,21 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ Utils.LOG_WARNING(block.toString()); String removalTool = ""; removalTool = block.getHarvestTool(1); - + if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block)){ if (canPickaxeBlock(block, world)){ if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ - + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ - - block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); - world.setBlockToAir(X, Y, Z); - + + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + } else { return; } - + } } else { @@ -179,13 +193,15 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ } } - - - @Override + public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ - item.damageItem(damage*100, localPlayer); + item.damageItem(damage, localPlayer); } - + + public void setItemDamage(ItemStack item, int damage){ + item.setItemDamage(damage-1); + } + @Override @SideOnly(Side.CLIENT) diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java new file mode 100644 index 0000000000..972ba0ca12 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java @@ -0,0 +1,115 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MultiSpadeBase extends StaballoySpade{ + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0){ + return super.getDurabilityForDisplay(stack);} + return 0; + } + + protected Boolean FACING_HORIZONTAL = true; + protected String FACING = "north"; + protected EntityPlayer localPlayer; + protected String lookingDirection; + protected World localWorld; + protected ItemStack thisPickaxe = null; + protected final int colour; + protected final String materialName; + public boolean isValid = true; + + public MultiSpadeBase(String unlocalizedName, ToolMaterial material, int materialDurability, int colour) { + super(Utils.sanitizeString(unlocalizedName), material); + this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); + this.setTextureName(CORE.MODID + ":" + "itemShovel"); + this.FACING_HORIZONTAL=true; + this.setMaxStackSize(1); + this.setMaxDamage(materialDurability); + this.colour = colour; + this.materialName = material.name(); + this.setCreativeTab(AddToCreativeTab.tabTools); + try {isValid = addRecipe();} catch (Throwable e){} + if (colour != 0 && isValid){ + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + } + } + + private boolean addRecipe(){ + String plateDense = "plateDense"+materialName; + String rodLong = "stickLong"+materialName; + String toolHammer = "craftingToolHardHammer"; + String toolWrench = "craftingToolWrench"; + String toolFile = "craftingToolFile"; + String toolScrewDriver = "craftingToolScrewdriver"; + + if (null == UtilsItems.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ + return false; + } + if (null == UtilsItems.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)){ + return false; + } + + UtilsRecipe.recipeBuilder( + toolFile, plateDense, toolHammer, + null, rodLong, null, + toolWrench, rodLong, toolScrewDriver, + UtilsItems.getSimpleStack(this)); + + return true; + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public String getItemStackDisplayName(ItemStack iStack) { + + String name; + if (getUnlocalizedName().toLowerCase().contains("wood")){ + name = "Wooden"; + } + else { + name = materialName; + } + return "Big "+name+" Spade"; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java index d20ad259e7..46e727edd1 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java @@ -99,7 +99,7 @@ public class StaballoyPickaxe extends ItemPickaxe{ } } - return bDurabilityLoss; + return 100; } public Boolean canPickaxeBlock(Block currentBlock, World currentWorld){ @@ -158,16 +158,48 @@ public class StaballoyPickaxe extends ItemPickaxe{ } //int heldItemDurability = heldItem.getDamage(1); - Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS); + Utils.LOG_INFO("Total Loss: "+(int)DURABILITY_LOSS); //heldItem.setDamage(heldStack, DURABILITY_LOSS); //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); //Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); - if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-DURABILITY_LOSS)){ - damageItem(heldItem, (int) DURABILITY_LOSS, localPlayer); + Utils.LOG_INFO("1x: "+(heldItem.getItemDamage())); + int itemdmg = heldItem.getItemDamage(); + int maxdmg = heldItem.getMaxDamage(); + int dodmg = (int)DURABILITY_LOSS; + int durNow = (int) maxdmg-itemdmg; + int durLeft = (int) ((maxdmg-itemdmg)-DURABILITY_LOSS); + + Utils.LOG_INFO( + "Current Damage: " + itemdmg + + " Max Damage: " + maxdmg + + " Durability to be lost: " + dodmg + + " Current Durability: " + durNow + + " Remaining Durability: " + durLeft + ); + + + //Break Tool + if ((durNow-dodmg) <= (900) && itemdmg != 0){ + //TODO break tool + Utils.LOG_INFO("Breaking Tool"); + heldItem.stackSize = 0; } + //Do Damage else { - damageItem(heldItem, heldItem.getMaxDamage()-heldItem.getItemDamage(), localPlayer); + //setItemDamage(heldItem, durLeft); + Utils.LOG_INFO(""+(durNow-durLeft)); + damageItem(heldItem, (durNow-durLeft)-1, localPlayer); + } + + + /*if (heldItem.getItemDamage() <= ((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)){ + Utils.LOG_INFO("2: "+DURABILITY_LOSS+" 3: "+((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)); + setItemDamage(heldItem, (int) (heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)); } + else { + Utils.LOG_INFO("3: "+( heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage()))); + setItemDamage(heldItem, heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())); + }*/ //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); DURABILITY_LOSS = 0; @@ -177,6 +209,10 @@ public class StaballoyPickaxe extends ItemPickaxe{ public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ item.damageItem(damage, localPlayer); } + + public void setItemDamage(ItemStack item, int damage){ + item.setItemDamage(damage-1); + } //Should clear up blocks quicker if I chain it. public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java new file mode 100644 index 0000000000..79eac5816b --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java @@ -0,0 +1,316 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.UtilsMining; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemSpade; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class StaballoySpade extends ItemSpade{ + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0){ + return super.getDurabilityForDisplay(stack);} + return 0; + } + + protected Boolean FACING_HORIZONTAL = true; + protected String FACING = "north"; + protected EntityPlayer localPlayer; + protected String lookingDirection; + protected World localWorld; + public ItemStack thisPickaxe = null; + + /* + * + * + * + * Methods + * + * + * + */ + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) { + localPlayer = aPlayer; + localWorld = world; + thisPickaxe = stack; + return super.onItemRightClick(stack, world, aPlayer); + } + + + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int X, int Y, int Z, EntityLivingBase entity) { + //super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); + localWorld = world; + thisPickaxe = stack; + //checkFacing(world); + if (!world.isRemote){ + GetDestroyOrientation(lookingDirection, world, X, Y, Z, stack); + } + + return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); + } + + public Boolean canPickaxeBlock(Block currentBlock, World currentWorld){ + String correctTool = ""; + if (!currentWorld.isRemote){ + try { + correctTool = currentBlock.getHarvestTool(0); + //Utils.LOG_WARNING(correctTool); + + Utils.LOG_INFO("Tool for Block: "+correctTool+" | Current block: "+currentBlock.getLocalizedName()); + if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("shovel")){ + return true;} + } catch (NullPointerException e){ + return false;} + } + return false; + } + + private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + float DURABILITY_LOSS = 0; + if (!world.isRemote){ + + if (FACING.equals("below") || FACING.equals("above")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + DURABILITY_LOSS = (DURABILITY_LOSS + removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem)); + } + } + } + + else if (FACING.equals("facingEast") || FACING.equals("facingWest")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + DURABILITY_LOSS = (DURABILITY_LOSS + removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem)); + } + } + } + + else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + DURABILITY_LOSS = (DURABILITY_LOSS + removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem)); + } + } + } + + //int heldItemDurability = heldItem.getDamage(1); + Utils.LOG_INFO("Total Loss: "+(int)DURABILITY_LOSS); + //heldItem.setDamage(heldStack, DURABILITY_LOSS); + //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + //Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); + Utils.LOG_INFO("1x: "+(heldItem.getItemDamage())); + int itemdmg = heldItem.getItemDamage(); + int maxdmg = heldItem.getMaxDamage(); + int dodmg = (int)DURABILITY_LOSS; + int durNow = (int) maxdmg-itemdmg; + int durLeft = (int) ((maxdmg-itemdmg)-DURABILITY_LOSS); + + Utils.LOG_INFO( + "Current Damage: " + itemdmg + + " Max Damage: " + maxdmg + + " Durability to be lost: " + dodmg + + " Current Durability: " + durNow + + " Remaining Durability: " + durLeft + ); + + + //Break Tool + if ((durNow-dodmg) <= (900) && itemdmg != 0){ + //TODO break tool + Utils.LOG_INFO("Breaking Tool"); + heldItem.stackSize = 0; + } + //Do Damage + else { + //setItemDamage(heldItem, durLeft); + Utils.LOG_INFO(""+(durNow-durLeft)); + damageItem(heldItem, (durNow-durLeft)-1, localPlayer); + } + DURABILITY_LOSS = 0; + + } + } + + public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ + item.damageItem(damage, localPlayer); + } + + public void setItemDamage(ItemStack item, int damage){ + item.setItemDamage(damage-1); + } + + //Should clear up blocks quicker if I chain it. + public int removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + Utils.LOG_INFO("Trying to drop/remove a block."); + try { + Block block = world.getBlock(X, Y, Z); + Utils.LOG_WARNING(block.toString()); + String removalTool = ""; + removalTool = block.getHarvestTool(0); + if (removalTool != null){ + if (removalTool.equals("shovel")){ + if (canPickaxeBlock(block, world)){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + + int itemdmg = heldItem.getItemDamage(); + int maxdmg = heldItem.getMaxDamage(); + int dodmg = (int)100; + int durNow = (int) maxdmg-itemdmg; + int durLeft = (int) ((maxdmg-itemdmg)-100); + + if ((durNow-dodmg) <= (900) && itemdmg != 0){ + //Do Nothing, Tool is useless. + return 0; + } + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + Utils.LOG_INFO("Adding 100 damage to item."); + return 100; + } + Utils.LOG_INFO("Incorrect Tool for mining this block. Wrong Block Water/lava/bedrock/blacklist"); + return 0; + } + Utils.LOG_INFO("Incorrect Tool for mining this block. Cannot Shovel this block type."); + return 0; + } + Utils.LOG_INFO("Incorrect Tool for mining this block. Blocks mining tool is now Shovel."); + return 0; + } + Utils.LOG_INFO("Either the block was air or it declares an invalid mining tool."); + return 0; + } catch (NullPointerException e){ + Utils.LOG_INFO("Something Broke"); + e.printStackTrace(); + return 0; + } + } + + public boolean checkFacing(World world){ + localWorld = world; + if (localPlayer != null){ + int direction = MathHelper.floor_double((double)((localPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3; + //Utils.LOG_WARNING("Player - F: "+direction); + //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); + + /*if (localPlayer.getLookVec().yCoord > 0){ + localPlayer.getLookVec().yCoord; + }*/ + + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, (EntityPlayer) localPlayer, false); + if (movingobjectposition != null){ + int sideHit = movingobjectposition.sideHit; + String playerStandingPosition = ""; + if (movingobjectposition != null) { + //System.out.println("Side Hit: "+movingobjectposition.sideHit); + } + + if (sideHit == 0){ + playerStandingPosition = "above"; + FACING_HORIZONTAL = false; + } + else if (sideHit == 1){ + playerStandingPosition = "below"; + FACING_HORIZONTAL = false; + } + else if (sideHit == 2){ + playerStandingPosition = "facingSouth"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 3){ + playerStandingPosition = "facingNorth"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 4){ + playerStandingPosition = "facingEast"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 5){ + playerStandingPosition = "facingWest"; + FACING_HORIZONTAL = true; + } + lookingDirection = playerStandingPosition; + + if (direction == 0){ + FACING = "south"; + } + else if (direction == 1){ + FACING = "west"; + } + else if (direction == 2){ + FACING = "north"; + } + else if (direction == 3){ + FACING = "east"; + } + } + + + return true; + } + return false; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + thisPickaxe = stack; + list.add(EnumChatFormatting.GOLD+"Spades a 3x3 area in the direction you are facing."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + + + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer aPlayer) { + thisPickaxe = itemstack; + localPlayer = aPlayer; + checkFacing(localPlayer.worldObj); + return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); + } + public StaballoySpade(String unlocalizedName, ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.FACING_HORIZONTAL=true; + this.setMaxStackSize(1); + this.setMaxDamage(3200); + } +} diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index a1c6f4405a..777bf16dc0 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -7,15 +7,10 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.config.Configuration; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class CORE { @@ -34,10 +29,7 @@ public class CORE { @Deprecated public static IGregtech_RecipeAdder sRecipeAdder; public static GregtechRecipe GT_Recipe = new GregtechRecipe(); - - @SideOnly(Side.CLIENT) - public static IIconRegister GT_BlockIcons, GT_ItemIcons; - public static List GT_BlockIconload = new ArrayList(); + public static Configuration Config; public static final String GT_Tooltip = "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus "+EnumChatFormatting.GRAY+"- "+EnumChatFormatting.RED+"[GT++]"; public static final String GT_Tooltip_Radioactive = EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.GREEN+"Radioactive! "+EnumChatFormatting.GOLD+" Avoid direct handling without hazmat protection."; diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java index 197482f1ae..52392aeb00 100644 --- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java +++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java @@ -20,6 +20,7 @@ import gtPlusPlus.core.item.base.rods.BaseItemRodLong; import gtPlusPlus.core.item.base.rotors.BaseItemRotor; import gtPlusPlus.core.item.base.screws.BaseItemScrew; import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; @@ -372,7 +373,45 @@ public class UtilsItems { Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) ); - return MP_Redstone; + if (MP_Redstone.isValid){ + return MP_Redstone; + } + return null; + + } + + public static MultiSpadeBase generateMultiShovel(boolean GT_Durability, Materials material){ + ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); + Utils.LOG_INFO("Generating a Multi-Shovel out of "+material.name()); + short[] rgb; + rgb = material.getRGBA(); + int dur = customMaterial.getMaxUses(); + Utils.LOG_INFO("Determined durability for "+material.name()+" is "+dur); + if (GT_Durability){ + dur = material.mDurability*100; + Utils.LOG_INFO("Using gregtech durability value, "+material.name()+" is now "+dur+"."); + } + else if (dur <= 0){ + dur = material.mDurability; + Utils.LOG_INFO("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); + } + + if (dur <= 0){ + Utils.LOG_INFO("Still too low, "+material.name()+" will now go unused."); + return null; + } + + MultiSpadeBase MP_Redstone = new MultiSpadeBase( + material.name()+" Multishovel", + (customMaterial), + dur, + Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) + ); + + if (MP_Redstone.isValid){ + return MP_Redstone; + } + return null; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java index 705f5b338e..dca5d7301c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java @@ -1,9 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.enums; -import gregtech.api.GregTech_API; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_IconContainer; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_Texture; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; @@ -51,7 +51,7 @@ public class GregtechTextures { protected IIcon mIcon; private BlockIcons() { - CORE.GT_BlockIconload.add(this); + Meta_GT_Proxy.GT_BlockIconload.add(this); } @Override @@ -66,7 +66,7 @@ public class GregtechTextures { @Override public void run() { - mIcon = GregTech_API.sBlockIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this); + mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this); } @Override @@ -80,7 +80,7 @@ public class GregtechTextures { public CustomIcon(String aIconName) { mIconName = aIconName; - CORE.GT_BlockIconload.add(this); + Meta_GT_Proxy.GT_BlockIconload.add(this); } @Override @@ -95,7 +95,7 @@ public class GregtechTextures { @Override public void run() { - mIcon = CORE.GT_BlockIcons.registerIcon(CORE.MODID + ":" + mIconName); + mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + mIconName); } @Override @@ -107,10 +107,12 @@ public class GregtechTextures { public enum ItemIcons implements Interface_IconContainer, Runnable { - VOID // The Empty Texture - , RENDERING_ERROR, SKOOKUMCHOOCHER, DURABILITY_BAR_0, DURABILITY_BAR_1, DURABILITY_BAR_2, DURABILITY_BAR_3, DURABILITY_BAR_4, DURABILITY_BAR_5, DURABILITY_BAR_6, DURABILITY_BAR_7, DURABILITY_BAR_8, ENERGY_BAR_0, ENERGY_BAR_1, ENERGY_BAR_2, ENERGY_BAR_3, ENERGY_BAR_4, ENERGY_BAR_5, ENERGY_BAR_6, ENERGY_BAR_7, ENERGY_BAR_8, TURBINE, TURBINE_SMALL, TURBINE_LARGE, TURBINE_HUGE; + VOID, // The Empty Texture + RENDERING_ERROR, //The Purple/Black Texture + SKOOKUMCHOOCHER, //The Skookum Tool Texture + TURBINE_SMALL, TURBINE_LARGE, TURBINE_HUGE; - public static final Interface_IconContainer[] + /* public static final Interface_IconContainer[] DURABILITY_BAR = new Interface_IconContainer[]{ DURABILITY_BAR_0, DURABILITY_BAR_1, @@ -132,14 +134,14 @@ public class GregtechTextures { ENERGY_BAR_6, ENERGY_BAR_7, ENERGY_BAR_8, - }; + };*/ //public static final Interface_Texture[] ERROR_RENDERING = new Interface_Texture[]{new GregtechRenderedTexture(RENDERING_ERROR)}; protected IIcon mIcon, mOverlay; private ItemIcons() { - GregTech_API.sGTItemIconload.add(this); + Meta_GT_Proxy.GT_ItemIconload.add(this); } @Override @@ -159,8 +161,8 @@ public class GregtechTextures { @Override public void run() { - mIcon = GregTech_API.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this); - mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this + "_OVERLAY"); + mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this); + mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this + "_OVERLAY"); } public static class CustomIcon implements Interface_IconContainer, Runnable { @@ -169,7 +171,7 @@ public class GregtechTextures { public CustomIcon(String aIconName) { mIconName = aIconName; - GregTech_API.sGTItemIconload.add(this); + Meta_GT_Proxy.GT_ItemIconload.add(this); } @Override @@ -184,8 +186,8 @@ public class GregtechTextures { @Override public void run() { - mIcon = GregTech_API.sItemIcons.registerIcon(CORE.MODID+ ":" + mIconName); - mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.MODID+ ":" + mIconName + "_OVERLAY"); + mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + mIconName); + mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + mIconName + "_OVERLAY"); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 05abaa00da..98fcc6d6bb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -11,6 +11,7 @@ import gregtech.api.enums.SubTag; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.ToolDictNames; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntityEx; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.GT_Log; @@ -34,6 +35,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -41,12 +43,22 @@ import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class Meta_GT_Proxy { //Store Some MetaTileEntity Data here, why not? public static final IMetaTileEntity[] METATILEENTITIES = new IMetaTileEntity[GregTech_API.MAXIMUM_METATILE_IDS]; + public static List GT_BlockIconload = new ArrayList(); + public static List GT_ItemIconload = new ArrayList(); + + + + @SideOnly(Side.CLIENT) + public static IIconRegister sBlockIcons, sItemIcons; + //Silly Vars private static final Collection mIgnoredItems = new HashSet(Arrays.asList(new String[]{"itemGhastTear", "itemFlint", "itemClay", "itemBucketSaltWater", "itemBucketFreshWater", "itemBucketWater", "itemRock", "itemReed", "itemArrow", "itemSaw", "itemKnife", "itemHammer", "itemChisel", "itemRubber", @@ -899,6 +911,25 @@ public class Meta_GT_Proxy { } + /** + * This gives you a new BaseMetaTileEntity. As some Interfaces are not always loaded (Buildcraft, Univeral Electricity) I have to use Invocation at the Constructor of the BaseMetaTileEntity + */ + private static Class sBaseMetaTileEntityClass = null; + public static BaseMetaTileEntityEx constructBaseMetaTileEntity() { + if (sBaseMetaTileEntityClass == null) { + try { + return (BaseMetaTileEntityEx) (sBaseMetaTileEntityClass = BaseMetaTileEntityEx.class).newInstance(); + } catch (Throwable e) {/*Do nothing*/} + } + + try { + return (BaseMetaTileEntityEx) (sBaseMetaTileEntityClass.newInstance()); + } catch (Throwable e) { + Utils.LOG_INFO("Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + e.printStackTrace(GT_Log.err); + throw new RuntimeException(e); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java index 9c6a780952..0b47d3c5c1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java @@ -8,9 +8,8 @@ import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_Generic_Block; import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntityEx; import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.util.GT_BaseCrop; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gregtech.common.blocks.GT_Item_Machines; @@ -108,7 +107,7 @@ public class GregtechBlockMachines @Override public String getUnlocalizedName() { - return "gt.blockmachines"; + return "gt.plusplus.blockmachines"; } @Override @@ -240,12 +239,12 @@ public class GregtechBlockMachines super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); } - @Override - @SideOnly(Side.CLIENT) + @Override //TODO + @SideOnly(Side.CLIENT) //TODO public void registerBlockIcons(IIconRegister aIconRegister) { - //if (GregTech_API.sPostloadFinished) { + if (GregTech_API.sPostloadFinished) { Utils.LOG_INFO("Setting up Icon Register for Blocks"); - GregTech_API.sBlockIcons = aIconRegister; + Meta_GT_Proxy.sBlockIcons = aIconRegister; Utils.LOG_INFO("Registering MetaTileEntity specific Textures"); for (IMetaTileEntity tMetaTileEntity : Meta_GT_Proxy.METATILEENTITIES) { @@ -257,17 +256,10 @@ public class GregtechBlockMachines e.printStackTrace(GT_Log.err); } } - Utils.LOG_INFO("Registering Crop specific Textures"); - try { - for (GT_BaseCrop tCrop : GT_BaseCrop.sCropList) { - tCrop.registerSprites(aIconRegister); - } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } + Utils.LOG_INFO("Starting Block Icon Load Phase"); System.out.println("Starting Block Icon Load Phase"); - for (Runnable tRunnable : GregTech_API.sGTBlockIconload) { + for (Runnable tRunnable : Meta_GT_Proxy.GT_BlockIconload) { try { tRunnable.run(); } catch (Throwable e) { @@ -276,7 +268,7 @@ public class GregtechBlockMachines } Utils.LOG_INFO("Finished Block Icon Load Phase"); System.out.println("Finished Block Icon Load Phase"); - // } + } } @Override @@ -287,7 +279,7 @@ public class GregtechBlockMachines @Override public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof BaseMetaTileEntity)) && (((BaseMetaTileEntity) tTileEntity).privateAccess()) && (!((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true))) { + if (((tTileEntity instanceof BaseMetaTileEntityEx)) && (((BaseMetaTileEntityEx) tTileEntity).privateAccess()) && (!((BaseMetaTileEntityEx) tTileEntity).playerOwnsThis(aPlayer, true))) { return -1.0F; } return super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); @@ -340,8 +332,8 @@ public class GregtechBlockMachines @Override public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + if ((tTileEntity instanceof BaseMetaTileEntityEx)) { + ((BaseMetaTileEntityEx) tTileEntity).doEnergyExplosion(); } super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); } @@ -421,8 +413,8 @@ public class GregtechBlockMachines if (!aWorld.isRemote) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity != null) && (chance < 1.0F)) { - if (((tTileEntity instanceof BaseMetaTileEntity)) && (GregTech_API.sMachineNonWrenchExplosions)) { - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + if (((tTileEntity instanceof BaseMetaTileEntityEx)) && (GregTech_API.sMachineNonWrenchExplosions)) { + ((BaseMetaTileEntityEx) tTileEntity).doEnergyExplosion(); } } else { super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7); @@ -437,7 +429,7 @@ public class GregtechBlockMachines } TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null) { - if ((tTileEntity instanceof BaseMetaTileEntity)) { + if ((tTileEntity instanceof BaseMetaTileEntityEx)) { return true; } if (((tTileEntity instanceof BaseMetaPipeEntity)) && ((((BaseMetaPipeEntity) tTileEntity).mConnections & 0xFFFFFFC0) != 0)) { @@ -465,16 +457,16 @@ public class GregtechBlockMachines @Override public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { - return ((BaseMetaTileEntity) tTileEntity).getLightValue(); + if ((tTileEntity instanceof BaseMetaTileEntityEx)) { + return ((BaseMetaTileEntityEx) tTileEntity).getLightValue(); } return 0; } - @Override + @Override //TODO public TileEntity createTileEntity(World aWorld, int aMeta) { if (aMeta < 4) { - return GregTech_API.constructBaseMetaTileEntity(); + return Meta_GT_Proxy.constructBaseMetaTileEntity(); } return new BaseMetaPipeEntity(); } @@ -537,8 +529,8 @@ public class GregtechBlockMachines @Override public ArrayList getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { - return ((BaseMetaTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); + if ((tTileEntity instanceof BaseMetaTileEntityEx)) { + return ((BaseMetaTileEntityEx) tTileEntity).getDebugInfo(aPlayer, aLogLevel); } if ((tTileEntity instanceof BaseMetaPipeEntity)) { return ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index d913f56869..29a8a5948a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.items; +import static gtPlusPlus.core.util.Utils.getTcAspectStack; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; @@ -16,7 +17,6 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.common.covers.GT_Cover_Arm; import gregtech.common.covers.GT_Cover_Conveyor; import gregtech.common.covers.GT_Cover_Pump; -import static gtPlusPlus.core.util.Utils.getTcAspectStack; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -192,10 +192,18 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { GregtechItemList.Fluid_Cell_1L.set(addItem(tLastID = 64, "1L Wrought Iron Fluid Cell", "Holds exactly one litre worth of liquid.", new Object[]{new ItemData(Materials.WroughtIron, OrePrefixes.plate.mMaterialAmount * 8L + 4L * OrePrefixes.ring.mMaterialAmount, new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); setFluidContainerStats(32000 + tLastID, 1L, 64L); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.WroughtIron, 4L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 8L), GregtechItemList.Fluid_Cell_1L.get(4L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Bronze, 4L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 8L), GregtechItemList.Fluid_Cell_16L.get(4L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Brass, 4L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 8L), GregtechItemList.Fluid_Cell_36L.get(4L, new Object[0]), 75, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Invar, 4L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 8L), GregtechItemList.Fluid_Cell_144L.get(4L, new Object[0]), 75, 32); + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.WroughtIron, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 1L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Bronze, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 1L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Brass, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 1L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Invar, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 1L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); + } + else { + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.WroughtIron, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 4L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bronze, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 4L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Brass, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 4L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Invar, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 4L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); + } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java new file mode 100644 index 0000000000..77787cd2bf --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java @@ -0,0 +1,202 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntityEx; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTankEx; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class GT_NBT_Tank + extends GT_MetaTileEntity_BasicTankEx { + + + /*protected String fluidName = getFluidName(); + protected int fluidAmount = getInternalFluidAmount();*/ + + /*private String getFluidName(){ + String x; + if (internalTank != null){ + x = internalTank.getFluid().getName(); + } + else { + x = "null"; + } + return x; + } + + private int getInternalFluidAmount(){ + int x; + if (internalTank != null){ + x = internalTank.amount; + } + else { + x = 0; + } + return x; + }*/ + + public GT_NBT_Tank(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); + } + + public GT_NBT_Tank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER)}; + } + + /* @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + }*/ + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + Utils.LOG_INFO("Dumping Fluid data. Name: "+mFluid.getFluid().getName()+" Amount: "+mFluid.amount+"L"); + if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + Utils.LOG_INFO("Right Click on Block"); + if (aBaseMetaTileEntity.isClientSide()){ + Utils.LOG_INFO("MTE is ClientSide"); + return true; + } + Utils.LOG_INFO("MTE is not ClientSide"); + aBaseMetaTileEntity.openGUI(aPlayer); + Utils.LOG_INFO("MTE is now has an open GUI"); + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public final byte getUpdateData() { + return 0x00; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public String[] getInfoData() { + + if (mFluid == null) { + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", + "Stored Fluid:", + "No Fluid", + Integer.toString(0) + "L", + Integer.toString(getCapacity()) + "L"}; + } + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", + "Stored Fluid:", + mFluid.getLocalizedName(), + Integer.toString(mFluid.amount) + "L", + Integer.toString(getCapacity()) + "L"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public MetaTileEntityEx newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_NBT_Tank(mName, mTier, mDescription, mTextures); + } + + @Override + public int getCapacity() { + return (int) (Math.pow(2, mTier) * 32000); + } + + @Override + public int getTankPressure() { + return 100; + } + + @Override + public void sendSound(byte aIndex) { + + } + + @Override + public void sendLoopStart(byte aIndex) { + + } + + @Override + public void sendLoopEnd(byte aIndex) { + + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java index b953f0d672..5cda3ac867 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java @@ -1,8 +1,12 @@ package gtPlusPlus.xmod.gregtech.loaders; +import gregtech.api.metatileentity.BaseMetaTileEntityEx; import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.xmod.gregtech.common.blocks.GregtechBlockMachines; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.registry.GameRegistry; public class Gregtech_Blocks { @@ -10,7 +14,28 @@ public class Gregtech_Blocks { //Casing Blocks ModBlocks.blockCasingsMisc = new GregtechMetaCasingBlocks(); - ModBlocks.blockMetaTileEntity = new GregtechBlockMachines(); + //ModBlocks.blockMetaTileEntity = new GregtechBlockMachines(); + //registerDefailtGtTe(); + + + + + } + + //Register default Tile Entity + private static void registerDefailtGtTe(){ + Utils.LOG_INFO("Registering new GT TileEntities."); + + BaseMetaTileEntityEx tBaseMetaTileEntity = Meta_GT_Proxy.constructBaseMetaTileEntity(); + + Utils.LOG_INFO("Testing BaseMetaTileEntity."); + if (tBaseMetaTileEntity == null) { + Utils.LOG_INFO("Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + throw new RuntimeException(""); + } + Utils.LOG_INFO("Registering the BaseMetaTileEntityEx."); + GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntityEx"); + FMLInterModComms.sendMessage("appliedenergistics2", "whitelist-spatial", tBaseMetaTileEntity.getClass().getName()); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java index 4f8f2e3c1f..e1af53a627 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java @@ -4,6 +4,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredTank; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_NBT_Tank; public class GregtechTieredFluidTanks { @@ -12,6 +13,7 @@ public class GregtechTieredFluidTanks if (LoadedMods.Gregtech){ Utils.LOG_INFO("Gregtech5u Content | Registering Fluid Tanks."); run1(); + //run2(); } } @@ -31,5 +33,22 @@ public class GregtechTieredFluidTanks GregtechItemList.GT_FluidTank_MAX.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); + } + + private static void run2() + { + int ID = 900; + GregtechItemList.GT_FluidTank_ULV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.00", "Ultra Low Voltage Fluid Tank", 0).getStackForm(1L)); + GregtechItemList.GT_FluidTank_LV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.01", "Low Voltage Fluid Tank", 1).getStackForm(1L)); + GregtechItemList.GT_FluidTank_MV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.02", "Medium Voltage Fluid Tank", 2).getStackForm(1L)); + GregtechItemList.GT_FluidTank_HV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.03", "High Voltage Fluid Tank", 3).getStackForm(1L)); + GregtechItemList.GT_FluidTank_EV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.04", "Extreme Voltage Fluid Tank", 4).getStackForm(1L)); + GregtechItemList.GT_FluidTank_IV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.05", "Insane Voltage Fluid Tank", 5).getStackForm(1L)); + GregtechItemList.GT_FluidTank_LuV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.06", "Ludicrous Voltage Fluid Tank", 6).getStackForm(1L)); + GregtechItemList.GT_FluidTank_ZPM.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.07", "ZPM Voltage Fluid Tank", 7).getStackForm(1L)); + GregtechItemList.GT_FluidTank_UV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.08", "Ultimate Voltage Fluid Tank", 8).getStackForm(1L)); + GregtechItemList.GT_FluidTank_MAX.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); + + } } diff --git a/src/resources/assets/miscutils/textures/items/itemShovel.png b/src/resources/assets/miscutils/textures/items/itemShovel.png new file mode 100644 index 0000000000..8e1c0c2826 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemShovel.png differ -- cgit From 676a51a4c93713b3498508e13fae0869045f6f49 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Fri, 7 Oct 2016 02:03:46 +1000 Subject: + Added the Bronze and Advanced Work benches from GT4, still hell buggy but a WIP. // Temporarily added Workbench registration to the Tiered Tanks Loader. % Added some logging to the Plate Generation. $ Fixed getTexture() in BaseMetaTileEntityEx.java to now support all branches of Gregtech. --- .classpath | 2 +- .../api/metatileentity/BaseMetaTileEntityEx.java | 12 +- .../xmod/gregtech/api/enums/GregtechItemList.java | 5 +- .../api/gui/CONTAINER_AdvancedWorkbench.java | 161 ++++++ .../api/gui/CONTAINER_BronzeWorkbench.java | 161 ++++++ .../gregtech/api/gui/GUI_AdvancedWorkbench.java | 30 ++ .../xmod/gregtech/api/gui/GUI_BronzeWorkbench.java | 30 ++ .../GT_MetaTileEntity_AdvancedCraftingTable.java | 555 +++++++++++++++++++++ .../GT_MetaTileEntity_BronzeCraftingTable.java | 160 ++++++ .../xmod/gregtech/loaders/RecipeGen_Plates.java | 93 +++- .../gregtech/GregtechTieredFluidTanks.java | 9 +- .../textures/gui/AdvancedCraftingTable.png | Bin 0 -> 4330 bytes .../miscutils/textures/gui/BronzeCraftingTable.png | Bin 0 -> 2053 bytes 13 files changed, 1200 insertions(+), 18 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_BronzeWorkbench.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java create mode 100644 src/resources/assets/miscutils/textures/gui/AdvancedCraftingTable.png create mode 100644 src/resources/assets/miscutils/textures/gui/BronzeCraftingTable.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/.classpath b/.classpath index 3e8a66c867..37602a4409 100644 --- a/.classpath +++ b/.classpath @@ -13,6 +13,6 @@ - + diff --git a/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java b/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java index 1669a11f9a..955b7eb045 100644 --- a/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java +++ b/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java @@ -1108,7 +1108,7 @@ public class BaseMetaTileEntityEx extends BaseTileEntity implements IGregTechTil return 0; } - @Override + public ITexture[] getTexture(byte aSide) { ITexture rIcon = getCoverTexture(aSide); if (rIcon != null) return new ITexture[]{rIcon}; @@ -1116,6 +1116,15 @@ public class BaseMetaTileEntityEx extends BaseTileEntity implements IGregTechTil return mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0); return Textures.BlockIcons.ERROR_RENDERING; } + + + public ITexture[] getTexture(Block arg0, byte aSide) { + ITexture rIcon = getCoverTexture(aSide); + if (rIcon != null) return new ITexture[]{rIcon}; + if (hasValidMetaTileEntity()) + return mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0); + return Textures.BlockIcons.ERROR_RENDERING; + } private boolean isEnergyInputSide(byte aSide) { if (aSide >= 0 && aSide < 6) { @@ -2078,4 +2087,5 @@ public class BaseMetaTileEntityEx extends BaseTileEntity implements IGregTechTil public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 6f492ef2b9..de0a72f484 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -122,7 +122,10 @@ public enum GregtechItemList implements GregtechItemContainer { Fluid_Cell_1L, Fluid_Cell_16L, Fluid_Cell_36L, Fluid_Cell_144L, //Multitank - Industrial_MultiTank, Industrial_MultiTankDense, Casing_MultitankExterior; + Industrial_MultiTank, Industrial_MultiTankDense, Casing_MultitankExterior, + + //Gt4 Workbenches + GT4_Workbench_Bronze, GT4_Workbench_Advanced; public static final GregtechItemList[] DYE_ONLY_ITEMS = { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java new file mode 100644 index 0000000000..bb7982afe3 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java @@ -0,0 +1,161 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CONTAINER_AdvancedWorkbench +extends GT_ContainerMetaTile_Machine +{ + public CONTAINER_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) + { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) + { + addSlotToContainer(new Slot(this.mTileEntity, 0, 8, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 1, 26, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 2, 44, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 3, 62, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 4, 8, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 5, 26, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 6, 44, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 7, 62, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 8, 8, 44)); + addSlotToContainer(new Slot(this.mTileEntity, 9, 26, 44)); + addSlotToContainer(new Slot(this.mTileEntity, 10, 44, 44)); + addSlotToContainer(new Slot(this.mTileEntity, 11, 62, 44)); + addSlotToContainer(new Slot(this.mTileEntity, 12, 8, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 13, 26, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 14, 44, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 15, 62, 62)); + + addSlotToContainer(new Slot(this.mTileEntity, 16, 82, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 17, 100, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 18, 118, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 19, 136, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 20, 154, 8)); + + addSlotToContainer(new Slot(this.mTileEntity, 21, 82, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 22, 100, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 23, 118, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 24, 82, 46)); + addSlotToContainer(new Slot(this.mTileEntity, 25, 100, 46)); + addSlotToContainer(new Slot(this.mTileEntity, 26, 118, 46)); + addSlotToContainer(new Slot(this.mTileEntity, 27, 82, 64)); + addSlotToContainer(new Slot(this.mTileEntity, 28, 100, 64)); + addSlotToContainer(new Slot(this.mTileEntity, 29, 118, 64)); + + addSlotToContainer(new Slot(this.mTileEntity, 33, 154, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 34, 154, 64)); + + addSlotToContainer(new Slot(this.mTileEntity, 30, 136, 28)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 31, 136, 64, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 154, 46, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 136, 46, false, false, 1)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) + { + if ((aSlotIndex < 21) || (aSlotIndex > 35)) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + if ((this.mTileEntity == null) || (this.mTileEntity.getMetaTileEntity() == null)) { + return null; + } + try + { + ItemStack tStack = ((Slot)this.inventorySlots.get(aSlotIndex)).getStack(); + if ((tStack != null) && (tStack.stackSize <= 0) && (!GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack()))) { + return null; + } + if (aSlotIndex == 32) + { + if ((aMouseclick == 0) && (aShifthold == 1)) + { + ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).setBluePrint(null); + return null; + } + } + else + { + if (aSlotIndex == 33) + { + ItemStack tCraftedStack = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(); + if (tCraftedStack != null) { + if (aShifthold == 1) + { + for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i = (byte)(i + 1)) { + for (byte j = 0; (j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); j = (byte)(j + 1)) + { + ItemStack tStack2; + if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + return aPlayer.inventory.getItemStack(); + } + aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); + } + } + } + else + { + if (aMouseclick == 0) + { + if (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { + aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + } + return aPlayer.inventory.getItemStack(); + } + for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) + { + ItemStack tStack2; + if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + return aPlayer.inventory.getItemStack(); + } + aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + } + return aPlayer.inventory.getItemStack(); + } + } + return null; + } + if (aSlotIndex == 34) + { + ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).mFlushMode = true; + return null; + } + if (aSlotIndex == 35) + { + ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); + return null; + } + } + } + catch (Throwable e) + { + e.printStackTrace(GT_Log.err); + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public int getSlotCount() + { + return 33; + } + + @Override + public int getShiftClickSlotCount() + { + return 21; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java new file mode 100644 index 0000000000..d093101044 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java @@ -0,0 +1,161 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CONTAINER_BronzeWorkbench +extends GT_ContainerMetaTile_Machine +{ + public CONTAINER_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) + { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) + { + addSlotToContainer(new Slot(this.mTileEntity, 0, 8, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 1, 26, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 2, 44, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 3, 62, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 4, 8, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 5, 26, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 6, 44, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 7, 62, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 8, 8, 44)); + addSlotToContainer(new Slot(this.mTileEntity, 9, 26, 44)); + addSlotToContainer(new Slot(this.mTileEntity, 10, 44, 44)); + addSlotToContainer(new Slot(this.mTileEntity, 11, 62, 44)); + addSlotToContainer(new Slot(this.mTileEntity, 12, 8, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 13, 26, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 14, 44, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 15, 62, 62)); + + addSlotToContainer(new Slot(this.mTileEntity, 16, 82, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 17, 100, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 18, 118, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 19, 136, 8)); + addSlotToContainer(new Slot(this.mTileEntity, 20, 154, 8)); + + addSlotToContainer(new Slot(this.mTileEntity, 21, 82, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 22, 100, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 23, 118, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 24, 82, 46)); + addSlotToContainer(new Slot(this.mTileEntity, 25, 100, 46)); + addSlotToContainer(new Slot(this.mTileEntity, 26, 118, 46)); + addSlotToContainer(new Slot(this.mTileEntity, 27, 82, 64)); + addSlotToContainer(new Slot(this.mTileEntity, 28, 100, 64)); + addSlotToContainer(new Slot(this.mTileEntity, 29, 118, 64)); + + addSlotToContainer(new Slot(this.mTileEntity, 33, 154, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 34, 154, 64)); + + addSlotToContainer(new Slot(this.mTileEntity, 30, 136, 28)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 31, 136, 64, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 154, 46, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 136, 46, false, false, 1)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) + { + if ((aSlotIndex < 21) || (aSlotIndex > 35)) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + if ((this.mTileEntity == null) || (this.mTileEntity.getMetaTileEntity() == null)) { + return null; + } + try + { + ItemStack tStack = ((Slot)this.inventorySlots.get(aSlotIndex)).getStack(); + if ((tStack != null) && (tStack.stackSize <= 0) && (!GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack()))) { + return null; + } + if (aSlotIndex == 32) + { + if ((aMouseclick == 0) && (aShifthold == 1)) + { + ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).setBluePrint(null); + return null; + } + } + else + { + if (aSlotIndex == 33) + { + ItemStack tCraftedStack = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(); + if (tCraftedStack != null) { + if (aShifthold == 1) + { + for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i = (byte)(i + 1)) { + for (byte j = 0; (j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); j = (byte)(j + 1)) + { + ItemStack tStack2; + if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + return aPlayer.inventory.getItemStack(); + } + aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); + } + } + } + else + { + if (aMouseclick == 0) + { + if (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { + aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + } + return aPlayer.inventory.getItemStack(); + } + for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) + { + ItemStack tStack2; + if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + return aPlayer.inventory.getItemStack(); + } + aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + } + return aPlayer.inventory.getItemStack(); + } + } + return null; + } + if (aSlotIndex == 34) + { + ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).mFlushMode = true; + return null; + } + if (aSlotIndex == 35) + { + ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); + return null; + } + } + } + catch (Throwable e) + { + e.printStackTrace(GT_Log.err); + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public int getSlotCount() + { + return 33; + } + + @Override + public int getShiftClickSlotCount() + { + return 21; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java new file mode 100644 index 0000000000..7da9238bd5 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java @@ -0,0 +1,30 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_AdvancedWorkbench +extends GT_GUIContainerMetaTile_Machine +{ + public GUI_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) + { + super(new CONTAINER_AdvancedWorkbench(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "AdvancedCraftingTable.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + //this.fontRendererObj.drawString("Condenser", 8, 4, 4210752); + } + + @Override + 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); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_BronzeWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_BronzeWorkbench.java new file mode 100644 index 0000000000..597edba503 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_BronzeWorkbench.java @@ -0,0 +1,30 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_BronzeWorkbench +extends GT_GUIContainerMetaTile_Machine +{ + public GUI_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) + { + super(new CONTAINER_BronzeWorkbench(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "BronzeCraftingTable.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + //this.fontRendererObj.drawString("Condenser", 8, 4, 4210752); + } + + @Override + 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); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java new file mode 100644 index 0000000000..b150ea32cb --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java @@ -0,0 +1,555 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_AdvancedWorkbench; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_AdvancedWorkbench; + +import java.util.ArrayList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_AdvancedCraftingTable +extends GT_MetaTileEntity_BasicTank +{ + public boolean mFlushMode = false; + + public GT_MetaTileEntity_AdvancedCraftingTable(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "WorkBench pro noSc0pe"); + } + + public GT_MetaTileEntity_AdvancedCraftingTable(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + Utils.LOG_INFO("Right Click on Block"); + if (aBaseMetaTileEntity.isClientSide()){ + Utils.LOG_INFO("MTE is ClientSide"); + return true; + } + Utils.LOG_INFO("MTE is not ClientSide"); + aBaseMetaTileEntity.openGUI(aPlayer); + Utils.LOG_INFO("MTE is now has an open GUI"); + return true; + } + + @Override + public String[] getInfoData() { + + if (mFluid == null) { + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Workbench", + "Stored Fluid:", + "No Fluid", + Integer.toString(0) + "L", + Integer.toString(getCapacity()) + "L"}; + } + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Workbench", + "Stored Fluid:", + mFluid.getLocalizedName(), + Integer.toString(mFluid.amount) + "L", + Integer.toString(getCapacity()) + "L"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + Utils.LOG_INFO("Dumping Fluid data. Name: "+mFluid.getFluid().getName()+" Amount: "+mFluid.amount+"L"); + if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + } + + @Override + public boolean isTransformerUpgradable() + { + return true; + } + + public boolean isBatteryUpgradable() + { + return true; + } + + @Override + public boolean isSimpleMachine() + { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) + { + return (aIndex < 31) || (aIndex > 32); + } + + @Override + public boolean isFacingValid(byte aFacing) + { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) + { + return true; + } + + @Override + public boolean isEnetInput() + { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) + { + return true; + } + + @Override + public long maxEUInput() + { + return 128; + } + + @Override + public long maxEUStore() + { + return 128000; + } + + public int getInvSize() + { + return 35; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_AdvancedCraftingTable(mName, mTier, mDescription, mTextures); + } + + public void onRightclick(EntityPlayer aPlayer) + { + getBaseMetaTileEntity().openGUI(aPlayer, 160); + } + + public void onFirstTick() + { + getCraftingOutput(); + } + + @Override + public boolean doesFillContainers() + { + return false; + } + + @Override + public boolean doesEmptyContainers() + { + return false; + } + + @Override + public boolean canTankBeFilled() + { + return true; + } + + @Override + public boolean canTankBeEmptied() + { + return true; + } + + @Override + public boolean displaysItemStack() + { + return false; + } + + @Override + public boolean displaysStackSize() + { + return false; + } + + public void onPostTick() + { + if (getBaseMetaTileEntity().isServerSide()) + { + if (getBaseMetaTileEntity().hasInventoryBeenModified()) { + getCraftingOutput(); + } + fillLiquidContainers(); + if (this.mFlushMode) + { + this.mFlushMode = false; + for (byte i = 21; i < 30; i = (byte)(i + 1)) { + if (this.mInventory[i] != null) { + if (this.mInventory[i].stackSize == 0) + { + this.mInventory[i] = null; + } + else + { + this.mFlushMode = true; + break; + } + } + } + } + } + } + + public void sortIntoTheInputSlots() + { + for (byte i = 21; i < 30; i = (byte)(i + 1)) { + if (this.mInventory[i] != null) + { + if (this.mInventory[i].stackSize == 0) { + this.mInventory[i] = null; + } + if (this.mInventory[i] != null) { + for (byte j = 0; j < 16; j = (byte)(j + 1)) { + if (GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])) { + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), i, j, (byte)64, (byte)1, (byte)64, (byte)1); + } + } + } + if (this.mInventory[i] != null) { + for (byte j = 0; j < 16; j = (byte)(j + 1)) { + if (this.mInventory[j] == null) { + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), i, j, (byte)64, (byte)1, (byte)64, (byte)1); + } + } + } + } + } + } + + private void fillLiquidContainers() + { + for (byte i = 16; (i < 21) && (this.mFluid != null); i = (byte)(i + 1)) + { + ItemStack tOutput = GT_Utility.fillFluidContainer(this.mFluid, this.mInventory[i], true, true); + if (tOutput != null) + { + if (this.mInventory[i].stackSize == 1) + { + this.mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; + this.mInventory[i] = tOutput; + } + else + { + for (byte j = 16; j < 21; j = (byte)(j + 1)) { + if ((this.mInventory[j] == null) || ((GT_Utility.areStacksEqual(tOutput, this.mInventory[j])) && (this.mInventory[j].stackSize + tOutput.stackSize <= tOutput.getMaxStackSize()))) + { + this.mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; + getBaseMetaTileEntity().decrStackSize(i, 1); + if (this.mInventory[j] == null) + { + this.mInventory[j] = tOutput; break; + } + this.mInventory[j].stackSize += 1; + + break; + } + } + } + if ((this.mFluid != null) && (this.mFluid.amount <= 0)) { + this.mFluid = null; + } + } + } + if ((this.mFluid != null) && (this.mFluid.amount <= 0)) { + this.mFluid = null; + } + } + + public void setBluePrint(ItemStack aStack) + { + if (aStack == null) { + aStack = this.mInventory[30]; + } + if ((this.mInventory[31] == null) || (aStack == null) /*|| (aStack.itemID != -2)*/ || (aStack.getItemDamage() != 0) || (aStack.stackSize != 1) || (aStack.hasTagCompound())) { + return; + } + NBTTagCompound tNBT = new NBTTagCompound(); + NBTTagList tNBT_ItemList = new NBTTagList(); + for (int i = 0; i < 9; i++) + { + ItemStack tStack = this.mInventory[(i + 21)]; + if (tStack != null) + { + NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("Slot", (byte)i); + tStack.writeToNBT(tag); + tNBT_ItemList.appendTag(tag); + } + } + tNBT.setTag("Inventory", tNBT_ItemList); + aStack.setTagCompound(tNBT); + } + + public ItemStack getCraftingOutput() + { + if ((this.mInventory[30] != null) /*&& (this.mInventory[30].itemID == -2)*/ && (this.mInventory[30].getItemDamage() == 0) && (this.mInventory[30].hasTagCompound())) + { + NBTTagCompound tNBT = this.mInventory[30].getTagCompound(); + NBTTagList tNBT_ItemList = tNBT.getTagList("Blueprint", 10); //TODO + for (int i = 0; (i < tNBT_ItemList.tagCount()) && (i < 9); i++) + { + NBTTagCompound tag = (NBTTagCompound)tNBT_ItemList.getCompoundTagAt(i); + byte slot = tag.getByte("Slot"); + if ((slot >= 0) && (slot < 9) && (this.mInventory[(slot + 21)] == null)) + { + this.mInventory[(slot + 21)] = GT_Utility.loadItem(tag); + if (this.mInventory[(slot + 21)] != null) { + this.mInventory[(slot + 21)].stackSize = 0; + } + } + } + } + this.mInventory[31] = GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), new ItemStack[] { this.mInventory[21], this.mInventory[22], this.mInventory[23], this.mInventory[24], this.mInventory[25], this.mInventory[26], this.mInventory[27], this.mInventory[28], this.mInventory[29] }); + return this.mInventory[31]; + } + + public boolean canDoCraftingOutput() + { + if (this.mInventory[31] == null) { + return false; + } + for (ItemStack tStack : recipeContent()) { + if (tStack.stackSize > getAmountOf(tStack)) { + return false; + } + } + return true; + } + + private int getAmountOf(ItemStack aStack) + { + int tAmount = 0; + for (byte i = 0; (i < 30) && (tAmount < 9); i = (byte)(i + 1)) { + if (GT_Utility.areStacksOrToolsEqual(aStack, this.mInventory[i])) { + tAmount += this.mInventory[i].stackSize; + } + } + return tAmount; + } + + private ArrayList recipeContent() + { + ArrayList tList = new ArrayList(); + for (byte i = 21; i < 30; i = (byte)(i + 1)) { + if (this.mInventory[i] != null) + { + boolean temp = false; + for (byte j = 0; j < tList.size(); j = (byte)(j + 1)) { + if (GT_Utility.areStacksOrToolsEqual(this.mInventory[i], (ItemStack)tList.get(j))) + { + ((ItemStack)tList.get(j)).stackSize += 1; + temp = true; + break; + } + } + if (!temp) { + tList.add(GT_Utility.copyAmount(1L, new Object[] { this.mInventory[i] })); + } + } + } + return tList; + } + + public ItemStack consumeMaterials(EntityPlayer aPlayer, ItemStack aHoldStack) + { + if (this.mInventory[31] == null) { + return aHoldStack; + } + if (aHoldStack != null) + { + if (!GT_Utility.areStacksEqual(aHoldStack, this.mInventory[31])) { + return aHoldStack; + } + if (aHoldStack.stackSize + this.mInventory[31].stackSize > aHoldStack.getMaxStackSize()) { + return aHoldStack; + } + } + for (byte i = 21; i < 30; i = (byte)(i + 1)) { + if (this.mInventory[i] != null) { + for (byte j = 0; j <= i; j = (byte)(j + 1)) { + if (((j < 21) || (j == i)) && + (GT_Utility.areStacksOrToolsEqual(this.mInventory[i], this.mInventory[j])) && (this.mInventory[j].stackSize > 0)) + { + ItemStack tStack = GT_Utility.getContainerItem(this.mInventory[j], true); + if ((tStack == null) || ((tStack.isItemStackDamageable()) && (tStack.getItemDamage() >= tStack.getMaxDamage()))) + { + getBaseMetaTileEntity().decrStackSize(j, 1); break; + } + if (this.mInventory[j].stackSize == 1) + { + this.mInventory[j] = tStack; break; + } + getBaseMetaTileEntity().decrStackSize(j, 1); + for (byte k = 0; k < 21; k = (byte)(k + 1)) + { + if (this.mInventory[k] == null) + { + this.mInventory[k] = tStack; + break; + } + if ((GT_Utility.areStacksEqual(tStack, this.mInventory[k])) && + (tStack.stackSize + this.mInventory[k].stackSize <= this.mInventory[k].getMaxStackSize())) + { + this.mInventory[k].stackSize += tStack.stackSize; + break; + } + } + break; + } + } + } + } + if (aHoldStack == null) + { + aHoldStack = GT_Utility.copy(new Object[] { this.mInventory[31] }); + aHoldStack.onCrafting(getBaseMetaTileEntity().getWorld(), aPlayer, this.mInventory[31].stackSize); + } + else + { + aHoldStack.stackSize += this.mInventory[31].stackSize; + aHoldStack.onCrafting(getBaseMetaTileEntity().getWorld(), aPlayer, this.mInventory[31].stackSize); + } + fillLiquidContainers(); + + return aHoldStack; + } + + @Override + public long getInputTier() + { + return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); + } + + @Override + public long getOutputTier() + { + return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); + } + + @Override + public int rechargerSlotStartIndex() + { + return 16; + } + + @Override + public int rechargerSlotCount() + { + return 5; + } + + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) + { + if (aSide == 0) { + return 32; + } + if (aSide == 1) { + return 290; + } + if ((aFacing == 0) || (aFacing == 1)) { + return 222; + } + if ((aFacing == 2) || (aFacing == 3)) { + return 223; + } + return 215; + } + + @Override + public String[] getDescription() + { + return new String[]{"For the very large Projects"}; + } + + public boolean allowPutStack(int aIndex, byte aSide, ItemStack aStack) + { + if (aIndex < 16) + { + for (byte i = 0; i < 16; i = (byte)(i + 1)) { + if (GT_Utility.areStacksOrToolsEqual(aStack, this.mInventory[i])) { + return aIndex == i; + } + } + return true; + } + return false; + } + + public boolean allowPullStack(int aIndex, byte aSide, ItemStack aStack) + { + return (aIndex == 33) || ((this.mFlushMode) && (aIndex >= 21) && (aIndex < 30)); + } + + @Override + public int getCapacity() + { + return 64000; + } + + @Override + public int getTankPressure() + { + return -100; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new CONTAINER_AdvancedWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new GUI_AdvancedWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == 1 ? new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CRAFTING)} : new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java new file mode 100644 index 0000000000..d0f15c5da2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java @@ -0,0 +1,160 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import gregtech.api.GregTech_API; +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 gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_BronzeWorkbench; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_BronzeWorkbench; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; + +public class GT_MetaTileEntity_BronzeCraftingTable +extends GT_MetaTileEntity_AdvancedCraftingTable +{ + public GT_MetaTileEntity_BronzeCraftingTable(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_BronzeCraftingTable(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + @Override + public boolean isElectric() + { + return false; + } + + @Override + public boolean isPneumatic() + { + return false; + } + + @Override + public boolean isSteampowered() + { + return false; + } + + @Override + public boolean isTransformerUpgradable() + { + return false; + } + + @Override + public boolean isBatteryUpgradable() + { + return false; + } + + @Override + public boolean isEnetInput() + { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) + { + return false; + } + + @Override + public long maxEUInput() + { + return 0; + } + + @Override + public long maxEUStore() + { + return 0; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_BronzeCraftingTable(mName, mTier, mDescription, mTextures); + } + + @Override + public void onRightclick(EntityPlayer aPlayer) + { + getBaseMetaTileEntity().openGUI(aPlayer, 161); + } + + @SuppressWarnings({ "static-method", "unused" }) + public boolean allowCoverOnSide(byte aSide, int aCoverID) + { + return GregTech_API.getCoverBehavior(aCoverID).isSimpleCover(); + } + + @Override + public int rechargerSlotStartIndex() + { + return 0; + } + + @Override + public int rechargerSlotCount() + { + return 0; + } + + @Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) + { + if (aSide == 0) { + return 315; + } + if (aSide == 1) { + return 317; + } + if ((aFacing == 0) || (aFacing == 1)) { + return 318; + } + if ((aFacing == 2) || (aFacing == 3)) { + return 319; + } + return 320; + } + + @Override + public String[] getDescription() + { + return new String[] {"For the smaller Projects"}; + } + + @Override + public int getCapacity() + { + return 16000; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new CONTAINER_BronzeWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new GUI_BronzeWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == 1 ? new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CRAFTING)} : new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java index 35fc715a6f..6d84abe37b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java @@ -1,8 +1,10 @@ package gtPlusPlus.xmod.gregtech.loaders; +import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import net.minecraft.item.ItemStack; @@ -20,47 +22,79 @@ public class RecipeGen_Plates { ItemStack plate_SingleTwo = material.getPlate(2); ItemStack plate_Double = material.getPlateDouble(1); + Utils.LOG_INFO("Generating Plate recipes for "+material.getLocalizedName()); + //Forge Hammer - GT_Values.RA.addForgeHammerRecipe( + if (addForgeHammerRecipe( ingotStackTwo, plate_Single, (int) Math.max(material.getMass(), 1L), - 16); + 16)){ + Utils.LOG_INFO("Forge Hammer Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Utils.LOG_INFO("Forge Hammer Recipe: "+material.getLocalizedName()+" - Failed"); + } //Bender - GT_Values.RA.addBenderRecipe( + if (addBenderRecipe( ingotStackOne, plate_Single, (int) Math.max(material.getMass() * 1L, 1L), - 24); + 24)){ + Utils.LOG_INFO("Bender Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Utils.LOG_INFO("Bender Recipe: "+material.getLocalizedName()+" - Failed"); + } //Extruder - GT_Values.RA.addExtruderRecipe( + if (addExtruderRecipe( ingotStackOne, shape_Extruder, plate_Single, - 10, 4 * tVoltageMultiplier); + 10, 4 * tVoltageMultiplier)){ + Utils.LOG_INFO("Extruder Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Utils.LOG_INFO("Extruder Recipe: "+material.getLocalizedName()+" - Failed"); + } //Alloy Smelter - GT_Values.RA.addAlloySmelterRecipe( + if (GT_Values.RA.addAlloySmelterRecipe( ingotStackTwo, shape_Mold, plate_Single, (int) Math.max(material.getMass() * 2L, 1L), - 2 * tVoltageMultiplier); + 2 * tVoltageMultiplier)){ + Utils.LOG_INFO("Alloy Smelter Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Utils.LOG_INFO("Alloy Smelter Recipe: "+material.getLocalizedName()+" - Failed"); + } //Making Double Plates - GT_Values.RA.addBenderRecipe( + if (addBenderRecipe( ingotStackTwo, plate_Double, (int) Math.max(material.getMass() * 2L, 1L), - 96); - GT_Values.RA.addBenderRecipe( + 96)){ + Utils.LOG_INFO("Bender Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Utils.LOG_INFO("Bender Recipe: "+material.getLocalizedName()+" - Failed"); + } + if (addBenderRecipe( plate_SingleTwo, plate_Double, (int) Math.max(material.getMass() * 2L, 1L), - 96); + 96)){ + Utils.LOG_INFO("Bender Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Utils.LOG_INFO("Bender Recipe: "+material.getLocalizedName()+" - Failed"); + } - Utils.LOG_WARNING("Adding crafting recipes for "+material.getLocalizedName()+" Plates - Single & Double"); + Utils.LOG_INFO("Adding crafting recipes for "+material.getLocalizedName()+" Plates - Single & Double"); //Single Plate Shaped/Shapeless GT_ModHandler.addCraftingRecipe( @@ -94,6 +128,39 @@ public class RecipeGen_Plates { plate_Single}); } + public static boolean addBenderRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt) { + if ((aInput1 == null) || (aOutput1 == null)) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("bender", aInput1, aDuration)) <= 0) { + return false; + } + new GT_Recipe(aEUt, aDuration, aInput1, aOutput1); + return true; + } + + public static boolean addExtruderRecipe(ItemStack aInput, ItemStack aShape, ItemStack aOutput, int aDuration, int aEUt) { + if ((aInput == null) || (aShape == null) || (aOutput == null)) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("extruder", aOutput, aDuration)) <= 0) { + return false; + } + GT_Recipe.GT_Recipe_Map.sExtruderRecipes.addRecipe(true, new ItemStack[]{aInput, aShape}, new ItemStack[]{aOutput}, null, null, null, aDuration, aEUt, 0); + return true; + } + + public static boolean addForgeHammerRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt) { + if ((aInput1 == null) || (aOutput1 == null)) { + return false; + } + if (!GregTech_API.sRecipeFile.get("forgehammer", aOutput1, true)) { + return false; + } + GT_Recipe.GT_Recipe_Map.sHammerRecipes.addRecipe(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, aDuration, aEUt, 0); + return true; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java index e1af53a627..1475a8140a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java @@ -3,6 +3,8 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredTank; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_NBT_Tank; @@ -31,8 +33,11 @@ public class GregtechTieredFluidTanks GregtechItemList.GT_FluidTank_ZPM.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.07", "ZPM Voltage Fluid Tank", 7).getStackForm(1L)); GregtechItemList.GT_FluidTank_UV.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.08", "Ultimate Voltage Fluid Tank", 8).getStackForm(1L)); GregtechItemList.GT_FluidTank_MAX.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); - - + ID = 900; + GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(ID++, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); + GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(ID++, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); + + } private static void run2() diff --git a/src/resources/assets/miscutils/textures/gui/AdvancedCraftingTable.png b/src/resources/assets/miscutils/textures/gui/AdvancedCraftingTable.png new file mode 100644 index 0000000000..3d5cc1591e Binary files /dev/null and b/src/resources/assets/miscutils/textures/gui/AdvancedCraftingTable.png differ diff --git a/src/resources/assets/miscutils/textures/gui/BronzeCraftingTable.png b/src/resources/assets/miscutils/textures/gui/BronzeCraftingTable.png new file mode 100644 index 0000000000..fa432b2805 Binary files /dev/null and b/src/resources/assets/miscutils/textures/gui/BronzeCraftingTable.png differ -- cgit From 5165724b5aa491a6892367bdc2e80977a5b32e7f Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 9 Oct 2016 12:23:21 +1000 Subject: % Rewrote a lot of the Container code for the workbenches to better reflect 1.7.10 and Gt5. % Changed the IDs of workbenches. --- .classpath | 2 +- .../api/gui/CONTAINER_AdvancedWorkbench.java | 127 +++++++++++---------- .../api/gui/CONTAINER_BronzeWorkbench.java | 41 +++---- .../gregtech/GregtechTieredFluidTanks.java | 7 +- 4 files changed, 95 insertions(+), 82 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/.classpath b/.classpath index 37602a4409..f64ee72b03 100644 --- a/.classpath +++ b/.classpath @@ -13,6 +13,6 @@ - + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java index bb7982afe3..4a1eac7ac1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java @@ -5,85 +5,92 @@ import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class CONTAINER_AdvancedWorkbench -extends GT_ContainerMetaTile_Machine -{ - public CONTAINER_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) - { - super(aInventoryPlayer, aTileEntity); - } +public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { + + public CONTAINER_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(this.mTileEntity, 0, 8, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 1, 26, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 2, 44, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 3, 62, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 4, 8, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 5, 26, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 6, 44, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 7, 62, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 8, 8, 44)); - addSlotToContainer(new Slot(this.mTileEntity, 9, 26, 44)); - addSlotToContainer(new Slot(this.mTileEntity, 10, 44, 44)); - addSlotToContainer(new Slot(this.mTileEntity, 11, 62, 44)); - addSlotToContainer(new Slot(this.mTileEntity, 12, 8, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 13, 26, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 14, 44, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 15, 62, 62)); + addSlotToContainer(new Slot(mTileEntity, 0, 8, 8)); + addSlotToContainer(new Slot(mTileEntity, 1, 26, 8)); + addSlotToContainer(new Slot(mTileEntity, 2, 44, 8)); + addSlotToContainer(new Slot(mTileEntity, 3, 62, 8)); + addSlotToContainer(new Slot(mTileEntity, 4, 8, 26)); + addSlotToContainer(new Slot(mTileEntity, 5, 26, 26)); + addSlotToContainer(new Slot(mTileEntity, 6, 44, 26)); + addSlotToContainer(new Slot(mTileEntity, 7, 62, 26)); + addSlotToContainer(new Slot(mTileEntity, 8, 8, 44)); + addSlotToContainer(new Slot(mTileEntity, 9, 26, 44)); + addSlotToContainer(new Slot(mTileEntity, 10, 44, 44)); + addSlotToContainer(new Slot(mTileEntity, 11, 62, 44)); + addSlotToContainer(new Slot(mTileEntity, 12, 8, 62)); + addSlotToContainer(new Slot(mTileEntity, 13, 26, 62)); + addSlotToContainer(new Slot(mTileEntity, 14, 44, 62)); + addSlotToContainer(new Slot(mTileEntity, 15, 62, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 16, 82, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 17, 100, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 18, 118, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 19, 136, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 20, 154, 8)); + addSlotToContainer(new Slot(mTileEntity, 16, 82, 8)); + addSlotToContainer(new Slot(mTileEntity, 17, 100, 8)); + addSlotToContainer(new Slot(mTileEntity, 18, 118, 8)); + addSlotToContainer(new Slot(mTileEntity, 19, 136, 8)); + addSlotToContainer(new Slot(mTileEntity, 20, 154, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 21, 82, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 22, 100, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 23, 118, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 24, 82, 46)); - addSlotToContainer(new Slot(this.mTileEntity, 25, 100, 46)); - addSlotToContainer(new Slot(this.mTileEntity, 26, 118, 46)); - addSlotToContainer(new Slot(this.mTileEntity, 27, 82, 64)); - addSlotToContainer(new Slot(this.mTileEntity, 28, 100, 64)); - addSlotToContainer(new Slot(this.mTileEntity, 29, 118, 64)); + addSlotToContainer(new Slot(mTileEntity, 21, 82, 28)); + addSlotToContainer(new Slot(mTileEntity, 22, 100, 28)); + addSlotToContainer(new Slot(mTileEntity, 23, 118, 28)); + addSlotToContainer(new Slot(mTileEntity, 24, 82, 46)); + addSlotToContainer(new Slot(mTileEntity, 25, 100, 46)); + addSlotToContainer(new Slot(mTileEntity, 26, 118, 46)); + addSlotToContainer(new Slot(mTileEntity, 27, 82, 64)); + addSlotToContainer(new Slot(mTileEntity, 28, 100, 64)); + addSlotToContainer(new Slot(mTileEntity, 29, 118, 64)); - addSlotToContainer(new Slot(this.mTileEntity, 33, 154, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 34, 154, 64)); + addSlotToContainer(new Slot(mTileEntity, 33, 154, 28)); + addSlotToContainer(new Slot(mTileEntity, 34, 154, 64)); - addSlotToContainer(new Slot(this.mTileEntity, 30, 136, 28)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 31, 136, 64, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 154, 46, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 136, 46, false, false, 1)); + addSlotToContainer(new Slot(mTileEntity, 30, 136, 28)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 31, 136, 64, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 32, 154, 46, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 32, 136, 46, false, false, 1)); } @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) - { + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer){ + Utils.LOG_INFO("Player Clicked A Slot. "+aSlotIndex); if ((aSlotIndex < 21) || (aSlotIndex > 35)) { + Utils.LOG_INFO("Returning slotClick for slot: "+aSlotIndex+" on line 75"); return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - if ((this.mTileEntity == null) || (this.mTileEntity.getMetaTileEntity() == null)) { + if ((mTileEntity == null) || (mTileEntity.getMetaTileEntity() == null)) { + Utils.LOG_INFO("Returning null on Line 78"); return null; } try { ItemStack tStack = ((Slot)this.inventorySlots.get(aSlotIndex)).getStack(); if ((tStack != null) && (tStack.stackSize <= 0) && (!GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack()))) { + Utils.LOG_INFO("Returning null on Line 85"); return null; } if (aSlotIndex == 32) { if ((aMouseclick == 0) && (aShifthold == 1)) { - ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).setBluePrint(null); + ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).setBluePrint(null); + Utils.LOG_INFO("Returning null on Line 93"); return null; } } @@ -91,18 +98,19 @@ extends GT_ContainerMetaTile_Machine { if (aSlotIndex == 33) { - ItemStack tCraftedStack = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(); + ItemStack tCraftedStack = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(); if (tCraftedStack != null) { if (aShifthold == 1) { for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i = (byte)(i + 1)) { - for (byte j = 0; (j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); j = (byte)(j + 1)) + for (byte j = 0; (j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); j = (byte)(j + 1)) { ItemStack tStack2; - if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 111"); return aPlayer.inventory.getItemStack(); } - aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); + aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); } } } @@ -110,32 +118,35 @@ extends GT_ContainerMetaTile_Machine { if (aMouseclick == 0) { - if (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + if (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { + aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); } return aPlayer.inventory.getItemStack(); } - for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) + for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) { ItemStack tStack2; - if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { return aPlayer.inventory.getItemStack(); } - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); } return aPlayer.inventory.getItemStack(); } } + Utils.LOG_INFO("Returning null on Line 136"); return null; } if (aSlotIndex == 34) { - ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).mFlushMode = true; + ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).mFlushMode = true; + Utils.LOG_INFO("Returning null on Line 142"); return null; } if (aSlotIndex == 35) { - ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); + ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); + Utils.LOG_INFO("Returning null on Line 148"); return null; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java index d093101044..650e80ebd5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java @@ -5,20 +5,22 @@ import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class CONTAINER_BronzeWorkbench -extends GT_ContainerMetaTile_Machine -{ - public CONTAINER_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) - { +public class CONTAINER_BronzeWorkbench extends GT_ContainerMetaTile_Machine { + + public CONTAINER_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); } + public CONTAINER_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + @Override public void addSlots(InventoryPlayer aInventoryPlayer) { @@ -64,8 +66,7 @@ extends GT_ContainerMetaTile_Machine addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 136, 46, false, false, 1)); } - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) + public ItemStack func_75144_a(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { if ((aSlotIndex < 21) || (aSlotIndex > 35)) { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); @@ -83,7 +84,7 @@ extends GT_ContainerMetaTile_Machine { if ((aMouseclick == 0) && (aShifthold == 1)) { - ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).setBluePrint(null); + ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).setBluePrint(null); return null; } } @@ -91,18 +92,18 @@ extends GT_ContainerMetaTile_Machine { if (aSlotIndex == 33) { - ItemStack tCraftedStack = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(); + ItemStack tCraftedStack = ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(); if (tCraftedStack != null) { if (aShifthold == 1) { for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i = (byte)(i + 1)) { - for (byte j = 0; (j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); j = (byte)(j + 1)) + for (byte j = 0; (j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); j = (byte)(j + 1)) { ItemStack tStack2; - if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { return aPlayer.inventory.getItemStack(); } - aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); + aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); } } } @@ -110,18 +111,18 @@ extends GT_ContainerMetaTile_Machine { if (aMouseclick == 0) { - if (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + if (((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { + aPlayer.inventory.setItemStack(((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); } return aPlayer.inventory.getItemStack(); } - for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) + for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) { ItemStack tStack2; - if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { return aPlayer.inventory.getItemStack(); } - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + aPlayer.inventory.setItemStack(((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); } return aPlayer.inventory.getItemStack(); } @@ -130,12 +131,12 @@ extends GT_ContainerMetaTile_Machine } if (aSlotIndex == 34) { - ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).mFlushMode = true; + ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).mFlushMode = true; return null; } if (aSlotIndex == 35) { - ((GT_MetaTileEntity_AdvancedCraftingTable)this.mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); + ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); return null; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java index 1475a8140a..4632b306ed 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java @@ -33,9 +33,10 @@ public class GregtechTieredFluidTanks GregtechItemList.GT_FluidTank_ZPM.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.07", "ZPM Voltage Fluid Tank", 7).getStackForm(1L)); GregtechItemList.GT_FluidTank_UV.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.08", "Ultimate Voltage Fluid Tank", 8).getStackForm(1L)); GregtechItemList.GT_FluidTank_MAX.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); - ID = 900; - GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(ID++, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); - GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(ID++, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); + + //Gregtech 4 Workbenches + GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(828, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); + GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(829, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); } -- cgit From 6d4f28c0b73afa2cdc59b9da24c290ec29bb9132 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 9 Oct 2016 15:51:24 +1000 Subject: + More Logging for the Workbenches --- .classpath | 2 +- .../api/gui/CONTAINER_AdvancedWorkbench.java | 30 ++++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/.classpath b/.classpath index f64ee72b03..cce7f298b8 100644 --- a/.classpath +++ b/.classpath @@ -13,6 +13,6 @@ - + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java index 4a1eac7ac1..47c8aedb98 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java @@ -5,6 +5,7 @@ import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.slots.SlotGtTool; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; import net.minecraft.entity.player.EntityPlayer; @@ -42,11 +43,11 @@ public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { addSlotToContainer(new Slot(mTileEntity, 14, 44, 62)); addSlotToContainer(new Slot(mTileEntity, 15, 62, 62)); - addSlotToContainer(new Slot(mTileEntity, 16, 82, 8)); - addSlotToContainer(new Slot(mTileEntity, 17, 100, 8)); - addSlotToContainer(new Slot(mTileEntity, 18, 118, 8)); - addSlotToContainer(new Slot(mTileEntity, 19, 136, 8)); - addSlotToContainer(new Slot(mTileEntity, 20, 154, 8)); + addSlotToContainer(new SlotGtTool(mTileEntity, 16, 82, 8)); + addSlotToContainer(new SlotGtTool(mTileEntity, 17, 100, 8)); + addSlotToContainer(new SlotGtTool(mTileEntity, 18, 118, 8)); + addSlotToContainer(new SlotGtTool(mTileEntity, 19, 136, 8)); + addSlotToContainer(new SlotGtTool(mTileEntity, 20, 154, 8)); addSlotToContainer(new Slot(mTileEntity, 21, 82, 28)); addSlotToContainer(new Slot(mTileEntity, 22, 100, 28)); @@ -75,14 +76,14 @@ public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } if ((mTileEntity == null) || (mTileEntity.getMetaTileEntity() == null)) { - Utils.LOG_INFO("Returning null on Line 78"); + Utils.LOG_INFO("Returning null on Line 79"); return null; } try { ItemStack tStack = ((Slot)this.inventorySlots.get(aSlotIndex)).getStack(); if ((tStack != null) && (tStack.stackSize <= 0) && (!GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack()))) { - Utils.LOG_INFO("Returning null on Line 85"); + Utils.LOG_INFO("Returning null on Line 86"); return null; } if (aSlotIndex == 32) @@ -90,7 +91,7 @@ public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { if ((aMouseclick == 0) && (aShifthold == 1)) { ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).setBluePrint(null); - Utils.LOG_INFO("Returning null on Line 93"); + Utils.LOG_INFO("Returning null on Line 94"); return null; } } @@ -110,6 +111,7 @@ public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 111"); return aPlayer.inventory.getItemStack(); } + Utils.LOG_INFO("Doing something ~ 1"); aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); } } @@ -119,34 +121,39 @@ public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { if (aMouseclick == 0) { if (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { + Utils.LOG_INFO("Doing something ~ 2"); aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); } + Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 127"); return aPlayer.inventory.getItemStack(); } for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) { ItemStack tStack2; if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { + Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 134"); return aPlayer.inventory.getItemStack(); } + Utils.LOG_INFO("Doing something ~ 3"); aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); } + Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 140"); return aPlayer.inventory.getItemStack(); } } - Utils.LOG_INFO("Returning null on Line 136"); + Utils.LOG_INFO("Returning null on Line 144"); return null; } if (aSlotIndex == 34) { ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).mFlushMode = true; - Utils.LOG_INFO("Returning null on Line 142"); + Utils.LOG_INFO("Returning null on Line 150"); return null; } if (aSlotIndex == 35) { ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); - Utils.LOG_INFO("Returning null on Line 148"); + Utils.LOG_INFO("Returning null on Line 156"); return null; } } @@ -155,6 +162,7 @@ public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { { e.printStackTrace(GT_Log.err); } + Utils.LOG_INFO("Returning super.slotClick() on Line 162"); return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } -- cgit From 26e10439a576e08bc3261a6d7c6c00c6cad7b761 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 10 Oct 2016 16:35:28 +1000 Subject: + Added some Geothermal Generators. + Added recipes and fuels for all Geothermals. (Normal Lava and Pahoehoe Lava) $ Fixed workbench not saving crafting table contents when closed. % Changed internal loading of Workbenches, Tanks and Geothermals. % Disabled old workbench buttons, now using Gregtech Holo slots. --- .../core/container/Container_Workbench.java | 167 ++++++++++--- .../gtPlusPlus/core/gui/machine/GUI_Workbench.java | 8 +- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 4 + .../InventoryWorkbenchHoloCrafting.java | 166 +++++++++++++ .../inventories/InventoryWorkbenchHoloSlots.java | 264 +++++++++++++++++++++ .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 12 +- src/Java/gtPlusPlus/core/slots/SlotNoInput.java | 23 ++ .../tileentities/machines/TileEntityWorkbench.java | 15 +- src/Java/gtPlusPlus/core/util/item/UtilsItems.java | 124 +++++----- src/Java/gtPlusPlus/core/util/math/MathUtils.java | 13 + .../xmod/gregtech/api/enums/GregtechItemList.java | 5 +- .../api/gui/CONTAINER_AdvancedWorkbench.java | 4 +- .../gregtech/api/gui/GUI_AdvancedWorkbench.java | 4 +- .../GregtechMetaTileEntityGeothermalGenerator.java | 139 +++++++++++ .../GregtechGeothermalThermalGenerator.java | 66 ++++++ .../gregtech/GregtechTieredFluidTanks.java | 10 +- .../registration/gregtech/GregtechWorkbenches.java | 29 +++ 17 files changed, 941 insertions(+), 112 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloCrafting.java create mode 100644 src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloSlots.java create mode 100644 src/Java/gtPlusPlus/core/slots/SlotNoInput.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeothermalThermalGenerator.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWorkbenches.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/core/container/Container_Workbench.java b/src/Java/gtPlusPlus/core/container/Container_Workbench.java index 3c12e860bc..d63133a01e 100644 --- a/src/Java/gtPlusPlus/core/container/Container_Workbench.java +++ b/src/Java/gtPlusPlus/core/container/Container_Workbench.java @@ -1,9 +1,14 @@ package gtPlusPlus.core.container; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.gui.GT_Slot_Output; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.inventories.InventoryWorkbenchChest; +import gtPlusPlus.core.inventories.InventoryWorkbenchHoloCrafting; +import gtPlusPlus.core.inventories.InventoryWorkbenchHoloSlots; import gtPlusPlus.core.inventories.InventoryWorkbenchTools; import gtPlusPlus.core.slots.SlotGtTool; +import gtPlusPlus.core.slots.SlotNoInput; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -12,7 +17,6 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; -import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; @@ -23,23 +27,31 @@ public class Container_Workbench extends Container { public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); public final InventoryWorkbenchChest inventoryChest; public final InventoryWorkbenchTools inventoryTool; + public final InventoryWorkbenchHoloSlots inventoryHolo; + public final InventoryWorkbenchHoloCrafting inventoryCrafting; + public IInventory craftResult = new InventoryCraftResult(); + private World worldObj; private int posX; private int posY; private int posZ; - - public boolean movingChest; - public boolean movingCrafting; - public static int StorageSlotNumber = 12; //Number of slots in storage area - public static int ToolSlotNumber = 5; // Number of slots in the tool area up top + public static int HoloSlotNumber = 6; public static int InputSlotNumber = 9; //Number of Slots in the Crafting Grid - public static int InOutputSlotNumber = InputSlotNumber + 1; //Same plus Output Slot + public static int StorageSlotNumber = 16; //Number of slots in storage area + public static int ToolSlotNumber = 5; // Number of slots in the tool area up top + public static int InOutputSlotNumber = InputSlotNumber + StorageSlotNumber + ToolSlotNumber + HoloSlotNumber; //Same plus Output Slot public static int InventorySlotNumber = 36; //Inventory Slots (Inventory and Hotbar) public static int InventoryOutSlotNumber = InventorySlotNumber + 1; //Inventory Slot Number + Output public static int FullSlotNumber = InventorySlotNumber + InOutputSlotNumber; //All slots - + + private int slotOutput = 0; + private int[] slotHolo = new int[5]; + private int[] slotCrafting = new int[9]; + private int[] slotStorage = new int[16]; + private int[] slotTools = new int[5]; + public void moveCraftingToChest(){ //Check Chest Space for (int i=0;i<9;i++){ @@ -78,9 +90,9 @@ public class Container_Workbench extends Container { this.tile_entity = tile; this.inventoryChest = tile.inventoryChest; this.inventoryTool = tile.inventoryTool; - - int o=0; - + this.inventoryHolo = tile.inventoryHolo; + this.inventoryCrafting = tile.inventoryCrafting; + int var6; int var7; worldObj = tile.getWorldObj(); @@ -88,8 +100,24 @@ public class Container_Workbench extends Container { posY = tile.yCoord; posZ = tile.zCoord; + int o=0; + //Output slot - addSlotToContainer(new SlotCrafting(inventory.player, this.craftMatrix, craftResult, 0, 136, 64)); + addSlotToContainer(new GT_Slot_Output(inventoryHolo, 0, 136, 64)); + //Util Slots + addSlotToContainer(new SlotNoInput(inventoryHolo, 1, 136, 28)); + addSlotToContainer(new SlotNoInput(inventoryHolo, 2, 154, 28)); + addSlotToContainer(new SlotNoInput(inventoryHolo, 3, 154, 64)); + //Holo Slots + addSlotToContainer(new GT_Slot_Holo(inventoryHolo, 4, 154, 46, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(inventoryHolo, 5, 136, 46, false, false, 1)); + + for (int i=1; i<6; i++){ + slotHolo[o] = o+1; + o++; + } + + o=0; //Crafting Grid for (var6 = 0; var6 < 3; ++var6) @@ -97,25 +125,17 @@ public class Container_Workbench extends Container { for (var7 = 0; var7 < 3; ++var7) { this.addSlotToContainer(new Slot(this.craftMatrix, var7 + var6 * 3, 82 + var7 * 18, 28 + var6 * 18)); + + if (this.inventoryCrafting.getStackInSlot(o) != null){ + this.craftMatrix.setInventorySlotContents(o, inventoryCrafting.getStackInSlot(o)); + this.inventoryCrafting.setInventorySlotContents(o, null); + } + slotCrafting[o] = o+6; + o++; } } - //Player Inventory - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 9; ++var7) - { - this.addSlotToContainer(new Slot(inventory, var7 + var6 * 9 + 9, 8 + var7 * 18, 84 + var6 * 18)); - } - } - - //Player Hotbar - for (var6 = 0; var6 < 9; ++var6) - { - this.addSlotToContainer(new Slot(inventory, var6, 8 + var6 * 18, 142)); - } - - + o=0; //Storage Side for (var6 = 0; var6 < 4; ++var6) @@ -124,28 +144,100 @@ public class Container_Workbench extends Container { { //Utils.LOG_INFO("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18)); this.addSlotToContainer(new Slot(inventoryChest, var7 + var6 * 4, 8 + var7 * 18, 7 + var6 * 18)); + slotStorage[o] = o+15; + o++; } } + o=0; + //Tool Slots for (var6 = 0; var6 < 1; ++var6) { for (var7 = 0; var7 < 5; ++var7) { this.addSlotToContainer(new SlotGtTool(inventoryTool, var7 + var6 * 3, 82 + var7 * 18, 8 + var6 * 18)); + slotTools[o] = o+31; + o++; } } + //Player Inventory + for (var6 = 0; var6 < 3; ++var6) + { + for (var7 = 0; var7 < 9; ++var7) + { + this.addSlotToContainer(new Slot(inventory, var7 + var6 * 9 + 9, 8 + var7 * 18, 84 + var6 * 18)); + } + } + + //Player Hotbar + for (var6 = 0; var6 < 9; ++var6) + { + this.addSlotToContainer(new Slot(inventory, var6, 8 + var6 * 18, 142)); + } + this.onCraftMatrixChanged(this.craftMatrix); } +/* @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer){ + + if (aSlotIndex == 999 || aSlotIndex == -999){ + Utils.LOG_INFO("??? - "+aSlotIndex); + } + + if (aSlotIndex == slotOutput){ + Utils.LOG_INFO("Player Clicked on the output slot"); + } + + for (int x : slotHolo){ + if (aSlotIndex == x){ + Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the Holo Grid"); + if (x == 1){ + Utils.LOG_INFO("Player Clicked Blueprint slot in the Holo Grid"); + } + else if (x == 2){ + Utils.LOG_INFO("Player Clicked Right Arrow slot in the Holo Grid"); + } + else if (x == 3){ + Utils.LOG_INFO("Player Clicked Big [P] slot in the Holo Grid"); + } + else if (x == 4){ + Utils.LOG_INFO("Player Clicked Transfer to Crafting Grid slot in the Holo Grid"); + } + else if (x == 5){ + Utils.LOG_INFO("Player Clicked Transfer to Storage Grid slot in the Holo Grid"); + } + } + } + + for (int x : slotCrafting){ + if (aSlotIndex == x){ + Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the crafting Grid"); + } + } + for (int x : slotStorage){ + if (aSlotIndex == x){ + Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the storage Grid"); + } + } + for (int x : slotTools){ + if (aSlotIndex == x){ + Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the tool Grid"); + } + } + //Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the Grid"); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } +*/ @Override public void onCraftMatrixChanged(IInventory par1IInventory){ //Custom Recipe Handler //craftResult.setInventorySlotContents(0, Workbench_CraftingHandler.getInstance().findMatchingRecipe(craftMatrix, worldObj)); - + //Vanilla CraftingManager craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj)); } @@ -153,11 +245,15 @@ public class Container_Workbench extends Container { @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) - { - - super.onContainerClosed(par1EntityPlayer); + { + for (int o=0; o= 0 && slot < INV_SIZE) + { + inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(NBTTagCompound nbt) + { + NBTTagList list = new NBTTagList(); + for(int i = 0;i amount) + { + stack = stack.splitStack(amount); + markDirty(); + } + else + { + setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + ItemStack stack = getStackInSlot(slot); + setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + inventory[slot] = stack; + if (stack != null && stack.stackSize > getInventoryStackLimit()) + { + stack.stackSize = getInventoryStackLimit(); + } + markDirty(); + } + + @Override + public String getInventoryName() + { + return name; + } + + @Override + public boolean hasCustomInventoryName() + { + return name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + @Override + public void markDirty() + { + for (int i = 0; i < getSizeInventory(); ++i) + { + ItemStack temp = getStackInSlot(i); + if (temp != null){ + //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if (temp != null && temp.stackSize == 0) { + inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) + { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) + { + return true; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloSlots.java b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloSlots.java new file mode 100644 index 0000000000..2bc84f492d --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloSlots.java @@ -0,0 +1,264 @@ +package gtPlusPlus.core.inventories; + +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class InventoryWorkbenchHoloSlots implements IInventory{ + + private String name = "Inventory Holo"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 6; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryWorkbenchHoloSlots() + { + + } + + public void readFromNBT(NBTTagCompound nbt) + { + NBTTagList list = nbt.getTagList("Items", 10); + inventory = new ItemStack[INV_SIZE]; + for(int i = 0;i= 0 && slot < INV_SIZE) + { + inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(NBTTagCompound nbt) + { + NBTTagList list = new NBTTagList(); + for(int i = 0;i getInventoryStackLimit()) + { + stack.stackSize = getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() + { + for (int i = 0; i < getSizeInventory(); ++i) + { + if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { + inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) + { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) + { + return false; + } + + /** A list of one item containing the result of the crafting formula */ + private ItemStack[] stackResult = new ItemStack[1]; + + /** + * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a + * new stack. + */ + /*@Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) + { + ItemStack stack = getStackInSlot(0); + if (this.stackResult[0] != null) + { + ItemStack itemstack = this.stackResult[0]; + this.stackResult[0] = null; + return itemstack; + } + if(stack != null) + { + if(stack.stackSize > p_70298_2_) + { + stack = stack.splitStack(p_70298_2_); + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + setInventorySlotContents(p_70298_1_, null); + } + } + return stack; + }*/ + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) + { + if (getStackInSlot(0) != null){ + Utils.LOG_INFO("getStackInSlot(0) contains "+getStackInSlot(0).getDisplayName()); + if (this.stackResult[0] == null){ + Utils.LOG_INFO("this.stackResult[0] == null"); + this.stackResult[0] = getStackInSlot(0); + } + else if (this.stackResult[0] != null){ + Utils.LOG_INFO("this.stackResult[0] != null"); + if (this.stackResult[0].getDisplayName().toLowerCase().equals(getStackInSlot(0).getDisplayName().toLowerCase())){ + Utils.LOG_INFO("Items are the same?"); + } + else { + Utils.LOG_INFO("Items are not the same."); + } + } + } + + if (this.stackResult[0] != null) + { + Utils.LOG_INFO("this.stackResult[0] == null - Really never should be here though. - Returning "+this.stackResult[0].getDisplayName()); + ItemStack itemstack = this.stackResult[0]; + this.stackResult[0] = null; + return itemstack; + } + return null; + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) + { + if (this.stackResult[0] != null) + { + ItemStack itemstack = this.stackResult[0]; + this.stackResult[0] = null; + return itemstack; + } + return null; + } + +} + + + +//Default Behaviour +/*@Override +public ItemStack decrStackSize(int slot, int amount) +{ + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + setInventorySlotContents(slot, null); + } + } + return stack; +}*/ + +//Default Behaviour +/*@Override +public ItemStack getStackInSlotOnClosing(int slot) +{ + ItemStack stack = getStackInSlot(slot); + setInventorySlotContents(slot, null); + return stack; +}*/ + diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index bb482d96d5..6a1e496305 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -13,6 +13,7 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; public class RECIPES_GREGTECH { @@ -175,6 +176,13 @@ public class RECIPES_GREGTECH { GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketFire_water", 0, 1), null, 120, 0); GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketHootch", 0, 1), null, 36, 0); + + + + //CORE.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); + GT_Values.RA.addFuel(UtilsItems.getSimpleStack(Items.lava_bucket), null, 32, 2); + GT_Values.RA.addFuel(UtilsItems.getIC2Cell(2), null, 32, 2); + GT_Values.RA.addFuel(UtilsItems.getIC2Cell(11), null, 24, 2); //System.exit(1); } @@ -196,9 +204,5 @@ public class RECIPES_GREGTECH { 240); } - private static void registerSkookumChoocher(){ - //GT_ModHandler.addCraftingRecipe(GT_OreDictUnificator.get(OrePrefixes.toolHeadUniversalSpade, aMaterial, 1L), tBits, new Object[]{"fX", Character.valueOf('X'), OrePrefixes.toolHeadShovel.get(aMaterial)}); - } - } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/slots/SlotNoInput.java b/src/Java/gtPlusPlus/core/slots/SlotNoInput.java new file mode 100644 index 0000000000..fe51631a5d --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotNoInput.java @@ -0,0 +1,23 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotNoInput extends Slot{ + + public SlotNoInput(IInventory inventory, int x, int y, int z) { + super(inventory, x, y, z); + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return false; + } + + @Override + public int getSlotStackLimit() { + return 0; + } + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java index 49ade0a10a..b0c4fefbf0 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java @@ -1,6 +1,8 @@ package gtPlusPlus.core.tileentities.machines; import gtPlusPlus.core.inventories.InventoryWorkbenchChest; +import gtPlusPlus.core.inventories.InventoryWorkbenchHoloCrafting; +import gtPlusPlus.core.inventories.InventoryWorkbenchHoloSlots; import gtPlusPlus.core.inventories.InventoryWorkbenchTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -9,11 +11,14 @@ public class TileEntityWorkbench extends TileEntity { public InventoryWorkbenchChest inventoryChest; public InventoryWorkbenchTools inventoryTool; - //public InventoryWorkbenchCrafting inventoryCrafting; + public InventoryWorkbenchHoloSlots inventoryHolo; + public InventoryWorkbenchHoloCrafting inventoryCrafting; public TileEntityWorkbench(){ this.inventoryTool = new InventoryWorkbenchTools();//number of slots - without product slot this.inventoryChest = new InventoryWorkbenchChest();//number of slots - without product slot + this.inventoryHolo = new InventoryWorkbenchHoloSlots(); + this.inventoryCrafting = new InventoryWorkbenchHoloCrafting(); this.canUpdate(); } @@ -33,7 +38,8 @@ public class TileEntityWorkbench extends TileEntity { super.writeToNBT(nbt); inventoryChest.writeToNBT(getTag(nbt, "ContentsChest")); inventoryTool.writeToNBT(getTag(nbt, "ContentsTools")); - //inventoryCrafting.writeToNBT(getTag(nbt, "ContentsCrafting")); + inventoryCrafting.writeToNBT(getTag(nbt, "ContentsCrafting")); + inventoryHolo.writeToNBT(getTag(nbt, "ContentsHolo")); } @@ -43,7 +49,10 @@ public class TileEntityWorkbench extends TileEntity { super.readFromNBT(nbt); inventoryChest.readFromNBT(nbt.getCompoundTag("ContentsChest")); inventoryTool.readFromNBT(nbt.getCompoundTag("ContentsTools")); - //inventoryCrafting.readFromNBT(nbt.getCompoundTag("ContentsCrafting")); + inventoryCrafting.readFromNBT(nbt.getCompoundTag("ContentsCrafting")); + inventoryHolo.readFromNBT(nbt.getCompoundTag("ContentsHolo")); } + + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java index 52392aeb00..ec4e457489 100644 --- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java +++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.util.item; import gregtech.api.enums.Materials; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.BlockBaseModular; @@ -65,6 +66,23 @@ public class UtilsItems { } } + public static ItemStack getIC2Cell(String S){ + ItemStack moreTemp = UtilsItems.getItemStackOfAmountFromOreDictNoBroken("cell"+S, 1); + + if (moreTemp == null){ + int cellID = 0; + ItemStack temp =GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID); + return temp != null ? temp : null; + } + + return moreTemp; + } + + public static ItemStack getIC2Cell(int meta){ + ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, meta); + return temp != null ? temp : null; + } + public static void getItemForOreDict(String FQRN, String oreDictName, String itemName, int meta){ try { @@ -86,10 +104,10 @@ public class UtilsItems { Utils.LOG_ERROR(itemName+" not found. [NULL]"); } } - + public static void addItemToOreDictionary(ItemStack stack, String oreDictName){ try { - GT_OreDictUnificator.registerOre(oreDictName, stack); + GT_OreDictUnificator.registerOre(oreDictName, stack); } catch (NullPointerException e) { Utils.LOG_ERROR(stack.getDisplayName()+" not registered. [NULL]"); } @@ -231,7 +249,7 @@ public class UtilsItems { Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay).setUnlocalizedName("spawn_egg_"+parSpawnName.toLowerCase()).setTextureName(CORE.MODID+":spawn_egg"); GameRegistry.registerItem(itemSpawnEgg, "spawnEgg"+parSpawnName); } - + public static ItemStack[] validItemsForOreDict(String oredictName){ List validNames = MaterialUtils.oreDictValuesForEntry(oredictName); @@ -245,58 +263,58 @@ public class UtilsItems { public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, int amount){ ArrayList oreDictList = OreDictionary.getOres(oredictName); if (!oreDictList.isEmpty()){ - ItemStack returnValue = oreDictList.get(0).copy(); - returnValue.stackSize = amount; - return returnValue; + ItemStack returnValue = oreDictList.get(0).copy(); + returnValue.stackSize = amount; + return returnValue; } - return getSimpleStack(ModItems.AAA_Broken, amount); + return getSimpleStack(ModItems.AAA_Broken, amount); } - + public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, int amount){ ItemStack returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); - + if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() || returnValue.getItem() != ModItems.AAA_Broken){ - return returnValue; + return returnValue; } - Utils.LOG_INFO(oredictName+" was not valid."); - return null; + Utils.LOG_INFO(oredictName+" was not valid."); + return null; } - + public static void generateItemsFromMaterial(Material matInfo){ - + String unlocalizedName = matInfo.getUnlocalizedName(); String materialName = matInfo.getLocalizedName(); short[] C = matInfo.getRGBA(); int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); boolean hotIngot = matInfo.requiresBlastFurnace(); int materialTier = matInfo.vTier; //TODO - + if (materialTier > 10 || materialTier <= 0){ materialTier = 2; } - - - + + + int sRadiation = 0; if (isRadioactive(materialName)){ sRadiation = getRadioactivityLevel(materialName); } - + if (sRadiation >= 1){ Item temp; Block tempBlock; tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.STANDARD, Colour); temp = new BaseItemIngot("itemIngot"+unlocalizedName, materialName, Colour, sRadiation); - + temp = new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, sRadiation); temp = new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, sRadiation); temp = new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, sRadiation); - + temp = new BaseItemPlate("itemPlate"+unlocalizedName, materialName, Colour, materialTier, sRadiation); temp = new BaseItemRod(matInfo, sRadiation); temp = new BaseItemRodLong(matInfo, sRadiation); } - + else { Item temp; Block tempBlock; @@ -306,11 +324,11 @@ public class UtilsItems { if (hotIngot){ Item tempIngot = temp; temp = new BaseItemIngotHot("itemHotIngot"+unlocalizedName, materialName, UtilsItems.getSimpleStack(tempIngot, 1), materialTier); - } + } temp = new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, sRadiation); temp = new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, sRadiation); temp = new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, sRadiation); - + temp = new BaseItemPlate("itemPlate"+unlocalizedName, materialName, Colour, materialTier, sRadiation); temp = new BaseItemPlateDouble("itemPlateDouble"+unlocalizedName, materialName, Colour, materialTier, sRadiation); temp = new BaseItemBolt(matInfo); @@ -321,30 +339,30 @@ public class UtilsItems { temp = new BaseItemRotor("itemRotor"+unlocalizedName, materialName, Colour); temp = new BaseItemGear(matInfo); } - + RecipeGen_Plates.generateRecipes(matInfo); - + FluidUtils.generateFluid(matInfo, 1); - + } - + public static Item[] generateDusts(String unlocalizedName, String materialName, int materialTier, Material matInfo, int Colour){ int radioactive = getRadioactivityLevel(materialName); Item[] output = { - new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, radioactive), - new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, radioactive), - new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, radioactive)}; + new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, radioactive), + new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, radioactive), + new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, radioactive)}; return output; } - + public static Item[] generateSpecialUseDusts(String unlocalizedName, String materialName, int Colour){ Item[] output = { - new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust"), - new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, Colour, "Small"), - new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, Colour, "Tiny")}; + new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust"), + new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, Colour, "Small"), + new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, Colour, "Tiny")}; return output; } - + public static MultiPickaxeBase generateMultiPick(boolean GT_Durability, Materials material){ ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); Utils.LOG_INFO("Generating a Multi-Pick out of "+material.name()); @@ -360,26 +378,26 @@ public class UtilsItems { dur = material.mDurability; Utils.LOG_INFO("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); } - + if (dur <= 0){ Utils.LOG_INFO("Still too low, "+material.name()+" will now go unused."); return null; } - + MultiPickaxeBase MP_Redstone = new MultiPickaxeBase( material.name()+" Multipick", (customMaterial), dur, Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) ); - + if (MP_Redstone.isValid){ return MP_Redstone; } return null; - + } - + public static MultiSpadeBase generateMultiShovel(boolean GT_Durability, Materials material){ ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); Utils.LOG_INFO("Generating a Multi-Shovel out of "+material.name()); @@ -395,26 +413,26 @@ public class UtilsItems { dur = material.mDurability; Utils.LOG_INFO("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); } - + if (dur <= 0){ Utils.LOG_INFO("Still too low, "+material.name()+" will now go unused."); return null; } - + MultiSpadeBase MP_Redstone = new MultiSpadeBase( material.name()+" Multishovel", (customMaterial), dur, Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) ); - + if (MP_Redstone.isValid){ return MP_Redstone; } return null; - + } - + public static boolean isRadioactive(String materialName){ int sRadiation = 0; if (materialName.toLowerCase().contains("uranium")){ @@ -431,7 +449,7 @@ public class UtilsItems { } return false; } - + public static int getRadioactivityLevel(String materialName){ int sRadiation = 0; if (materialName.toLowerCase().contains("uranium")){ @@ -445,7 +463,7 @@ public class UtilsItems { } return sRadiation; } - + public static String getArrayStackNames(ItemStack[] aStack){ String itemNames = "Item Array: "; for (ItemStack alph : aStack){ @@ -453,9 +471,9 @@ public class UtilsItems { itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; } return itemNames; - + } - + public static String[] getArrayStackNamesAsArray(ItemStack[] aStack){ String[] itemNames = {}; int arpos = 0; @@ -464,9 +482,9 @@ public class UtilsItems { arpos++; } return itemNames; - + } - + public static String getFluidArrayStackNames(FluidStack[] aStack){ String itemNames = "Fluid Array: "; for (FluidStack alph : aStack){ @@ -474,7 +492,7 @@ public class UtilsItems { itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount; } return itemNames; - + } } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 3df5693bc3..b4aec5a8bf 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -103,6 +103,19 @@ public class MathUtils { public static double decimalRoundingToWholes(double d) { return 5*(Math.round(d/5)); } + + public static int roundToClosestMultiple(double number, int multiple) { + int result = multiple; + if (number % multiple == 0) { + return (int) number; + } + // If not already multiple of given number + if (number % multiple != 0) { + int division = (int) ((number / multiple) + 1); + result = division * multiple; + } + return result; + } /** diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index de0a72f484..346b239932 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -125,7 +125,10 @@ public enum GregtechItemList implements GregtechItemContainer { Industrial_MultiTank, Industrial_MultiTankDense, Casing_MultitankExterior, //Gt4 Workbenches - GT4_Workbench_Bronze, GT4_Workbench_Advanced; + GT4_Workbench_Bronze, GT4_Workbench_Advanced, + + //Geothermal Engines + Geothermal_Engine_EV, Geothermal_Engine_IV, Geothermal_Engine_LuV; public static final GregtechItemList[] DYE_ONLY_ITEMS = { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java index 47c8aedb98..c5bfc4ac7b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java @@ -1,19 +1,19 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.slots.SlotGtTool; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.dev.GT_ContainerMetaTile_MachineEx; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { +public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_MachineEx { public CONTAINER_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java index 7da9238bd5..c52d50d674 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java @@ -1,12 +1,12 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.dev.GT_GUIContainerMetaTile_MachineEx; import net.minecraft.entity.player.InventoryPlayer; public class GUI_AdvancedWorkbench -extends GT_GUIContainerMetaTile_Machine +extends GT_GUIContainerMetaTile_MachineEx { public GUI_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java new file mode 100644 index 0000000000..263254c751 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java @@ -0,0 +1,139 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; + +public class GregtechMetaTileEntityGeothermalGenerator +extends GT_MetaTileEntity_BasicGenerator +{ + + public int mEfficiency; + + public GregtechMetaTileEntityGeothermalGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires Pahoehoe Lava or Normal Lava as Fuel", new ITexture[0]); + onConfigLoad(); + } + + public GregtechMetaTileEntityGeothermalGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public int getCapacity() { + //return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); + return 5000*this.mTier; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "ThermalGenerator.efficiency.tier." + this.mTier, (100 - this.mTier * 7)); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(ItemStack aStack) { + int rValue = Math.max(GT_ModHandler.getFuelCanValue(aStack) * 6 / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityGeothermalGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP)}; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM)}; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER)}; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT)}; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE)}; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE)}; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE)}; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE)}; + } + + + @Override + public String[] getDescription() + { + return new String[] {"Generates power from Lava/Pahoehoe at " + getEfficiency() + "% Efficiency per tick"}; + } + + @Override + public GT_Recipe_Map getRecipes() + { + return GT_Recipe_Map.sHotFuels; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeothermalThermalGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeothermalThermalGenerator.java new file mode 100644 index 0000000000..961abedc8d --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeothermalThermalGenerator.java @@ -0,0 +1,66 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.RECIPE_CONSTANTS; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntityGeothermalGenerator; +import net.minecraft.item.ItemStack; + +public class GregtechGeothermalThermalGenerator { + + public static void run() + { + if (LoadedMods.Gregtech){ + Utils.LOG_INFO("Gregtech5u Content | Registering Industrial Geothermal Engines."); + run1(); + } + + } + + private static void run1(){ + GregtechItemList.Geothermal_Engine_EV.set(new GregtechMetaTileEntityGeothermalGenerator(830, "advancedgenerator.geothermalFuel.tier.01", "Basic Geothermal Engine", 4).getStackForm(1L)); + GregtechItemList.Geothermal_Engine_IV.set(new GregtechMetaTileEntityGeothermalGenerator(831, "advancedgenerator.geothermalFuel.tier.02", "Turbo Geothermal Engine", 5).getStackForm(1L)); + GregtechItemList.Geothermal_Engine_LuV.set(new GregtechMetaTileEntityGeothermalGenerator(832, "advancedgenerator.geothermalFuel.tier.03", "Vulcan Geothermal Engine", 6).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Geothermal_Engine_EV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"CEC", "GMG", "PWP", + Character.valueOf('M'), ItemList.Hull_EV, + Character.valueOf('P'), ItemList.Electric_Piston_EV, + Character.valueOf('E'), ItemList.Electric_Motor_EV, + Character.valueOf('C'), GregtechOrePrefixes.circuit.get(Materials.Ultimate), + Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Aluminium), + Character.valueOf('G'), OrePrefixes.gearGt.get(Materials.Titanium)}); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Geothermal_Engine_IV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"CEC", "GMG", "PWP", + Character.valueOf('M'), ItemList.Hull_IV, + Character.valueOf('P'), ItemList.Electric_Piston_IV, + Character.valueOf('E'), ItemList.Electric_Motor_IV, + Character.valueOf('C'), GregtechOrePrefixes.circuit.get(GT_Materials.Symbiotic), + Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Platinum), + Character.valueOf('G'), OrePrefixes.gearGt.get(Materials.TungstenSteel)}); + + final ItemStack INGREDIENT_1 = RECIPE_CONSTANTS.electricPiston_LuV; + final ItemStack INGREDIENT_2 = RECIPE_CONSTANTS.electricMotor_LuV; + GT_ModHandler.addCraftingRecipe(GregtechItemList.Geothermal_Engine_LuV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"CEC", "GMG", "PWP", + Character.valueOf('M'), ItemList.Hull_LuV, + Character.valueOf('P'), INGREDIENT_1, + Character.valueOf('E'), INGREDIENT_2, + Character.valueOf('C'), GregtechOrePrefixes.circuit.get(GT_Materials.Neutronic), + Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Tungsten), + Character.valueOf('G'), OrePrefixes.gearGt.get(Materials.Chrome)}); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java index 4632b306ed..690ebcc0ec 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java @@ -3,8 +3,6 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredTank; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_NBT_Tank; @@ -32,13 +30,7 @@ public class GregtechTieredFluidTanks GregtechItemList.GT_FluidTank_LuV.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.06", "Ludicrous Voltage Fluid Tank", 6).getStackForm(1L)); GregtechItemList.GT_FluidTank_ZPM.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.07", "ZPM Voltage Fluid Tank", 7).getStackForm(1L)); GregtechItemList.GT_FluidTank_UV.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.08", "Ultimate Voltage Fluid Tank", 8).getStackForm(1L)); - GregtechItemList.GT_FluidTank_MAX.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); - - //Gregtech 4 Workbenches - GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(828, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); - GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(829, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); - - + GregtechItemList.GT_FluidTank_MAX.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); } private static void run2() diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWorkbenches.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWorkbenches.java new file mode 100644 index 0000000000..4486bc5cd5 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWorkbenches.java @@ -0,0 +1,29 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; + +public class GregtechWorkbenches +{ + public static void run() + { + if (LoadedMods.Gregtech){ + Utils.LOG_INFO("Gregtech5u Content | Registering Workbenches."); + run1(); + //run2(); + } + + } + + private static void run1() + { + //Gregtech 4 Workbenches + GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(828, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); + GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(829, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); + + + } +} -- cgit From d6bf108b40f0b281ff7c3c2bc91e43ed2b9883f7 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 17 Oct 2016 01:39:50 +1000 Subject: + Added Tesseract Generators and Terminals. + Added a handful of new, old textures from GT4. % Rewrote portions of the Blueprint item again, to try make it work better with NBT. + Added an Example NBT item for myself~ because I am a derp. + Added some custom textures for the Industrial Centrifuge. % Moved all the GT4 Tile Entities to their own loading class. --- src/Java/gtPlusPlus/GTplusplus.java | 5 + .../core/container/Container_Workbench.java | 23 +- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 4 +- .../core/handler/Recipes/RegistrationHandler.java | 2 + .../gtPlusPlus/core/interfaces/IItemBlueprint.java | 4 +- .../gtPlusPlus/core/item/base/BaseItemBrain.java | 108 ++++ .../core/item/general/ItemBlueprint.java | 225 ++++++-- src/Java/gtPlusPlus/core/lib/CORE.java | 5 + .../gtPlusPlus/core/recipe/RECIPES_General.java | 49 ++ src/Java/gtPlusPlus/core/util/item/UtilsItems.java | 11 +- .../gtPlusPlus/core/util/recipe/UtilsRecipe.java | 11 +- .../xmod/gregtech/api/enums/GregtechItemList.java | 5 +- .../api/gui/CONTAINER_AdvancedWorkbench.java | 4 +- .../gregtech/api/gui/GUI_AdvancedWorkbench.java | 4 +- .../blocks/textures/CasingTextureHandler.java | 11 +- .../textures/TexturesCentrifugeMultiblock.java | 441 +++++++++++++++ .../common/blocks/textures/TexturesGtBlocks.java | 75 +++ .../GT_MetaTileEntity_TesseractGenerator.java | 602 +++++++++++++++++++++ .../GT_MetaTileEntity_TesseractTerminal.java | 504 +++++++++++++++++ ...GregtechMetaTileEntityIndustrialCentrifuge.java | 13 +- .../registration/gregtech/Gregtech4Content.java | 37 ++ .../registration/gregtech/GregtechWorkbenches.java | 29 - .../TileEntities/adv_machine_dimensional.png | Bin 0 -> 1660 bytes .../adv_machine_dimensional.png.mcmeta | 5 + .../TileEntities/adv_machine_screen_frequency.png | Bin 0 -> 822 bytes .../TileEntities/adv_machine_screen_random1.png | Bin 0 -> 12342 bytes .../adv_machine_screen_random1.png.mcmeta | 5 + .../TileEntities/adv_machine_screen_random2.png | Bin 0 -> 12342 bytes .../adv_machine_screen_random2.png.mcmeta | 5 + .../TileEntities/adv_machine_screen_random3.png | Bin 0 -> 12342 bytes .../adv_machine_screen_random3.png.mcmeta | 5 + .../TileEntities/high_adv_machine_dimensional.png | Bin 0 -> 1713 bytes .../high_adv_machine_dimensional.png.mcmeta | 5 + 33 files changed, 2085 insertions(+), 112 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/base/BaseItemBrain.java create mode 100644 src/Java/gtPlusPlus/core/recipe/RECIPES_General.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWorkbenches.java create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_dimensional.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_dimensional.png.mcmeta create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_frequency.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random1.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random1.png.mcmeta create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random2.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random2.png.mcmeta create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random3.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random3.png.mcmeta create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/high_adv_machine_dimensional.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/high_adv_machine_dimensional.png.mcmeta (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 89988a1248..3fb57d064c 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -24,6 +24,7 @@ import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; import java.awt.event.ActionEvent; @@ -120,7 +121,11 @@ implements ActionListener @SideOnly(value=Side.CLIENT) public static void loadTextures(){ Utils.LOG_INFO("Loading some textures on the client."); + //Tools Utils.LOG_WARNING("Processing texture: "+TexturesGtTools.SKOOKUM_CHOOCHER.getTextureFile().getResourcePath()); + + //Blocks + Utils.LOG_WARNING("Processing texture: "+TexturesGtBlocks.Casing_Machine_Dimensional.getTextureFile().getResourcePath()); } diff --git a/src/Java/gtPlusPlus/core/container/Container_Workbench.java b/src/Java/gtPlusPlus/core/container/Container_Workbench.java index 5ce6d0e1a2..b3b024f52c 100644 --- a/src/Java/gtPlusPlus/core/container/Container_Workbench.java +++ b/src/Java/gtPlusPlus/core/container/Container_Workbench.java @@ -188,8 +188,9 @@ public class Container_Workbench extends Container { @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer){ + if (!aPlayer.worldObj.isRemote){ if (aSlotIndex == 999 || aSlotIndex == -999){ - Utils.LOG_INFO("??? - "+aSlotIndex); + //Utils.LOG_INFO("??? - "+aSlotIndex); } if (aSlotIndex == slotOutput){ @@ -210,7 +211,7 @@ public class Container_Workbench extends Container { Utils.LOG_INFO("Found a blueprint."); ItemStack tempBlueprint = inventoryHolo.getStackInSlot(1); ItemBlueprint tempItemBlueprint = (ItemBlueprint) tempBlueprint.getItem(); - if (inventoryHolo.getStackInSlot(0) != null){ + if (inventoryHolo.getStackInSlot(0) != null && !tempItemBlueprint.hasBlueprint(tempBlueprint)){ Utils.LOG_INFO("Output slot was not empty."); Utils.LOG_INFO("Trying to manipulate NBT data on the blueprint stack, then replace it with the new one."); tempItemBlueprint.setBlueprint(inventoryHolo.getStackInSlot(1), craftMatrix, inventoryHolo.getStackInSlot(0)); @@ -219,7 +220,12 @@ public class Container_Workbench extends Container { Utils.LOG_INFO(UtilsItems.getArrayStackNames(tempItemBlueprint.getBlueprint(newTempBlueprint))); } else { - Utils.LOG_INFO("Output slot was empty."); + if (tempItemBlueprint.hasBlueprint(tempBlueprint)){ + Utils.LOG_INFO("Blueprint already holds a recipe."); + } + else { + Utils.LOG_INFO("Output slot was empty."); + } } } else { @@ -257,6 +263,7 @@ public class Container_Workbench extends Container { Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the tool Grid"); } } + } //Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the Grid"); return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } @@ -267,7 +274,15 @@ public class Container_Workbench extends Container { //craftResult.setInventorySlotContents(0, Workbench_CraftingHandler.getInstance().findMatchingRecipe(craftMatrix, worldObj)); //Vanilla CraftingManager - craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj)); + Utils.LOG_INFO("checking crafting grid for a valid output."); + ItemStack temp = CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj); + if (temp != null){ + Utils.LOG_INFO("Output found. "+temp.getDisplayName()+" x"+temp.stackSize); + inventoryHolo.setInventorySlotContents(slotOutput, temp); + } + else { + Utils.LOG_INFO("No Valid output found."); + } } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index fd7fbf9645..e51dc157c6 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -42,7 +42,7 @@ import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSolarGenerators; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSteamCondenser; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSuperConductionPoint; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTieredFluidTanks; -import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechWorkbenches; +import gtPlusPlus.xmod.gregtech.registration.gregtech.Gregtech4Content; import java.util.LinkedList; import java.util.Queue; @@ -91,7 +91,7 @@ public class COMPAT_HANDLER { GregtechDehydrator.run(); GregtechTieredFluidTanks.run(); GregtechIndustrialMultiTank.run(); - GregtechWorkbenches.run(); + Gregtech4Content.run(); GregtechGeothermalThermalGenerator.run(); } diff --git a/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java b/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java index affb56566d..275a67f571 100644 --- a/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java +++ b/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.handler.Recipes; import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.recipe.RECIPES_General; import gtPlusPlus.core.recipe.RECIPES_MachineComponents; import gtPlusPlus.core.recipe.RECIPES_Machines; import gtPlusPlus.core.recipe.RECIPES_Shapeless; @@ -23,6 +24,7 @@ public class RegistrationHandler { RECIPES_Shapeless.RECIPES_LOAD(); RECIPES_MachineComponents.RECIPES_LOAD(); RECIPE_Batteries.RECIPES_LOAD(); + RECIPES_General.RECIPES_LOAD(); //RECIPES_MTWRAPPER.run(); Utils.LOG_INFO("Loaded: "+recipesSuccess+" Failed: "+recipesFailed); COMPAT_HANDLER.areInitItemsLoaded = true; diff --git a/src/Java/gtPlusPlus/core/interfaces/IItemBlueprint.java b/src/Java/gtPlusPlus/core/interfaces/IItemBlueprint.java index f3f4e40b66..90126b1e82 100644 --- a/src/Java/gtPlusPlus/core/interfaces/IItemBlueprint.java +++ b/src/Java/gtPlusPlus/core/interfaces/IItemBlueprint.java @@ -29,7 +29,7 @@ public interface IItemBlueprint { * @param String Blueprint Name * @return N/A */ - public void setBlueprintName(String name); + public void setBlueprintName(ItemStack stack, String name); /** * Does this itemstack hold a blueprint? @@ -43,6 +43,6 @@ public interface IItemBlueprint { * @param stack yourMetaItem * @return the blueprints contents */ - public ItemStack[] getBlueprint(ItemStack stack); + public ItemStack[] getBlueprint(ItemStack stack); } diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemBrain.java b/src/Java/gtPlusPlus/core/item/base/BaseItemBrain.java new file mode 100644 index 0000000000..86cd1c8046 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemBrain.java @@ -0,0 +1,108 @@ +package gtPlusPlus.core.item.base; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/* + * + * + Key Point: You can access the NBT compound data from the Item class (in those methods that pass an ItemStack), but the NBT compound can only be set on an ItemStack. + + The steps to add NBT data to an ItemStack: + Create or otherwise get an ItemStack of the desired item + Create an NBTTagCompound and fill it with the appropriate data + Call ItemStack#setTagCompound() method to set it. + + * + */ + +public class BaseItemBrain extends Item{ + // This is an array of all the types I am going to be adding. + String[] brainTypes = { "dead", "preserved", "fresh", "tasty" }; + + // This method allows us to have different language translation keys for + // each item we add. + @Override + public String getUnlocalizedName(ItemStack stack) + { + // This makes sure that the stack has a tag compound. This is how data + // is stored on items. + if (stack.hasTagCompound()) + { + // This is the object holding all of the item data. + NBTTagCompound itemData = stack.getTagCompound(); + // This checks to see if the item has data stored under the + // brainType key. + if (itemData.hasKey("brainType")) + { + // This retrieves data from the brainType key and uses it in + // the return value + return "item." + itemData.getString("brainType"); + } + } + // This will be used if the item is obtained without nbt data on it. + return "item.nullBrain"; + } + + + // This is a fun method which allows us to run some code when our item is + // shown in a creative tab. I am going to use it to add all the brain + // types. + @SuppressWarnings("unchecked") + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, List itemList) + { + // This creates a loop with a counter. It will go through once for + // every listing in brainTypes, and gives us a number associated + // with each listing. + for (int pos = 0; pos < brainTypes.length; pos++) + { + // This creates a new ItemStack instance. The item parameter + // supplied is this item. + ItemStack brainStack = new ItemStack(item); + // By default, a new ItemStack does not have any nbt compound data. + // We need to give it some. + brainStack.setTagCompound(new NBTTagCompound()); + // Now we set the type of the item, brainType is the key, and + // brainTypes[pos] is grabbing a + // entry from the brainTypes array. + brainStack.getTagCompound().setString("brainType", + brainTypes[pos]); + // And this adds it to the itemList, which is a list of all items + // in the creative tab. + itemList.add(brainStack); + } + } + + // This code will allow us to tell the items apart in game. You can change + @SuppressWarnings("unchecked") + // texture based on nbt data, but I won't be covering that. + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean isAdvanced){ + if ( stack.hasTagCompound() + && stack.getTagCompound().hasKey("brainType")) + { + // StatCollector is a class which allows us to handle string + // language translation. This requires that you fill out the + // translation in you language class. + tooltip.add(StatCollector.translateToLocal("tooltip.yourmod." + + stack.getTagCompound().getString("brainType") + ".desc")); + } + else // If the brain does not have valid tag data, a default message + { + tooltip.add(StatCollector.translateToLocal( + "tooltip.yourmod.nullbrain.desc")); + } + } +} + diff --git a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java index a15616711d..b721672aa4 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java @@ -4,6 +4,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.interfaces.IItemBlueprint; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; import java.util.List; @@ -21,49 +22,59 @@ import cpw.mods.fml.common.registry.GameRegistry; public class ItemBlueprint extends Item implements IItemBlueprint{ - protected String mName = ""; - protected boolean mHasBlueprint = false; - private final int bpID; - - /** - * The inventory of items the blueprint holds~ - */ - protected ItemStack[] blueprint = new ItemStack[9]; - public ItemBlueprint(String unlocalizedName) { this.setUnlocalizedName(unlocalizedName); this.setTextureName(CORE.MODID + ":" + unlocalizedName); this.setMaxStackSize(1); this.setCreativeTab(AddToCreativeTab.tabMachines); - this.bpID = MathUtils.randInt(0, 1000); + //this.bpID = MathUtils.randInt(0, 1000); GameRegistry.registerItem(this, unlocalizedName); } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (bpID >= 0){ - list.add(EnumChatFormatting.GRAY+"Technical Document No. "+bpID); + public void addInformation(ItemStack itemStack, EntityPlayer aPlayer, List list, boolean bool) { + //Create some NBT if it's not there, otherwise this does nothing. + if (!itemStack.hasTagCompound()){ + createNBT(itemStack); } - if(mHasBlueprint){ - list.add(EnumChatFormatting.BLUE+"Currently holding a blueprint for "+mName); + //Set up some default variables. + int id = -1; + String name = ""; + boolean blueprint = false; + //Get proper display vars from NBT if it's there + if (itemStack.hasTagCompound()){ + //Utils.LOG_INFO("Found TagCompound"); + id = (int) getNBT(itemStack, "mID"); + name = (String) getNBT(itemStack, "mName"); + blueprint = (boolean) getNBT(itemStack, "mBlueprint"); } + //Write to tooltip list for each viable setting. + if (itemStack.hasTagCompound()) { + if (id != -1){ + list.add(EnumChatFormatting.GRAY+"Technical Document No. "+id); + } + if(blueprint){ + list.add(EnumChatFormatting.BLUE+"Currently holding a blueprint for "+name); + } + else { + list.add(EnumChatFormatting.RED+"Currently not holding a blueprint for anything."); + } + } else { list.add(EnumChatFormatting.RED+"Currently not holding a blueprint for anything."); } - super.addInformation(stack, aPlayer, list, bool); + super.addInformation(itemStack, aPlayer, list, bool); } - + @Override public String getItemStackDisplayName(ItemStack p_77653_1_) { - return "Blueprint"; + return "Blueprint"; } @Override - public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { - itemStack.stackTagCompound = new NBTTagCompound(); - //this.inventory = null; - //itemStack.stackTagCompound.set("pos_x", bed_X); TODO + public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { + createNBT(itemStack); } @Override @@ -74,38 +85,59 @@ public class ItemBlueprint extends Item implements IItemBlueprint{ @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) { //Let the player know what blueprint is held - Utils.messagePlayer(par3Entity, "This is a placeholder."); + if (itemStack.hasTagCompound()) { + Utils.messagePlayer(par3Entity, "This Blueprint holds NBT data. "+"|"+getNBT(itemStack, "mID")+"|"+getNBT(itemStack, "mBlueprint")+"|"+getNBT(itemStack, "mName")+"|"+UtilsItems.getArrayStackNames(readItemsFromNBT(itemStack))); + } + else { + createNBT(itemStack); + Utils.messagePlayer(par3Entity, "This is a placeholder. "+getNBT(itemStack, "mID")); + } + + return super.onItemRightClick(itemStack, world, par3Entity); } - public void readFromNBT(NBTTagCompound nbt){ - NBTTagList list = nbt.getTagList("Items", 10); - blueprint = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0 && slot < INV_SIZE) + public ItemStack[] readItemsFromNBT(ItemStack itemStack){ + ItemStack[] blueprint = new ItemStack[9]; + if (itemStack.hasTagCompound()){ + NBTTagCompound nbt = itemStack.getTagCompound(); + NBTTagList list = nbt.getTagList("Items", 10); + blueprint = new ItemStack[INV_SIZE]; + for(int i = 0;i= 0 && slot < INV_SIZE) + { + blueprint[slot] = ItemStack.loadItemStackFromNBT(data); + } } + return blueprint; } + return null; } - public void writeToNBT(NBTTagCompound nbt){ - NBTTagList list = new NBTTagList(); - for(int i = 0;i sTesseractGenerators = new HashMap(); //GUIS public enum GUI_ENUM diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java new file mode 100644 index 0000000000..9a396334d4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -0,0 +1,49 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.ItemList; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class RECIPES_General { + + static ItemStack RECIPE_Paper = UtilsItems.getSimpleStack(Items.paper); + static ItemStack RECIPE_LapisDust = UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustLazurite", 2); + static ItemStack OUTPUT_Blueprint = UtilsItems.getSimpleStack(ModItems.itemBlueprintBase); + static ItemStack RECIPE_CraftingTable = UtilsItems.getSimpleStack(Item.getItemFromBlock(Blocks.crafting_table)); + static ItemStack RECIPE_BronzePlate = UtilsItems.getItemStackOfAmountFromOreDictNoBroken("plateBronze", 1); + static ItemStack RECIPE_BasicCasingIC2; + static ItemStack OUTPUT_Workbench_Bronze = UtilsItems.getSimpleStack(Item.getItemFromBlock(ModBlocks.blockWorkbench)); + static ItemStack NULL = null; + + public static void RECIPES_LOAD(){ + + if (LoadedMods.Gregtech){ + RECIPE_BasicCasingIC2 = ItemList.Casing_Gearbox_Bronze.get(1); + run(); + } + } + + private static void run(){ + + + UtilsRecipe.recipeBuilder( + RECIPE_Paper, RECIPE_LapisDust, NULL, + RECIPE_Paper, RECIPE_LapisDust, NULL, + RECIPE_LapisDust, RECIPE_LapisDust, NULL, + OUTPUT_Blueprint); + + UtilsRecipe.recipeBuilder( + RECIPE_BronzePlate, RECIPE_CraftingTable, RECIPE_BronzePlate, + RECIPE_BronzePlate, RECIPE_BasicCasingIC2, RECIPE_BronzePlate, + RECIPE_BronzePlate, RECIPE_BronzePlate, RECIPE_BronzePlate, + OUTPUT_Workbench_Bronze); + } + +} diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java index ec4e457489..64f06a078c 100644 --- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java +++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java @@ -467,8 +467,15 @@ public class UtilsItems { public static String getArrayStackNames(ItemStack[] aStack){ String itemNames = "Item Array: "; for (ItemStack alph : aStack){ - String temp = itemNames; - itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; + + if (alph != null){ + String temp = itemNames; + itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; + } + else { + String temp = itemNames; + itemNames = temp + ", " + "null" + " x" + "0"; + } } return itemNames; diff --git a/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java b/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java index 997aaa95c9..727e40f570 100644 --- a/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java +++ b/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java @@ -101,7 +101,7 @@ public class UtilsRecipe { try { GameRegistry.addRecipe(new ShapedOreRecipe(resultItem.copy(), (Object[]) validSlots.toArray())); - Utils.LOG_INFO("Success! Added a recipe for "+resultItem.toString()); + Utils.LOG_INFO("Success! Added a recipe for "+resultItem.getDisplayName()); if (!COMPAT_HANDLER.areInitItemsLoaded){ RegistrationHandler.recipesSuccess++; } @@ -173,7 +173,7 @@ public class UtilsRecipe { //GameRegistry.addRecipe(new ShapelessOreRecipe(Output, outputAmount), (Object[]) validSlots.toArray()); GameRegistry.addRecipe(new ShapelessOreRecipe(Output, (Object[]) validSlots.toArray())); //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); - Utils.LOG_INFO("Success! Added a recipe for "+Output.toString()); + Utils.LOG_INFO("Success! Added a recipe for "+Output.getDisplayName()); RegistrationHandler.recipesSuccess++; } catch(RuntimeException k){ @@ -333,7 +333,7 @@ public class UtilsRecipe { return; } - GT_ModHandler.addCraftingRecipe(OutputItem, + if (GT_ModHandler.addCraftingRecipe(OutputItem, GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"ABC", "DEF", "GHI", @@ -345,7 +345,10 @@ public class UtilsRecipe { 'F', InputItem6, 'G', InputItem7, 'H', InputItem8, - 'I', InputItem9}); + 'I', InputItem9})){ + Utils.LOG_INFO("Success! Added a recipe for "+OutputItem.getDisplayName()); + RegistrationHandler.recipesSuccess++; + } } public static void addShapelessGregtechRecipe(ItemStack OutputItem, Object... inputItems){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 346b239932..6576e1c0d9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -128,7 +128,10 @@ public enum GregtechItemList implements GregtechItemContainer { GT4_Workbench_Bronze, GT4_Workbench_Advanced, //Geothermal Engines - Geothermal_Engine_EV, Geothermal_Engine_IV, Geothermal_Engine_LuV; + Geothermal_Engine_EV, Geothermal_Engine_IV, Geothermal_Engine_LuV, + + //Tesseracts + GT4_Tesseract_Generator, GT4_Tesseract_Terminal; public static final GregtechItemList[] DYE_ONLY_ITEMS = { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java index c5bfc4ac7b..47c8aedb98 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java @@ -1,19 +1,19 @@ package gtPlusPlus.xmod.gregtech.api.gui; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.slots.SlotGtTool; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.gui.dev.GT_ContainerMetaTile_MachineEx; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_MachineEx { +public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { public CONTAINER_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java index c52d50d674..7da9238bd5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java @@ -1,12 +1,12 @@ package gtPlusPlus.xmod.gregtech.api.gui; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.dev.GT_GUIContainerMetaTile_MachineEx; import net.minecraft.entity.player.InventoryPlayer; public class GUI_AdvancedWorkbench -extends GT_GUIContainerMetaTile_MachineEx +extends GT_GUIContainerMetaTile_Machine { public GUI_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java index 19210eea8a..a638baf5a2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java @@ -1,15 +1,15 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; import gregtech.api.enums.Textures; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; public class CasingTextureHandler { - private static final TexturesGregtech59 gregtech59 = new TexturesGregtech59(); - private static final TexturesGregtech58 gregtech58 = new TexturesGregtech58(); + //private static final TexturesGregtech59 gregtech59 = new TexturesGregtech59(); + //private static final TexturesGregtech58 gregtech58 = new TexturesGregtech58(); + private static final TexturesCentrifugeMultiblock gregtechX = new TexturesCentrifugeMultiblock(); public static IIcon getIcon(int aSide, int aMeta) { //Texture ID's. case 0 == ID[57] if ((aMeta >= 0) && (aMeta < 16)) { @@ -67,9 +67,10 @@ public class CasingTextureHandler { public static IIcon handleCasingsGT(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide, GregtechMetaCasingBlocks thisBlock) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + /*if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ return gregtech59.handleCasingsGT59(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); } - return gregtech58.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + return gregtech58.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock);*/ + return gregtechX.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java new file mode 100644 index 0000000000..bc7827916e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java @@ -0,0 +1,441 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialCentrifuge; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class TexturesCentrifugeMultiblock { + + private static CustomIcon GT8_1_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE1"); + private static CustomIcon GT8_1 = new CustomIcon("iconsets/LARGECENTRIFUGE1"); + private static CustomIcon GT8_2_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE2"); + private static CustomIcon GT8_2 = new CustomIcon("iconsets/LARGECENTRIFUGE2"); + private static CustomIcon GT8_3_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE3"); + private static CustomIcon GT8_3 = new CustomIcon("iconsets/LARGECENTRIFUGE3"); + private static CustomIcon GT8_4_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE4"); + private static CustomIcon GT8_4 = new CustomIcon("iconsets/LARGECENTRIFUGE4"); + private static CustomIcon GT8_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static CustomIcon GT8_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + private static CustomIcon GT8_6_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE6"); + private static CustomIcon GT8_6 = new CustomIcon("iconsets/LARGECENTRIFUGE6"); + private static CustomIcon GT8_7_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE7"); + private static CustomIcon GT8_7 = new CustomIcon("iconsets/LARGECENTRIFUGE7"); + private static CustomIcon GT8_8_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE8"); + private static CustomIcon GT8_8 = new CustomIcon("iconsets/LARGECENTRIFUGE8"); + private static CustomIcon GT8_9_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE9"); + private static CustomIcon GT8_9 = new CustomIcon("iconsets/LARGECENTRIFUGE9"); + + private static CustomIcon frontFace_0 = (GT8_1); + private static CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static CustomIcon frontFace_1 = (GT8_2); + private static CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static CustomIcon frontFace_2 = (GT8_3); + private static CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static CustomIcon frontFace_3 = (GT8_4); + private static CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static CustomIcon frontFace_4 = (GT8_5); + private static CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static CustomIcon frontFace_5 = (GT8_6); + private static CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static CustomIcon frontFace_6 = (GT8_7); + private static CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static CustomIcon frontFace_7 = (GT8_8); + private static CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static CustomIcon frontFace_8 = (GT8_9); + private static CustomIcon frontFaceActive_8 = (GT8_9_Active); + + CustomIcon[] CENTRIFUGE = new CustomIcon[]{ + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; + + CustomIcon[] CENTRIFUGE_ACTIVE = new CustomIcon[]{ + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; + + public IIcon handleCasingsGT(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide, GregtechMetaCasingBlocks thisBlock) { + return handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } + + + public IIcon handleCasingsGT58(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide, GregtechMetaCasingBlocks thisBlock) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (((tMeta != 6) && (tMeta != 8) && (tMeta != 0))) { + return CasingTextureHandler.getIcon(aSide, tMeta); + } + int tStartIndex = tMeta == 6 ? 1 : 13; + if (tMeta == 0) { + if ((aSide == 2) || (aSide == 3)) { + TileEntity tTileEntity; + IMetaTileEntity tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[0].getIcon(); + } + return CENTRIFUGE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[3].getIcon(); + } + return CENTRIFUGE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[6].getIcon(); + } + return CENTRIFUGE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[1].getIcon(); + } + return CENTRIFUGE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[7].getIcon(); + } + return CENTRIFUGE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[8].getIcon(); + } + return CENTRIFUGE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[5].getIcon(); + } + return CENTRIFUGE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[2].getIcon(); + } + return CENTRIFUGE[2].getIcon(); + } + } else if ((aSide == 4) || (aSide == 5)) { + TileEntity tTileEntity; + Object tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[0].getIcon(); + } + return CENTRIFUGE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[3].getIcon(); + } + return CENTRIFUGE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[6].getIcon(); + } + return CENTRIFUGE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[1].getIcon(); + } + return CENTRIFUGE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[7].getIcon(); + } + return CENTRIFUGE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[8].getIcon(); + } + return CENTRIFUGE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[5].getIcon(); + } + return CENTRIFUGE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return CENTRIFUGE_ACTIVE[2].getIcon(); + } + return CENTRIFUGE[2].getIcon(); + } + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + boolean[] tConnectedSides = {(aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta)}; + switch (aSide) { + case 0: + if (tConnectedSides[0]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 1: + if (tConnectedSides[1]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 2: + if (tConnectedSides[5]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 3: + if (tConnectedSides[3]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 4: + if (tConnectedSides[4]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + case 5: + if (tConnectedSides[2]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + break; + } + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java new file mode 100644 index 0000000000..5044f958c8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java @@ -0,0 +1,75 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +public class TexturesGtBlocks { + + /* + * Handles Custom Textures. + */ + + public static class CustomIcon implements IIconContainer, Runnable { + protected IIcon mIcon; + protected String mIconName; + + public CustomIcon(String aIconName) { + mIconName = aIconName; + Utils.LOG_INFO("Constructing a Custom Texture. " + mIconName); + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + mIcon = GregTech_API.sBlockIcons.registerIcon(CORE.MODID + ":" + mIconName); + Utils.LOG_INFO("FIND ME _ Processing texture: "+this.getTextureFile().getResourcePath()); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + } + + + /* + * Add Some Custom Textures below. + * I am not sure whether or not I need to declare them as such, but better to be safe than sorry. + * Right? + */ + + + + //Machine Casings + private static final CustomIcon Internal_Casing_Machine_Dimensional = new CustomIcon("TileEntities/adv_machine_dimensional"); + public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; + private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = new CustomIcon("TileEntities/high_adv_machine_dimensional"); + public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; + + //Computer Screens + private static final CustomIcon Internal_Casing_Machine_Screen_1 = new CustomIcon("TileEntities/adv_machine_screen_random1"); + public static final CustomIcon Casing_Machine_Screen_1 = Internal_Casing_Machine_Screen_1; + private static final CustomIcon Internal_Casing_Machine_Screen_2 = new CustomIcon("TileEntities/adv_machine_screen_random2"); + public static final CustomIcon Casing_Machine_Screen_2 = Internal_Casing_Machine_Screen_2; + private static final CustomIcon Internal_Casing_Machine_Screen_3 = new CustomIcon("TileEntities/adv_machine_screen_random3"); + public static final CustomIcon Casing_Machine_Screen_3 = Internal_Casing_Machine_Screen_3; + private static final CustomIcon Internal_Casing_Machine_Screen_Frequency = new CustomIcon("TileEntities/adv_machine_screen_frequency"); + public static final CustomIcon Casing_Machine_Screen_Frequency = Internal_Casing_Machine_Screen_Frequency; + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java new file mode 100644 index 0000000000..dde2c6927c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java @@ -0,0 +1,602 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import static gtPlusPlus.core.lib.CORE.sTesseractGenerators; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IDigitalChest; +import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class GT_MetaTileEntity_TesseractGenerator +extends GT_MetaTileEntity_BasicTank +{ + public static int TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; + public static int TESSERACT_ENERGY_COST = 1024; + public byte isWorking = 0; + public int oFrequency = 0; + public int mNeededEnergy = 0; + public int mFrequency = 0; + + public GT_MetaTileEntity_TesseractGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, ""); + } + + public GT_MetaTileEntity_TesseractGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractGenerator(mName, mTier, mDescription, mTextures); + } + + @Override + public boolean isTransformerUpgradable() + { + return true; + } + + @Override + public boolean isOverclockerUpgradable() + { + return false; + } + + @Override + public boolean isSimpleMachine() + { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) + { + return true; + } + + @Override + public boolean isEnetInput() + { + return true; + } + + @Override + public boolean isEnetOutput() + { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) + { + return true; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) + { + return false; + } + + @Override + public long getMinimumStoredEU() + { + return getBaseMetaTileEntity().getEUCapacity() / 2; + } + + @Override + public long maxEUInput() + { + return 2048; + } + + @Override + public long maxEUOutput() + { + return 0; + } + + @Override + public long maxEUStore() + { + return 100000; + } + + @Override + public long maxSteamStore() + { + return maxEUStore(); + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) + { + return true; + } + + @Override + public boolean ownerControl() + { + return true; + } + + @Override + public int getProgresstime() + { + return (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) && (this.isWorking >= 20) ? 999 : 0; + } + + @Override + public int maxProgresstime() + { + return 1000; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) + { + aNBT.setInteger("mFrequency", this.mFrequency); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) + { + this.mFrequency = aNBT.getInteger("mFrequency"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) + { + TESSERACT_ENERGY_COST = 1024; + TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; + } + + @Override + public void onServerStart() + { + sTesseractGenerators.clear(); + } + + public void onServerStop() + { + sTesseractGenerators.clear(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ){ + if (aSide == getBaseMetaTileEntity().getFrontFacing()){ + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))){ + case 0: + Utils.LOG_INFO("Freq. -1 | " + this.mFrequency); + this.mFrequency -= 1; + break; + case 1: + Utils.LOG_INFO("Freq. +1 | " + this.mFrequency); + this.mFrequency += 1; + default: + //Utils.LOG_INFO("Did not click the correct place."); + break; + } + Utils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + Utils.messagePlayer(aPlayer, ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null) && (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this) ? EnumChatFormatting.RED + " (Occupied)" : "")); + } + return true; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) + { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) + { + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))) + { + case 0: + this.mFrequency -= 64; + break; + case 1: + this.mFrequency += 64; + break; + case 2: + this.mFrequency -= 512; + break; + case 3: + this.mFrequency += 512; + } + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null) && (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this) ? EnumChatFormatting.RED + " (Occupied)" : "")); + } + } + + public boolean allowCoverOnSide(byte aSide, int aCoverID) + { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public String[] getInfoData() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IGregTechDeviceInformation)) && (((IGregTechDeviceInformation)tTileEntity).isGivingInformation())) { + return ((IGregTechDeviceInformation)tTileEntity).getInfoData(); + } + return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) && (this.isWorking >= 20) ? "Active" : "Inactive" }; + } + + @Override + public boolean isGivingInformation() + { + return true; + } + + public boolean isSendingInformation() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IGregTechDeviceInformation))) { + return ((IGregTechDeviceInformation)tTileEntity).isGivingInformation(); + } + return false; + } + + @Override + public boolean isDigitalChest() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest)tTileEntity).isDigitalChest(); + } + return false; + } + + @Override + public ItemStack[] getStoredItemData() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest)tTileEntity).getStoredItemData(); + } + return null; + } + + @Override + public void setItemCount(int aCount) + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + ((IDigitalChest)tTileEntity).setItemCount(aCount); + } + } + + @Override + public int getMaxItemCount() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest)tTileEntity).getMaxItemCount(); + } + return 0; + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); + } + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return new int[0]; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory)tTileEntity).getAccessibleSlotsFromSide(aSide); + } + int[] rArray = new int[getSizeInventory()]; + for (int i = 0; i < getSizeInventory(); i++) { + rArray[i] = i; + } + return rArray; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory)tTileEntity).canInsertItem(aIndex, aStack, aSide); + } + return true; + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory)tTileEntity).canExtractItem(aIndex, aStack, aSide); + } + return true; + } + + @Override + public int getSizeInventory() + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int aIndex) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); + } + + @Override + public void setInventorySlotContents(int aIndex, ItemStack aStack) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); + } + + @Override + public ItemStack decrStackSize(int aIndex, int aAmount) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); + } + + @Override + public String getInventoryName() + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); + } + + @Override + public int getInventoryStackLimit() + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); + } + + @Override + public int fill_default(ForgeDirection aDirection, FluidStack aFluid, boolean doFill) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); + } + + @Override + public FluidStack drain(ForgeDirection aDirection, int maxDrain, boolean doDrain) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); + } + + public boolean addEnergyConsumption(GT_MetaTileEntity_TesseractTerminal aTerminal) + { + if (!getBaseMetaTileEntity().isAllowedToWork()) { + return false; + } + this.mNeededEnergy += (aTerminal.getBaseMetaTileEntity().getWorld() == getBaseMetaTileEntity().getWorld() ? TESSERACT_ENERGY_COST : TESSERACT_ENERGY_COST_DIMENSIONAL); + return true; + } + + public boolean isValidTesseractGenerator(String aOwnerName, boolean aWorkIrrelevant) + { + return (getBaseMetaTileEntity() != null) && (!getBaseMetaTileEntity().isInvalidTileEntity()) && (getBaseMetaTileEntity().isAllowedToWork()) && ((aOwnerName == null) || (getBaseMetaTileEntity().getOwnerName().equals(aOwnerName))) && ((aWorkIrrelevant) || (this.isWorking >= 20)); + } + + public void onPostTick() + { + if (getBaseMetaTileEntity().isServerSide()){ + if (this.mFrequency != this.oFrequency){ + + Utils.LOG_INFO("mFreq != oFreq"); + + if (sTesseractGenerators.get(Integer.valueOf(this.oFrequency)) == this) + { + sTesseractGenerators.remove(Integer.valueOf(this.oFrequency)); + getBaseMetaTileEntity().issueBlockUpdate(); + Utils.LOG_INFO("this Gen == oFreq on map - do block update"); + } + Utils.LOG_INFO("mFreq will be set to oFreq"); + this.oFrequency = this.mFrequency; + } + if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mNeededEnergy, false))) + { + Utils.LOG_INFO("Can Work & Has Energy"); + if ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == null) || (!((GT_MetaTileEntity_TesseractGenerator)sTesseractGenerators.get(Integer.valueOf(this.mFrequency))).isValidTesseractGenerator(null, true))) { + Utils.LOG_INFO("storing TE I think to mFreq map?"); + sTesseractGenerators.put(Integer.valueOf(this.mFrequency), this); + } + } + else + { + if (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) + { + Utils.LOG_INFO("this gen == mFreq on map - do block update"); + sTesseractGenerators.remove(Integer.valueOf(this.mFrequency)); + getBaseMetaTileEntity().issueBlockUpdate(); + } + this.isWorking = 0; + } + if (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) + { + Utils.LOG_INFO("mFreq == this - do work related things"); + if (this.isWorking < 20) { + this.isWorking = ((byte)(this.isWorking + 1)); + } + if (this.isWorking == 20) + { + getBaseMetaTileEntity().issueBlockUpdate(); + this.isWorking = ((byte)(this.isWorking + 1)); + } + } + else + { + this.isWorking = 0; + } + this.mNeededEnergy = 0; + } + } + + @Override + public String[] getDescription() + { + return new String[] {"Generates a Tesseract for the attached Inventory"}; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == aFacing ? new ITexture[]{ new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Dimensional), new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Screen_Frequency)} : new ITexture[]{new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Dimensional), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; + } + + + //To-Do? + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java new file mode 100644 index 0000000000..8c22b49260 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java @@ -0,0 +1,504 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + +public class GT_MetaTileEntity_TesseractTerminal +extends GT_MetaTileEntity_BasicTank +{ + public int mFrequency = 0; + public boolean mDidWork = false; + public static boolean sInterDimensionalTesseractAllowed = true; + + public GT_MetaTileEntity_TesseractTerminal(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, ""); + } + + public GT_MetaTileEntity_TesseractTerminal(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractTerminal(mName, mTier, mDescription, mTextures); + } + + @Override + public boolean isTransformerUpgradable() + { + return false; + } + + @Override + public boolean isOverclockerUpgradable() + { + return false; + } + + @Override + public boolean isSimpleMachine() + { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) + { + return true; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) + { + return false; + } + + @Override + public long getMinimumStoredEU() + { + return getBaseMetaTileEntity().getEUCapacity() / 2; + } + + @Override + public long maxEUInput() + { + return 2048; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) + { + return true; + } + + @Override + public long maxEUStore() + { + return 100000; + } + + @Override + public long maxSteamStore() + { + return maxEUStore(); + } + + @Override + public boolean ownerControl() + { + return true; + } + + @Override + public int getProgresstime() + { + return getTesseract(this.mFrequency, false) != null ? 999 : 0; + } + + @Override + public int maxProgresstime() + { + return 1000; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) + { + aNBT.setInteger("mFrequency", this.mFrequency); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) + { + this.mFrequency = aNBT.getInteger("mFrequency"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) + { + sInterDimensionalTesseractAllowed = true; + } + + public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) + { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) + { + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))) + { + case 0: + this.mFrequency -= 1; + break; + case 1: + this.mFrequency += 1; + } + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); + } + return true; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) + { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) + { + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))) + { + case 0: + this.mFrequency -= 64; + break; + case 1: + this.mFrequency += 64; + break; + case 2: + this.mFrequency -= 512; + break; + case 3: + this.mFrequency += 512; + } + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); + } + } + + public boolean allowCoverOnSide(byte aSide, int aCoverID) + { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + public GT_MetaTileEntity_TesseractGenerator getTesseract(int aFrequency, boolean aWorkIrrelevant) + { + GT_MetaTileEntity_TesseractGenerator rTesseract = (GT_MetaTileEntity_TesseractGenerator)CORE.sTesseractGenerators.get(Integer.valueOf(aFrequency)); + if (rTesseract == null) { + return null; + } + if (rTesseract.mFrequency != aFrequency) + { + CORE.sTesseractGenerators.put(Integer.valueOf(aFrequency), null);return null; + } + if (!rTesseract.isValidTesseractGenerator(getBaseMetaTileEntity().getOwnerName(), aWorkIrrelevant)) { + return null; + } + if ((!sInterDimensionalTesseractAllowed) && (rTesseract.getBaseMetaTileEntity().getWorld() != getBaseMetaTileEntity().getWorld())) { + return null; + } + return rTesseract; + } + + @Override + public String[] getInfoData() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && (tTileEntity.isSendingInformation())) { + return tTileEntity.getInfoData(); + } + return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" }; + } + + @Override + public boolean isGivingInformation() + { + return true; + } + + @Override + public boolean isDigitalChest() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isDigitalChest(); + } + + @Override + public ItemStack[] getStoredItemData() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStoredItemData(); + } + + @Override + public void setItemCount(int aCount) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setItemCount(aCount); + } + + @Override + public int getMaxItemCount() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getMaxItemCount(); + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); + } + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return new int[0]; + } + return tTileEntity.getAccessibleSlotsFromSide(aSide); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canInsertItem(aIndex, aStack, aSide); + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canExtractItem(aIndex, aStack, aSide); + } + + @Override + public int getSizeInventory() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int aIndex) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); + } + + @Override + public void setInventorySlotContents(int aIndex, ItemStack aStack) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); + } + + @Override + public ItemStack decrStackSize(int aIndex, int aAmount) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); + } + + @Override + public String getInventoryName() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); + } + + @Override + public int getInventoryStackLimit() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); + } + + @Override + public int fill_default(ForgeDirection aDirection, FluidStack aFluid, boolean doFill) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); + } + + @Override + public FluidStack drain(ForgeDirection aDirection, int maxDrain, boolean doDrain) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); + } + + public void onPostTick() + { + if ((getBaseMetaTileEntity().isServerSide()) && (getBaseMetaTileEntity().isAllowedToWork())) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, true); + if (tTileEntity != null) + { + tTileEntity.addEnergyConsumption(this); + if ((!this.mDidWork) && (getTesseract(this.mFrequency, false) != null)) + { + this.mDidWork = true; + getBaseMetaTileEntity().issueBlockUpdate(); + } + } + else if (this.mDidWork == true) + { + this.mDidWork = false; + getBaseMetaTileEntity().issueBlockUpdate(); + } + } + } + + @Override + public String[] getDescription() + { + return new String[] {"Accesses Tesseracts remotely"}; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == aFacing ? new ITexture[]{new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Dimensional), new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Screen_Frequency)} : new ITexture[]{new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Dimensional), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; + } + + //To-Do? + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java index 13ae8e424f..c76afc23be 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java @@ -16,6 +16,7 @@ import gtPlusPlus.core.lib.CORE.configSwitches; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks.CustomIcon; import java.util.ArrayList; import java.util.List; @@ -36,22 +37,14 @@ extends GregtechMeta_MultiBlockBase { private static boolean isDisabled = false; private static ITexture frontFace; private static ITexture frontFaceActive; - private static Textures.BlockIcons.CustomIcon GT9_5_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE5"); - private static Textures.BlockIcons.CustomIcon GT9_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST5"); - private static Textures.BlockIcons.CustomIcon GT8_5_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE5"); - private static Textures.BlockIcons.CustomIcon GT8_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE5"); + private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static CustomIcon GT9_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); //public static double recipesComplete = 0; public GregtechMetaTileEntityIndustrialCentrifuge(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ frontFaceActive = new GT_RenderedTexture(GT9_5_Active); frontFace = new GT_RenderedTexture(GT9_5); - } - else{ - frontFaceActive = new GT_RenderedTexture(GT8_5_Active); - frontFace = new GT_RenderedTexture(GT8_5); - } } public GregtechMetaTileEntityIndustrialCentrifuge(String aName) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java new file mode 100644 index 0000000000..3d8f8ce61c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java @@ -0,0 +1,37 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; + +public class Gregtech4Content +{ + + //ID Range 828, 829, 833 - 850 + + public static void run() + { + if (LoadedMods.Gregtech){ + workbenches(); + tesseracts(); + } + } + + private static void workbenches(){ + //Gregtech 4 Workbenches + Utils.LOG_INFO("Gregtech 4 Content | Registering Workbenches."); + GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(828, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); + GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(829, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); + } + + private static void tesseracts(){ + //Gregtech 4 Workbenches + Utils.LOG_INFO("Gregtech 4 Content | Registering Tesseracts."); + GregtechItemList.GT4_Tesseract_Generator.set(new GT_MetaTileEntity_TesseractGenerator(833, "tesseract.generator", "Tesseract Generator", 4).getStackForm(1L)); + GregtechItemList.GT4_Tesseract_Terminal.set(new GT_MetaTileEntity_TesseractTerminal(834, "tesseract.terminal", "Tesseract Terminal", 4).getStackForm(1L)); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWorkbenches.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWorkbenches.java deleted file mode 100644 index 4486bc5cd5..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWorkbenches.java +++ /dev/null @@ -1,29 +0,0 @@ -package gtPlusPlus.xmod.gregtech.registration.gregtech; - -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; - -public class GregtechWorkbenches -{ - public static void run() - { - if (LoadedMods.Gregtech){ - Utils.LOG_INFO("Gregtech5u Content | Registering Workbenches."); - run1(); - //run2(); - } - - } - - private static void run1() - { - //Gregtech 4 Workbenches - GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(828, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); - GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(829, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); - - - } -} diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_dimensional.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_dimensional.png new file mode 100644 index 0000000000..d391da4eaf Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_dimensional.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_dimensional.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_dimensional.png.mcmeta new file mode 100644 index 0000000000..60af678259 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_dimensional.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":4 + } +} \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_frequency.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_frequency.png new file mode 100644 index 0000000000..0db2d5da9b Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_frequency.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random1.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random1.png new file mode 100644 index 0000000000..7157b7541d Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random1.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random1.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random1.png.mcmeta new file mode 100644 index 0000000000..60af678259 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random1.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":4 + } +} \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random2.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random2.png new file mode 100644 index 0000000000..7157b7541d Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random2.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random2.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random2.png.mcmeta new file mode 100644 index 0000000000..97596ba817 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random2.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":2 + } +} \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random3.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random3.png new file mode 100644 index 0000000000..7157b7541d Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random3.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random3.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random3.png.mcmeta new file mode 100644 index 0000000000..dfae8cae16 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_screen_random3.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":1 + } +} \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/high_adv_machine_dimensional.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/high_adv_machine_dimensional.png new file mode 100644 index 0000000000..fe779e8a9e Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/high_adv_machine_dimensional.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/high_adv_machine_dimensional.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/TileEntities/high_adv_machine_dimensional.png.mcmeta new file mode 100644 index 0000000000..60af678259 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/high_adv_machine_dimensional.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":4 + } +} \ No newline at end of file -- cgit From f14718ab64b3262b47cf2a8adfaf6d8f66f9d9b8 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Wed, 19 Oct 2016 23:46:19 +1000 Subject: + Added a dual fluid tank base tile entity. % Changed the Rocket Engines to now require two separate fuels at once. (The secondary fuel will deplete quite slowly, consider using the better fuel here) % Changed interface handling for the Tesseract Terminal. --- .../gregtech/api/gui/CONTAINER_DeluxeTank.java | 77 +++ .../xmod/gregtech/api/gui/GUI_DeluxeTank.java | 35 ++ .../GT_MetaTileEntity_DeluxeTank.java | 327 +++++++++++ .../GregtechRocketFuelGeneratorBase.java | 630 +++++++++++++-------- .../GT_MetaTileEntity_TesseractTerminal.java | 27 +- 5 files changed, 846 insertions(+), 250 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java new file mode 100644 index 0000000000..12094ad620 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java @@ -0,0 +1,77 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_Container_BasicTank; +import gregtech.api.gui.GT_Slot_Output; +import gregtech.api.gui.GT_Slot_Render; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; + +import java.util.Iterator; + +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; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + *

+ * The Container I use for all my Basic Tanks + */ +public class CONTAINER_DeluxeTank extends GT_Container_BasicTank { + + public int mContent = 0; + + public CONTAINER_DeluxeTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 80, 17)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 80, 53)); + addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 41, 42)); + addSlotToContainer(new GT_Slot_Render(mTileEntity, 3, 59, 42)); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + if (((GT_MetaTileEntity_DeluxeTank) mTileEntity.getMetaTileEntity()).mFluid != null) + mContent = ((GT_MetaTileEntity_DeluxeTank) mTileEntity.getMetaTileEntity()).mFluid.amount; + else + mContent = 0; + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, mContent & 65535); + var1.sendProgressBarUpdate(this, 101, mContent >>> 16); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + mContent = mContent & -65536 | par2; + break; + case 101: + mContent = mContent & 65535 | par2 << 16; + break; + } + } + + @Override + public int getSlotCount() { + return 2; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java new file mode 100644 index 0000000000..758aa55294 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java @@ -0,0 +1,35 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; + +public class GUI_DeluxeTank extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GUI_DeluxeTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_DeluxeTank(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "BasicTank.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752); + fontRendererObj.drawString(mName, 8, 6, 4210752); + if (mContainer != null) { + fontRendererObj.drawString("Fuel | A | B |", 10, 20, 16448255); + //fontRendererObj.drawString(GT_Utility.parseNumberToString(((CONTAINER_DeluxeTank) mContainer).mContent), 10, 30, 16448255); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java new file mode 100644 index 0000000000..2effc58f9a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java @@ -0,0 +1,327 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.ItemList; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_DeluxeTank; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_DeluxeTank; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + *

+ * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually + */ +public abstract class GT_MetaTileEntity_DeluxeTank extends GT_MetaTileEntity_BasicTank { + + public FluidStack mFluid; + public FluidStack mFluid2; + + /** + * @param aInvSlotCount should be 3 + */ + public GT_MetaTileEntity_DeluxeTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_DeluxeTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex != getStackDisplaySlot(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + if (mFluid2 != null) aNBT.setTag("mFluid2", mFluid2.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); + } + + @Override + public abstract boolean doesFillContainers(); + + @Override + public abstract boolean doesEmptyContainers(); + + @Override + public abstract boolean canTankBeFilled(); + + @Override + public abstract boolean canTankBeEmptied(); + + @Override + public abstract boolean displaysItemStack(); + + @Override + public abstract boolean displaysStackSize(); + + @Override + public int getInputSlot() { + return 0; + } + + @Override + public int getOutputSlot() { + return 1; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + public int getStackDisplaySlot2() { + return 3; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return true; + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public FluidStack getFillableStack() { + return getFillableStackEx(1); + } + + public FluidStack getFillableStackEx(int stackID) { + if (stackID <= 1){ + return mFluid; + } + return mFluid2; + } + + @Override + public FluidStack setFillableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; + } + + public FluidStack setFillableStack2(FluidStack aFluid) { + mFluid2 = aFluid; + return mFluid2; + } + + @Override + public FluidStack getDrainableStack() { + return getDrainableStackEx(1); + } + + public FluidStack getDrainableStackEx(int stackID) { + if (stackID <= 1){ + return mFluid; + } + return mFluid2; + } + + @Override + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; + } + + @Override + public FluidStack getDisplayedFluid() { + return getDrainableStack(); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) + setFillableStack(null); + + if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { + if (getDisplayedFluid() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) + mInventory[getStackDisplaySlot()] = null; + } else { + mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); + } + } + + if (displaysItemStack() && getStackDisplaySlot2() >= 0 && getStackDisplaySlot2() < mInventory.length) { + if (getDrainableStackEx(2) == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot2()], true, true)) + mInventory[getStackDisplaySlot2()] = null; + } else { + mInventory[getStackDisplaySlot2()] = GT_Utility.getFluidDisplayStack(getDrainableStackEx(2), displaysStackSize()); + } + } + + if (doesEmptyContainers()) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); + if (tFluid != null && isFluidInputAllowed(tFluid)) { + + if (tFluid.isFluidEqual(getDrainableStackEx(1)) || getDrainableStackEx(1) == null){ + if (getFillableStackEx(1) == null) { + if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + setFillableStack(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + getFillableStack().amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + else if (tFluid.isFluidEqual(getDrainableStackEx(2)) || (getDrainableStackEx(2) == null)){ + if (getFillableStackEx(2) == null) { + if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + setFillableStack2(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(getFillableStackEx(2)) && tFluid.amount + getFillableStackEx(2).amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + getFillableStackEx(2).amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + else { + Utils.LOG_INFO("Something broke when trying to empty cells between two fluid tank areas."); + } + } + } + + if (doesFillContainers()) { + ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); + if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + if (tFluid != null) getDrainableStack().amount -= tFluid.amount; + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); + } + } + } + } + + @Override + public FluidStack getFluid() { + return getDrainableStack(); + } + + @Override + public int getFluidAmount() { + return getDrainableStack() != null ? getDrainableStack().amount : 0; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) + return 0; + + if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { + if (aFluid.amount <= getCapacity()) { + if (doFill) { + setFillableStack(aFluid.copy()); + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + setFillableStack(aFluid.copy()); + getFillableStack().amount = getCapacity(); + getBaseMetaTileEntity().markDirty(); + } + return getCapacity(); + } + + if (!getFillableStack().isFluidEqual(aFluid)) + return 0; + + int space = getCapacity() - getFillableStack().amount; + if (aFluid.amount <= space) { + if (doFill) { + getFillableStack().amount += aFluid.amount; + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) + getFillableStack().amount = getCapacity(); + return space; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (getDrainableStack() == null || !canTankBeEmptied()) return null; + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { + setDrainableStack(null); + getBaseMetaTileEntity().markDirty(); + return null; + } + + int used = maxDrain; + if (getDrainableStack().amount < used) + used = getDrainableStack().amount; + + if (doDrain) { + getDrainableStack().amount -= used; + getBaseMetaTileEntity().markDirty(); + } + + FluidStack drained = getDrainableStack().copy(); + drained.amount = used; + + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { + setDrainableStack(null); + getBaseMetaTileEntity().markDirty(); + } + + return drained; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getOutputSlot(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getInputSlot(); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java index ce4042148e..2e10453a05 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -4,11 +4,12 @@ import static gregtech.api.enums.GT_Values.V; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; import java.util.Collection; @@ -17,257 +18,390 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank { - - private boolean useFuel = false; - - public GregtechRocketFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); - } - - public GregtechRocketFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } +public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_DeluxeTank { - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = getFront(i); - rTextures[1][i + 1] = getBack(i); - rTextures[2][i + 1] = getBottom(i); - rTextures[3][i + 1] = getTop(i); - rTextures[4][i + 1] = getSides(i); - rTextures[5][i + 1] = getFrontActive(i); - rTextures[6][i + 1] = getBackActive(i); - rTextures[7][i + 1] = getBottomActive(i); - rTextures[8][i + 1] = getTopActive(i); - rTextures[9][i + 1] = getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - @Override - public String[] getDescription() { - return new String[]{mDescription, "Fuel Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip}; - } - + private boolean useFuel = false; - @Override + public GregtechRocketFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + } + + public GregtechRocketFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = getFront(i); + rTextures[1][i + 1] = getBack(i); + rTextures[2][i + 1] = getBottom(i); + rTextures[3][i + 1] = getTop(i); + rTextures[4][i + 1] = getSides(i); + rTextures[5][i + 1] = getFrontActive(i); + rTextures[6][i + 1] = getBackActive(i); + rTextures[7][i + 1] = getBottomActive(i); + rTextures[8][i + 1] = getTopActive(i); + rTextures[9][i + 1] = getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + @Override + public String[] getDescription() { + return new String[]{mDescription, "Fuel Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip}; + } + + + /* @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; aBaseMetaTileEntity.openGUI(aPlayer); return true; - } - - public ITexture[] getFront(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBack(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottom(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTop(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getSides(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getFrontActive(byte aColor) { - return getFront(aColor); - } - - public ITexture[] getBackActive(byte aColor) { - return getBack(aColor); - } - - public ITexture[] getBottomActive(byte aColor) { - return getBottom(aColor); - } - - public ITexture[] getTopActive(byte aColor) { - return getTop(aColor); - } - - public ITexture[] getSidesActive(byte aColor) { - return getSides(aColor); - } - - @Override - public boolean isFacingValid(byte aSide) { - return aSide > 1; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex < 2; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public long maxEUOutput() { - return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0; - } - - @Override - public long maxEUStore() { - return Math.max(getEUVar(), V[mTier] * 80 + getMinimumStoredEU()); - } - - @Override - public boolean doesFillContainers() { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean doesEmptyContainers() { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean canTankBeFilled() { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean canTankBeEmptied() { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return getFuelValue(aFluid) > 0; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) { - if (mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { - mInventory[getStackDisplaySlot()] = null; - } else { - if (mInventory[getStackDisplaySlot()] == null) - mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); - } - } else { - int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); - if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) { - long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ - if (useFuel){ - mFluid.amount -= tFluidAmountToUse * tConsumed; - useFuel = false; - } - else { - useFuel = true; - } - } - } - } - if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { - int tFuelValue = getFuelValue(mInventory[getInputSlot()]); - if (tFuelValue > 0) { - ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } - } - - if (aBaseMetaTileEntity.isServerSide()) - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); - } - - public abstract GT_Recipe_Map getRecipes(); - - public abstract int getEfficiency(); - - public int consumedFluidPerOperation(FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid == null || getRecipes() == null) return 0; - FluidStack tLiquid; - Collection tRecipeList = getRecipes().mRecipeList; - if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) - if (aLiquid.isFluidEqual(tLiquid)) - return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); - return 0; - } - - public int getFuelValue(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; - GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); - return 0; - } - - public ItemStack getEmptyContainer(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; - GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); - return GT_Utility.getContainerItem(aStack, true); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); - } - - @Override - public int getCapacity() { - return 32000; - } - - @Override - public int getTankPressure() { - return -100; - } + }*/ + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + Utils.LOG_WARNING("Entity is Client side, simply returning true"); + return true; + } + Utils.LOG_WARNING("Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true"); + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBack(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTop(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSides(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(byte aColor) { + return getFront(aColor); + } + + public ITexture[] getBackActive(byte aColor) { + return getBack(aColor); + } + + public ITexture[] getBottomActive(byte aColor) { + return getBottom(aColor); + } + + public ITexture[] getTopActive(byte aColor) { + return getTop(aColor); + } + + public ITexture[] getSidesActive(byte aColor) { + return getSides(aColor); + } + + @Override + public boolean isFacingValid(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0; + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[mTier] * 115 + getMinimumStoredEU()); + } + + @Override + public boolean doesFillContainers() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean doesEmptyContainers() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeFilled() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeEmptied() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFuelValue(aFluid) > 0; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) { + if (mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { + mInventory[getStackDisplaySlot()] = null; + } else { + if (mInventory[getStackDisplaySlot()] == null) + mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + } + } else { + if (mFluid != null && mFluid2 != null){ + int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); + int tFuelValue2 = getFuelValue(mFluid2), tConsumed2 = consumedFluidPerOperation(mFluid2); + if ((tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed)/* && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)*/) { + + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName()); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName()); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); + long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + long tFluidAmountToUse2 = Math.min(mFluid2.amount / tConsumed2, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2); + + if (tFluidAmountToUse <= 0){ + /*if ((mFluid.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse = 1; + }*/ + + if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ + tFluidAmountToUse = 1; + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse - Updated: "+tFluidAmountToUse); + Utils.LOG_WARNING("========================================================="); + } + } + + if (tFluidAmountToUse2 <= 0){ + /*if ((mFluid2.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse2 = 1; + }*/ + if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ + tFluidAmountToUse2 = 1; + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse2 - Updated: "+tFluidAmountToUse2); + Utils.LOG_WARNING("========================================================="); + } + } + + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse: "+tFluidAmountToUse); + Utils.LOG_WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid.amount / tConsumed: "+("fluidAmount:"+mFluid.amount)+(" tConsumed:"+tConsumed)+" | "+(mFluid.amount / tConsumed)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue: "+(tFuelValue)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue)); + */ + + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); + Utils.LOG_WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "+("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"+tConsumed2)+" | "+(mFluid2.amount / tConsumed2)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2)); + */ + if ((tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) && (tFluidAmountToUse2 > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse2 * tFuelValue2, true))){ + + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName()); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName()); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); + + if (useFuel){ + mFluid.amount -= tFluidAmountToUse * tConsumed; + mFluid2.amount -= tFluidAmountToUse2 * tConsumed2; + useFuel = false; + } + else { + useFuel = true; + } + + } + else { + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0"); + Utils.LOG_WARNING("tFluidAmountToUse1: "+tFluidAmountToUse); + Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); + } + } + else { + /*Utils.LOG_WARNING("(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)"); + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); */ + } + } + else { + Utils.LOG_WARNING("One mFluid is null"); + if (mFluid != null) + Utils.LOG_WARNING("mFluid1 is not null"); + if (mFluid2 != null) + Utils.LOG_WARNING("mFluid2 is not null"); + } + } + if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { + int tFuelValue = getFuelValue(mInventory[getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); + } + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null || getRecipes() == null) return 0; + FluidStack tLiquid; + Collection tRecipeList = getRecipes().mRecipeList; + if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) + if (aLiquid.isFluidEqual(tLiquid)) + return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); + return 0; + } + + public int getFuelValue(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); + return 0; + } + + public ItemStack getEmptyContainer(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); + return GT_Utility.getContainerItem(aStack, true); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return -100; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java index 8c22b49260..51eb199e2a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java @@ -9,6 +9,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -140,7 +141,7 @@ extends GT_MetaTileEntity_BasicTank sInterDimensionalTesseractAllowed = true; } - public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) + /*public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { if (aSide == getBaseMetaTileEntity().getFrontFacing()) { @@ -156,8 +157,30 @@ extends GT_MetaTileEntity_BasicTank GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); } return true; - } + }*/ + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ){ + if (aSide == getBaseMetaTileEntity().getFrontFacing()){ + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))){ + case 0: + Utils.LOG_INFO("Freq. -1 | " + this.mFrequency); + this.mFrequency -= 1; + break; + case 1: + Utils.LOG_INFO("Freq. +1 | " + this.mFrequency); + this.mFrequency += 1; + default: + //Utils.LOG_INFO("Did not click the correct place."); + break; + } + Utils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + Utils.messagePlayer(aPlayer, (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); + } + return true; + } + @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { -- cgit From d53b08982a6d2be3cc0be4552520bfc500576f6f Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Thu, 20 Oct 2016 01:45:23 +1000 Subject: + Added a faster vent texture. + Slowed down the other vent texture to half speed. + Added code to allow the usage of the new custom textures. + Added some debug messages for furnace recipes. % Cleaned up the NetworkUtils class and added a nice internet availability check. $ Fixed an issue where Geothermal generators did not implement pollution values for GT 5.09. % Changed the textures on the Rocket Engine Generators, for hopefully the last time. % Cleaned up dual fuel code for Rocket Engine Generators. ^ Bumped the build version to 1.4.9-dev --- .classpath | 2 +- build.gradle | 2 +- .../core/item/base/dusts/BaseItemDust.java | 7 ++- src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- .../gregtech/recipehandlers/GregtechRecipe.java | 2 +- .../core/util/networking/NetworkUtils.java | 63 +++++++++++---------- .../GregtechRocketFuelGeneratorBase.java | 4 +- .../common/blocks/textures/TexturesGtBlocks.java | 30 +++++++++- .../GregtechMetaTileEntityGeothermalGenerator.java | 5 ++ .../GregtechMetaTileEntityRocketFuelGenerator.java | 21 +++---- .../textures/blocks/TileEntities/machine_top.png | Bin 0 -> 822 bytes .../machine_top_vent_rotating.png.mcmeta | 2 +- .../machine_top_vent_rotating_fast.png | Bin 0 -> 3126 bytes .../machine_top_vent_rotating_fast.png.mcmeta | 5 ++ 14 files changed, 96 insertions(+), 49 deletions(-) create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating_fast.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating_fast.png.mcmeta (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/.classpath b/.classpath index cce7f298b8..37602a4409 100644 --- a/.classpath +++ b/.classpath @@ -13,6 +13,6 @@ - + diff --git a/build.gradle b/build.gradle index 456c2145ff..0d3853999a 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ sourceCompatibility = 1.7 targetCompatibility = 1.7 archivesBaseName = "GT-PlusPlus" -version = "1.4.8.6-release" +version = "1.4.9-dev" minecraft.version = "1.7.10-10.13.4.1448-1.7.10" task sourceJar(type: Jar) { diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java index 236edca24d..f16355593b 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -285,7 +285,12 @@ public class BaseItemDust extends Item{ Utils.LOG_WARNING("This will produce an ingot of "+tempOutputStack.getDisplayName() + " Debug: "+temp); if (null != tempOutputStack){ if (mTier < 5 || !dustInfo.requiresBlastFurnace()){ - CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(UtilsItems.getSimpleStack(this), tempOutputStack); + if (CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(UtilsItems.getSimpleStack(this), tempOutputStack)){ + Utils.LOG_WARNING("Successfully added a furnace recipe for "+materialName); + } + else { + Utils.LOG_WARNING("Failed to add a furnace recipe for "+materialName); + } } else if (mTier >= 5 || dustInfo.requiresBlastFurnace()){ Utils.LOG_WARNING("Adding recipe for "+materialName+" Ingots in a Blast furnace."); diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 390071b539..12e78f833b 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -18,7 +18,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.4.8.6-release"; + public static final String VERSION = "1.4.9-dev"; public static final String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static boolean isModUpToDate = Utils.isModUpToDate(); public static boolean DEBUG = false; diff --git a/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java index d1857ffefc..b10e643831 100644 --- a/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java +++ b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java @@ -28,7 +28,7 @@ public final class GregtechRecipe { } public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { - Utils.LOG_INFO("Adding a GT Furnace/Alloy Smelter Recipe"); + Utils.LOG_WARNING("Adding a GT Furnace/Alloy Smelter Recipe"+"| Input:"+aInput.getDisplayName()+" | Output:"+aOutput.getDisplayName()+" |"); return ourProxy.addSmeltingAndAlloySmeltingRecipe(aInput, aOutput); } diff --git a/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java b/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java index 9e7e033bed..bcfce5a71b 100644 --- a/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java +++ b/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java @@ -10,36 +10,41 @@ import java.net.URLConnection; public class NetworkUtils { public static String getContentFromURL(String args) { - - URL url; - - try { - // get URL content - url = new URL(args); - URLConnection conn = url.openConnection(); - - // open the stream and put it into BufferedReader - BufferedReader br = new BufferedReader( - new InputStreamReader(conn.getInputStream())); - - String inputLine; - String tempLine = null; - - - - - while ((inputLine = br.readLine()) != null) { - tempLine = inputLine; + if (netIsAvailable()){ + try { + URL url; + // get URL content + url = new URL(args); + URLConnection conn = url.openConnection(); + // open the stream and put it into BufferedReader + BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String inputLine; + String tempLine = null; + while ((inputLine = br.readLine()) != null) { + tempLine = inputLine; + } + br.close(); + return tempLine; + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } - - br.close(); - return tempLine; - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } + } return null; } - + + private static boolean netIsAvailable() { + try { + final URL url = new URL("http://www.google.com"); + final URLConnection conn = url.openConnection(); + conn.connect(); + return true; + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } catch (IOException e) { + return false; + } + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java index 2e10453a05..7d0e43c5e2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -23,11 +23,11 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ private boolean useFuel = false; public GregtechRocketFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + super(aID, aName, aNameRegional, aTier, 4, aDescription, aTextures); } public GregtechRocketFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); + super(aName, aTier, 4, aDescription, aTextures); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java index 5044f958c8..3f90e2a467 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java @@ -20,7 +20,7 @@ public class TexturesGtBlocks { public CustomIcon(String aIconName) { mIconName = aIconName; - Utils.LOG_INFO("Constructing a Custom Texture. " + mIconName); + Utils.LOG_WARNING("Constructing a Custom Texture. " + mIconName); GregTech_API.sGTBlockIconload.add(this); } @@ -37,7 +37,7 @@ public class TexturesGtBlocks { @Override public void run() { mIcon = GregTech_API.sBlockIcons.registerIcon(CORE.MODID + ":" + mIconName); - Utils.LOG_INFO("FIND ME _ Processing texture: "+this.getTextureFile().getResourcePath()); + Utils.LOG_WARNING("FIND ME _ Processing texture: "+this.getTextureFile().getResourcePath()); } @Override @@ -56,11 +56,31 @@ public class TexturesGtBlocks { //Machine Casings + private static final CustomIcon Internal_Casing_Machine_Simple = new CustomIcon("TileEntities/machine_top"); + public static final CustomIcon Casing_Machine_Simple = Internal_Casing_Machine_Simple; + private static final CustomIcon Internal_Casing_Machine_Dimensional = new CustomIcon("TileEntities/adv_machine_dimensional"); public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = new CustomIcon("TileEntities/high_adv_machine_dimensional"); public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; + private static final CustomIcon Internal_Casing_Machine_Sound = new CustomIcon("TileEntities/audio_out"); + public static final CustomIcon Casing_Machine_Sound = Internal_Casing_Machine_Sound; + private static final CustomIcon Internal_Casing_Machine_Sound_Active = new CustomIcon("TileEntities/audio_out_active"); + public static final CustomIcon Casing_Machine_Sound_Active = Internal_Casing_Machine_Sound_Active; + + private static final CustomIcon Internal_Casing_Machine_Redstone_Off = new CustomIcon("TileEntities/cover_redstone_conductor"); + public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; + private static final CustomIcon Internal_Casing_Machine_Redstone_On = new CustomIcon("TileEntities/cover_redstone_emitter"); + public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; + + private static final CustomIcon Internal_Casing_Machine_Vent = new CustomIcon("TileEntities/machine_top_vent_rotating"); + public static final CustomIcon Casing_Machine_Vent = Internal_Casing_Machine_Vent; + private static final CustomIcon Internal_Casing_Machine_Vent_Fast = new CustomIcon("TileEntities/machine_top_vent_rotating_fast"); + public static final CustomIcon Casing_Machine_Vent_Fast = Internal_Casing_Machine_Vent_Fast; + private static final CustomIcon Internal_Casing_Machine_Vent_Adv = new CustomIcon("TileEntities/adv_machine_vent_rotating"); + public static final CustomIcon Casing_Machine_Vent_Adv = Internal_Casing_Machine_Vent_Adv; + //Computer Screens private static final CustomIcon Internal_Casing_Machine_Screen_1 = new CustomIcon("TileEntities/adv_machine_screen_random1"); public static final CustomIcon Casing_Machine_Screen_1 = Internal_Casing_Machine_Screen_1; @@ -70,6 +90,12 @@ public class TexturesGtBlocks { public static final CustomIcon Casing_Machine_Screen_3 = Internal_Casing_Machine_Screen_3; private static final CustomIcon Internal_Casing_Machine_Screen_Frequency = new CustomIcon("TileEntities/adv_machine_screen_frequency"); public static final CustomIcon Casing_Machine_Screen_Frequency = Internal_Casing_Machine_Screen_Frequency; + + //Overlays + private static final CustomIcon Internal_Overlay_Crafting_Bronze = new CustomIcon("TileEntities/bronze_top_crafting"); + public static final CustomIcon Overlay_Crafting_Bronze = Internal_Overlay_Crafting_Bronze; + private static final CustomIcon Internal_Overlay_Crafting_Steel = new CustomIcon("TileEntities/cover_crafting"); + public static final CustomIcon Overlay_Crafting_Steel = Internal_Overlay_Crafting_Steel; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java index 263254c751..a84ba6d249 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java @@ -136,4 +136,9 @@ extends GT_MetaTileEntity_BasicGenerator { return GT_Recipe_Map.sHotFuels; } + + + public int getPollution() { + return 100; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index 20ebd611a2..892f573add 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -11,6 +11,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.registry.GameRegistry; @@ -69,51 +70,51 @@ public class GregtechMetaTileEntityRocketFuelGenerator @Override public ITexture[] getFront(byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; } @Override public ITexture[] getBack(byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK)}; + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Vent)}; } @Override public ITexture[] getBottom(byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM)}; + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple)}; } @Override public ITexture[] getTop(byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP)}; + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_Off)}; } @Override public ITexture[] getSides(byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE)}; + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Sound)}; } @Override public ITexture[] getFrontActive(byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; } @Override public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE)}; + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Vent_Fast)}; } @Override public ITexture[] getBottomActive(byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE)}; + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple)}; } @Override public ITexture[] getTopActive(byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE)}; + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_On)}; } @Override public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE)}; + return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Sound_Active)}; } } diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top.png new file mode 100644 index 0000000000..815ad92daf Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating.png.mcmeta index 97596ba817..5e86a7cd5f 100644 --- a/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating.png.mcmeta +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating.png.mcmeta @@ -1,5 +1,5 @@ { "animation":{ - "frametime":2 + "frametime":8 } } \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating_fast.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating_fast.png new file mode 100644 index 0000000000..0b49d7534b Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating_fast.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating_fast.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating_fast.png.mcmeta new file mode 100644 index 0000000000..dfae8cae16 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/machine_top_vent_rotating_fast.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":1 + } +} \ No newline at end of file -- cgit From 77e7efe4f6ce3f6562c86569bbc831caa16ebf8d Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Fri, 21 Oct 2016 06:08:51 +1000 Subject: % Cleaned up tank tooltips. - Removed all old code now not required by tanks. - Removed the GT4 workbench classes, favourite my homebrew ones. --- .classpath | 2 +- .../api/metatileentity/BaseMetaTileEntityEx.java | 2091 -------------------- .../api/metatileentity/MetaTileEntityEx.java | 972 --------- .../GT_MetaTileEntity_BasicMachineEx.java | 798 -------- .../GT_MetaTileEntity_BasicTankEx.java | 251 --- .../GT_MetaTileEntity_TieredMachineBlockEx.java | 67 - .../core/block/machine/Machine_Workbench.java | 5 +- .../block/machine/Machine_WorkbenchAdvanced.java | 5 +- .../api/gui/CONTAINER_AdvancedWorkbench.java | 180 -- .../api/gui/CONTAINER_BronzeWorkbench.java | 162 -- .../gregtech/api/gui/GUI_AdvancedWorkbench.java | 30 - .../xmod/gregtech/api/gui/GUI_BronzeWorkbench.java | 30 - .../xmod/gregtech/common/Meta_GT_Proxy.java | 10 +- .../common/blocks/GregtechBlockMachines.java | 553 ------ .../GT_MetaTileEntity_AdvancedCraftingTable.java | 555 ------ .../GT_MetaTileEntity_BronzeCraftingTable.java | 160 -- .../storage/GT_MetaTileEntity_TieredTank.java | 343 ++-- .../common/tileentities/storage/GT_NBT_Tank.java | 202 -- .../xmod/gregtech/loaders/Gregtech_Blocks.java | 4 +- .../registration/gregtech/Gregtech4Content.java | 6 +- .../gregtech/GregtechTieredFluidTanks.java | 24 +- 21 files changed, 181 insertions(+), 6269 deletions(-) delete mode 100644 src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java delete mode 100644 src/Java/gregtech/api/metatileentity/MetaTileEntityEx.java delete mode 100644 src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachineEx.java delete mode 100644 src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTankEx.java delete mode 100644 src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlockEx.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_BronzeWorkbench.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/.classpath b/.classpath index 37602a4409..f64ee72b03 100644 --- a/.classpath +++ b/.classpath @@ -13,6 +13,6 @@ - + diff --git a/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java b/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java deleted file mode 100644 index 955b7eb045..0000000000 --- a/src/Java/gregtech/api/metatileentity/BaseMetaTileEntityEx.java +++ /dev/null @@ -1,2091 +0,0 @@ -package gregtech.api.metatileentity; - -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.enums.GT_Values.V; -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IEnergyConnected; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.net.GT_Packet_TileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; -import ic2.api.Direction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.EnumSkyBlock; -import net.minecraft.world.World; -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * This is the main TileEntity for EVERYTHING. - */ -public class BaseMetaTileEntityEx extends BaseTileEntity implements IGregTechTileEntity { - private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; - protected MetaTileEntityEx mMetaTileEntity; - protected long mStoredEnergy = 0, mStoredSteam = 0; - protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; - protected boolean mReleaseEnergy = false; - protected int[] mAverageEUInput = new int[]{0, 0, 0, 0, 0}, mAverageEUOutput = new int[]{0, 0, 0, 0, 0}; - private boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; - private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; - - - //TODO - //TODO - //TODO - //TODO - private boolean mHasEnoughEnergy = true; - private boolean mRunningThroughTick = false; - private boolean mInputDisabled = false; - private boolean mOutputDisabled = false; - private boolean mMuffler = false; - private boolean mLockUpgrade = false; - private boolean mActive = false; - private boolean mRedstone = false; - private boolean mWorkUpdate = false; - private boolean mSteamConverter = false; - private boolean mInventoryChanged = false; - private boolean mWorks = true; - private boolean mNeedsUpdate = true; - private boolean mNeedsBlockUpdate = true; - private boolean mSendClientData = false; - private boolean oRedstone = false; - //TODO - //TODO - - // Create a new NBT Tag List to store itemstacks as NBT Tags - protected NBTTagList mInventoryItems = new NBTTagList(); - protected ItemStack[] mInventory; - //TODO - //TODO - //TODO - - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; - private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; - private short mID = 0; - private long mTickTimer = 0, oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; - private String mOwnerName = ""; - private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - - public BaseMetaTileEntityEx() { - /* this.mInventory = mMetaTileEntity.mInventory; - Utils.LOG_INFO(UtilsItems.getArrayStackNames(mInventory));*/ - } - - - @Override - public void writeToNBT(NBTTagCompound aNBT) { - try { - super.writeToNBT(aNBT); - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - try { - aNBT.setInteger("mID", mID); - aNBT.setLong("mStoredSteam", mStoredSteam); - aNBT.setLong("mStoredEnergy", mStoredEnergy); - aNBT.setIntArray("mCoverData", mCoverData); - aNBT.setIntArray("mCoverSides", mCoverSides); - aNBT.setByteArray("mRedstoneSided", mSidedRedstone); - aNBT.setByte("mColor", mColor); - aNBT.setByte("mLightValue", mLightValue); - aNBT.setByte("mOtherUpgrades", mOtherUpgrades); - aNBT.setByte("mWorkData", mWorkData); - aNBT.setByte("mStrongRedstone", mStrongRedstone); - aNBT.setShort("mFacing", mFacing); - aNBT.setString("mOwnerName", mOwnerName); - aNBT.setBoolean("mLockUpgrade", mLockUpgrade); - aNBT.setBoolean("mMuffler", mMuffler); - aNBT.setBoolean("mSteamConverter", mSteamConverter); - aNBT.setBoolean("mActive", mActive); - aNBT.setBoolean("mRedstone", mRedstone); - aNBT.setBoolean("mWorks", !mWorks); - aNBT.setBoolean("mInputDisabled", mInputDisabled); - aNBT.setBoolean("mOutputDisabled", mOutputDisabled); - aNBT.setTag("GT.CraftingComponents", mRecipeStuff); - - //Let's try save the contents of the inventory - // Create a new NBT Tag List to store itemstacks as NBT Tags - NBTTagList items = new NBTTagList(); - - for (int i = 0; i < getSizeInventory(); ++i) - { - // Only write stacks that contain items - if (getStackInSlot(i) != null){ - // Make a new NBT Tag Compound to write the itemstack and slot index to - NBTTagCompound item = new NBTTagCompound(); - item.setInteger("Slot", i); - // Writes the itemstack in slot(i) to the Tag Compound we just made - getStackInSlot(i).writeToNBT(item); - // add the tag compound to our tag list - items.appendTag(item); - } - } - // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" - aNBT.setTag("TileEntityInventory", items); - - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - try { - if (hasValidMetaTileEntity()) { - NBTTagList tItemList = new NBTTagList(); - for (int i = 0; i < mMetaTileEntity.getRealInventory().length; i++) { - ItemStack tStack = mMetaTileEntity.getRealInventory()[i]; - if (tStack != null) { - NBTTagCompound tTag = new NBTTagCompound(); - tTag.setInteger("IntSlot", i); - tStack.writeToNBT(tTag); - tItemList.appendTag(tTag); - } - } - aNBT.setTag("Inventory", tItemList); - - try { - mMetaTileEntity.saveNBTData(aNBT); - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - - @Override - public void readFromNBT(NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - setInitialValuesAsNBT(aNBT, (short) 0); - } - - - @Override - public void setInitialValuesAsNBT(NBTTagCompound aNBT, short aID) { - if (aNBT == null) { - if (aID > 0) mID = aID; - else mID = mID > 0 ? mID : 0; - if (mID != 0) createNewMetatileEntity(mID); - mSidedRedstone = (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior() ? new byte[]{0, 0, 0, 0, 0, 0} : new byte[]{15, 15, 15, 15, 15, 15}); - } else { - if (aID <= 0) mID = (short) aNBT.getInteger("mID"); - else mID = aID; - mStoredSteam = aNBT.getInteger("mStoredSteam"); - mStoredEnergy = aNBT.getInteger("mStoredEnergy"); - mColor = aNBT.getByte("mColor"); - mLightValue = aNBT.getByte("mLightValue"); - mWorkData = aNBT.getByte("mWorkData"); - mStrongRedstone = aNBT.getByte("mStrongRedstone"); - mFacing = oFacing = (byte) aNBT.getShort("mFacing"); - mOwnerName = aNBT.getString("mOwnerName"); - mLockUpgrade = aNBT.getBoolean("mLockUpgrade"); - mMuffler = aNBT.getBoolean("mMuffler"); - mSteamConverter = aNBT.getBoolean("mSteamConverter"); - mActive = aNBT.getBoolean("mActive"); - mRedstone = aNBT.getBoolean("mRedstone"); - mWorks = !aNBT.getBoolean("mWorks"); - mInputDisabled = aNBT.getBoolean("mInputDisabled"); - mOutputDisabled = aNBT.getBoolean("mOutputDisabled"); - mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries")); - mCoverSides = aNBT.getIntArray("mCoverSides"); - mCoverData = aNBT.getIntArray("mCoverData"); - mSidedRedstone = aNBT.getByteArray("mRedstoneSided"); - mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - - //Loading Invetory contents - // Gets the custom taglist we wrote to this compound, if any - NBTTagList items = aNBT.getTagList("TileEntityInventory", Constants.NBT.TAG_COMPOUND); - for (int i = 0; i < items.tagCount(); ++i){ - NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i); - int slot = item.getInteger("Slot"); - // Just double-checking that the saved slot index is within our inventory array bounds - if (slot >= 0 && slot < getSizeInventory()) { - mInventory[slot] = ItemStack.loadItemStackFromNBT(item); - } - } - - if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0}; - if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; - if (mSidedRedstone.length != 6) - if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior()) - mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; - else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - - if (mID != 0 && createNewMetatileEntity(mID)) { - NBTTagList tItemList = aNBT.getTagList("Inventory", 10); - for (int i = 0; i < tItemList.tagCount(); i++) { - NBTTagCompound tTag = tItemList.getCompoundTagAt(i); - int tSlot = tTag.getInteger("IntSlot"); - if (tSlot >= 0 && tSlot < mMetaTileEntity.getRealInventory().length) { - mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag); - } - } - - try { - mMetaTileEntity.loadNBTData(aNBT); - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - } - - if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0}; - if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; - if (mSidedRedstone.length != 6) - if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior()) - mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; - else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - } - - private boolean createNewMetatileEntity(short aID) { - if (aID <= 0 || aID >= Meta_GT_Proxy.METATILEENTITIES.length || Meta_GT_Proxy.METATILEENTITIES[aID] == null) { - GT_Log.err.println("GT++ - MetaID " + aID + " not loadable => locking TileEntity!"); - } else { - if (aID != 0) { - if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); - Meta_GT_Proxy.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - mTickTimer = 0; - mID = aID; - return true; - } - } - return false; - } - - /** - * Used for ticking special BaseMetaTileEntities, which need that for Energy Conversion - * It's called right before onPostTick() - */ - public void updateStatus() { - // - } - - /** - * Called when trying to charge Items - */ - public void chargeItem(ItemStack aStack) { - decreaseStoredEU(GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()), false, false), true); - } - - /** - * Called when trying to discharge Items - */ - public void dischargeItem(ItemStack aStack) { - increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getEUCapacity() - getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), false, false, false), true); - } - - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!hasValidMetaTileEntity()) { - if (mMetaTileEntity == null) return; - mMetaTileEntity.setBaseMetaTileEntity(this); - } - - mRunningThroughTick = true; - long tTime = System.currentTimeMillis(); - - for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { - try { - switch (tCode) { - case 0: - tCode++; - if (mTickTimer++ == 0) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - if (isServerSide()) for (byte i = 0; i < 6; i++) - if (getCoverIDAtSide(i) != 0) - if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) - dropCover(i, i, true); - - worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); - - mMetaTileEntity.onFirstTick(this); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - } - case 1: - tCode++; - if (isClientSide()) { - if (mColor != oColor) { - mMetaTileEntity.onColorChangeClient(oColor = mColor); - issueTextureUpdate(); - } - - if (mLightValue != oLightValueClient) { - worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); - oLightValueClient = mLightValue; - issueTextureUpdate(); - } - - if (mNeedsUpdate) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - //worldObj.func_147479_m(xCoord, yCoord, zCoord); - mNeedsUpdate = false; - } - } - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - if (isServerSide() && mTickTimer > 10) { - for (byte i = (byte) (tCode - 2); i < 6; i++) - if (getCoverIDAtSide(i) != 0) { - tCode++; - GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); - int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); - if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { - mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - } - } - - } - case 8: - tCode = 9; - if (isServerSide()) { - if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0; - if (++mAverageEUOutputIndex >= mAverageEUOutput.length) mAverageEUOutputIndex = 0; - - mAverageEUInput[mAverageEUInputIndex] = 0; - mAverageEUOutput[mAverageEUOutputIndex] = 0; - } - case 9: - tCode++; - mMetaTileEntity.onPreTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - case 10: - tCode++; - if (isServerSide()) { - if (mRedstone != oRedstone || mTickTimer == 10) { - for (byte i = 0; i < 6; i++) - mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - oRedstone = mRedstone; - issueBlockUpdate(); - } - - if (xCoord != oX || yCoord != oY || zCoord != oZ) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - issueClientUpdate(); - clearTileEntityBuffer(); - } - - if (mFacing != oFacing) { - oFacing = mFacing; - for (byte i = 0; i < 6; i++) - if (getCoverIDAtSide(i) != 0) - if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) - dropCover(i, i, true); - issueBlockUpdate(); - } - - if (mTickTimer > 20 && mMetaTileEntity.isElectric()) { - mAcceptedAmperes = 0; - - if (getOutputVoltage() != oOutput) { - oOutput = getOutputVoltage(); - } - - if (mMetaTileEntity.isEnetOutput() || mMetaTileEntity.isEnetInput()) { - for (byte i = 0; i < 6; i++) { - boolean - temp = isEnergyInputSide(i); - if (temp != mActiveEUInputs[i]) { - mActiveEUInputs[i] = temp; - } - temp = isEnergyOutputSide(i); - if (temp != mActiveEUOutputs[i]) { - mActiveEUOutputs[i] = temp; - } - } - } - - if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { - long tOutputVoltage = Math.max(oOutput, oOutput + (1 << GT_Utility.getTier(oOutput))), tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); - if (tUsableAmperage > 0) { - long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); - mAverageEUOutput[mAverageEUOutputIndex] += tEU; - decreaseStoredEU(tEU, true); - } - } - if (getEUCapacity() > 0) { - if (GregTech_API.sMachineFireExplosions && getRandomNumber(1000) == 0) { - Block tBlock = getBlockAtSide((byte) getRandomNumber(6)); - if (tBlock != null && tBlock instanceof BlockFire) doEnergyExplosion(); - } - - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - - if (getRandomNumber(1000) == 0) { - if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) - || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord) - || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord) - || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord) - || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) { - if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { - if (getRandomNumber(10) == 0) { - try { - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception e) { - } - doEnergyExplosion(); - } else setOnFire(); - } - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) { - try { - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception e) { - } - doEnergyExplosion(); - } - } - } - } - } - - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - } - case 11: - tCode++; - if (isServerSide()) { - if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { - for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { - if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { - dischargeItem(mMetaTileEntity.mInventory[i]); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) - mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; - } - } - } - } - case 12: - tCode++; - if (isServerSide()) { - if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { - for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { - if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { - chargeItem(mMetaTileEntity.mInventory[i]); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) - mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; - } - } - } - } - case 13: - tCode++; - updateStatus(); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - case 14: - tCode++; - mMetaTileEntity.onPostTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - case 15: - tCode++; - if (isServerSide()) { - if (mTickTimer % 10 == 0) { - if (mSendClientData) { - NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord); - mSendClientData = false; - } - } - - if (mTickTimer > 10) { - byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)); - if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); - tData = mMetaTileEntity.getUpdateData(); - if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); - if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); - tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); - if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); - if (mLightValue != oLightValue) { - worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); - issueTextureUpdate(); - sendBlockEvent((byte) 7, oLightValue = mLightValue); - } - } - - if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); - mNeedsBlockUpdate = false; - } - } - default: - tCode = -1; - break; - } - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - if (isServerSide() && hasValidMetaTileEntity()) { - tTime = System.currentTimeMillis() - tTime; - if (mTimeStatistics.length > 0) - mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime; - if (tTime > 0 && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10) - System.out.println("GT++ - WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime + "ms caused by an instance of " + getMetaTileEntity().getClass()); - } - - mWorkUpdate = mInventoryChanged = mRunningThroughTick = false; - } - - - @Override - public Packet getDescriptionPacket() { - issueClientUpdate(); - return null; - } - - - @Override - public boolean receiveClientEvent(int aEventID, int aValue) { - super.receiveClientEvent(aEventID, aValue); - - if (hasValidMetaTileEntity()) { - try { - mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue); - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - if (isClientSide()) { - issueTextureUpdate(); - switch (aEventID) { - case 0: - mFacing = (byte) (aValue & 7); - mActive = ((aValue & 8) != 0); - mRedstone = ((aValue & 16) != 0); - //mLockUpgrade = ((aValue&32) != 0); - break; - case 1: - if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte) aValue); - break; - case 2: - if (aValue > 16 || aValue < 0) aValue = 0; - mColor = (byte) aValue; - break; - case 3: - mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0); - mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0); - mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0); - mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0); - mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0); - mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0); - break; - case 4: - if (hasValidMetaTileEntity() && mTickTimer > 20) - mMetaTileEntity.doSound((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; - case 5: - if (hasValidMetaTileEntity() && mTickTimer > 20) - mMetaTileEntity.startSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; - case 6: - if (hasValidMetaTileEntity() && mTickTimer > 20) - mMetaTileEntity.stopSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; - case 7: - mLightValue = (byte) aValue; - break; - } - } - return true; - } - - public ArrayList getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { - ArrayList tList = new ArrayList(); - if (aLogLevel > 2) { - tList.add("GT++ - Meta-ID: " + mID + (canAccessData() ? " valid" : " invalid") + (mMetaTileEntity == null ? " MetaTileEntity == null!" : " ")); - } - if (aLogLevel > 1) { - if (mTimeStatistics.length > 0) { - double tAverageTime = 0; - for (int tTime : mTimeStatistics) tAverageTime += tTime; - tList.add("GT++ - This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + "ms over the last " + mTimeStatistics.length + " ticks."); - } - if (mLagWarningCount > 0) { - tList.add("GT++ - This TileEntity has also caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); - } - tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : " not ") + "accessible for you"); - } - if (aLogLevel > 0) { - if (getSteamCapacity() > 0 && hasSteamEngineUpgrade()) - tList.add(getStoredSteam() + " of " + getSteamCapacity() + " Steam"); - tList.add("Machine is " + (mActive ? "active" : "inactive")); - if (!mHasEnoughEnergy) - tList.add("GT++ - ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process."); - } - return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); - } - - - @Override - public void issueTextureUpdate() { - mNeedsUpdate = true; - } - - - @Override - public void issueBlockUpdate() { - mNeedsBlockUpdate = true; - } - - - @Override - public void issueClientUpdate() { - mSendClientData = true; - } - - - @Override - public void issueCoverUpdate(byte aSide) { - issueClientUpdate(); - } - - - @Override - public byte getStrongestRedstone() { - return (byte) Math.max(getInternalInputRedstoneSignal((byte) 0), Math.max(getInternalInputRedstoneSignal((byte) 1), Math.max(getInternalInputRedstoneSignal((byte) 2), Math.max(getInternalInputRedstoneSignal((byte) 3), Math.max(getInternalInputRedstoneSignal((byte) 4), getInternalInputRedstoneSignal((byte) 5)))))); - } - - - @Override - public boolean getRedstone() { - return getRedstone((byte) 0) || getRedstone((byte) 1) || getRedstone((byte) 2) || getRedstone((byte) 3) || getRedstone((byte) 4) || getRedstone((byte) 5); - } - - - @Override - public boolean getRedstone(byte aSide) { - return getInternalInputRedstoneSignal(aSide) > 0; - } - - public ITexture getCoverTexture(byte aSide) { - return GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide))); - } - - - @Override - public boolean isGivingInformation() { - if (canAccessData()) return mMetaTileEntity.isGivingInformation(); - return false; - } - - - @Override - public boolean isValidFacing(byte aSide) { - if (canAccessData()) return mMetaTileEntity.isFacingValid(aSide); - return false; - } - - - @Override - public byte getBackFacing() { - return GT_Utility.getOppositeSide(mFacing); - } - - - @Override - public byte getFrontFacing() { - return mFacing; - } - - - @Override - public void setFrontFacing(byte aFacing) { - if (isValidFacing(aFacing)) { - mFacing = aFacing; - mMetaTileEntity.onFacingChange(); - onMachineBlockUpdate(); - } - } - - - @Override - public int getSizeInventory() { - if (canAccessData()) return mMetaTileEntity.getSizeInventory(); - return 0; - } - - - @Override - public ItemStack getStackInSlot(int aIndex) { - if (canAccessData()) return mMetaTileEntity.getStackInSlot(aIndex); - return null; - } - - - @Override - public void setInventorySlotContents(int aIndex, ItemStack aStack) { - mInventoryChanged = true; - if (canAccessData()) - mMetaTileEntity.setInventorySlotContents(aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); - } - - - @Override - public String getInventoryName() { - if (canAccessData()) return mMetaTileEntity.getInventoryName(); - if (Meta_GT_Proxy.METATILEENTITIES[mID] != null) return Meta_GT_Proxy.METATILEENTITIES[mID].getInventoryName(); - return ""; - } - - - @Override - public int getInventoryStackLimit() { - if (canAccessData()) return mMetaTileEntity.getInventoryStackLimit(); - return 64; - } - - - @Override - public void openInventory() { - if (canAccessData()) mMetaTileEntity.onOpenGUI(); - } - - - @Override - public void closeInventory() { - if (canAccessData()) mMetaTileEntity.onCloseGUI(); - } - - - @Override - public boolean isUseableByPlayer(EntityPlayer aPlayer) { - return canAccessData() && playerOwnsThis(aPlayer, false) && mTickTimer > 40 && getTileEntityOffset(0, 0, 0) == this && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 && mMetaTileEntity.isAccessAllowed(aPlayer); - } - - - @Override - public void validate() { - super.validate(); - mTickTimer = 0; - } - - - @Override - public void invalidate() { - tileEntityInvalid = false; - if (canAccessData()) { - mMetaTileEntity.onRemoval(); - mMetaTileEntity.setBaseMetaTileEntity(null); - } - super.invalidate(); - } - - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - } - - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - ItemStack stack = getStackInSlot(slot); - if (stack != null) setInventorySlotContents(slot, null); - return stack; - } - - - @Override - public void onMachineBlockUpdate() { - if (canAccessData()) mMetaTileEntity.onMachineBlockUpdate(); - } - - - @Override - public int getProgress() { - return canAccessData() ? mMetaTileEntity.getProgresstime() : 0; - } - - - @Override - public int getMaxProgress() { - return canAccessData() ? mMetaTileEntity.maxProgresstime() : 0; - } - - - @Override - public boolean increaseProgress(int aProgressAmountInTicks) { - return canAccessData() ? mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks : false; - } - - - @Override - public boolean hasThingsToDo() { - return getMaxProgress() > 0; - } - - - @Override - public void enableWorking() { - if (!mWorks) mWorkUpdate = true; - mWorks = true; - } - - - @Override - public void disableWorking() { - mWorks = false; - } - - - @Override - public boolean isAllowedToWork() { - return mWorks; - } - - - @Override - public boolean hasWorkJustBeenEnabled() { - return mWorkUpdate; - } - - - @Override - public byte getWorkDataValue() { - return mWorkData; - } - - - @Override - public void setWorkDataValue(byte aValue) { - mWorkData = aValue; - } - - - @Override - public int getMetaTileID() { - return mID; - } - - - @Override - public int setMetaTileID(short aID) { - return mID = aID; - } - - - @Override - public boolean isActive() { - return mActive; - } - - - @Override - public void setActive(boolean aActive) { - mActive = aActive; - } - - - @Override - public long getTimer() { - return mTickTimer; - } - - - @Override - public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { - if (!canAccessData()) return false; - return mHasEnoughEnergy = decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || decreaseStoredSteam(aEnergy, false) || (aIgnoreTooLessEnergy && (decreaseStoredSteam(aEnergy, true))); - } - - - @Override - public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { - if (!canAccessData()) return false; - if (getStoredEU() < getEUCapacity() || aIgnoreTooMuchEnergy) { - setStoredEU(mMetaTileEntity.getEUVar() + aEnergy); - return true; - } - return false; - } - - - @Override - public boolean inputEnergyFrom(byte aSide) { - if (aSide == 6) return true; - if (isServerSide()) return (aSide >= 0 && aSide < 6 ? mActiveEUInputs[aSide] : false) && !mReleaseEnergy; - return isEnergyInputSide(aSide); - } - - - @Override - public boolean outputsEnergyTo(byte aSide) { - if (aSide == 6) return true; - if (isServerSide()) return (aSide >= 0 && aSide < 6 ? mActiveEUOutputs[aSide] : false) || mReleaseEnergy; - return isEnergyOutputSide(aSide); - } - - - @Override - public long getOutputAmperage() { - if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesOut(); - return 0; - } - - - @Override - public long getOutputVoltage() { - if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) - return mMetaTileEntity.maxEUOutput(); - return 0; - } - - - @Override - public long getInputAmperage() { - if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesIn(); - return 0; - } - - - @Override - public long getInputVoltage() { - if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxEUInput(); - return Integer.MAX_VALUE; - } - - - @Override - public boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy) { - if (!canAccessData()) return false; - if (mMetaTileEntity.getSteamVar() < getSteamCapacity() || aIgnoreTooMuchEnergy) { - setStoredSteam(mMetaTileEntity.getSteamVar() + aEnergy); - return true; - } - return false; - } - - - @Override - public String[] getDescription() { - if (canAccessData()) return mMetaTileEntity.getDescription(); - return new String[0]; - } - - - @Override - public boolean isValidSlot(int aIndex) { - if (canAccessData()) return mMetaTileEntity.isValidSlot(aIndex); - return false; - } - - - @Override - public long getUniversalEnergyStored() { - return Math.max(getStoredEU(), getStoredSteam()); - } - - - @Override - public long getUniversalEnergyCapacity() { - return Math.max(getEUCapacity(), getSteamCapacity()); - } - - - @Override - public long getStoredEU() { - if (canAccessData()) return Math.min(mMetaTileEntity.getEUVar(), getEUCapacity()); - return 0; - } - - - @Override - public long getEUCapacity() { - if (canAccessData()) return mMetaTileEntity.maxEUStore(); - return 0; - } - - - @Override - public long getStoredSteam() { - if (canAccessData()) return Math.min(mMetaTileEntity.getSteamVar(), getSteamCapacity()); - return 0; - } - - - @Override - public long getSteamCapacity() { - if (canAccessData()) return mMetaTileEntity.maxSteamStore(); - return 0; - } - - - public ITexture[] getTexture(byte aSide) { - ITexture rIcon = getCoverTexture(aSide); - if (rIcon != null) return new ITexture[]{rIcon}; - if (hasValidMetaTileEntity()) - return mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0); - return Textures.BlockIcons.ERROR_RENDERING; - } - - - public ITexture[] getTexture(Block arg0, byte aSide) { - ITexture rIcon = getCoverTexture(aSide); - if (rIcon != null) return new ITexture[]{rIcon}; - if (hasValidMetaTileEntity()) - return mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0); - return Textures.BlockIcons.ERROR_RENDERING; - } - - private boolean isEnergyInputSide(byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (!getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) - return false; - if (isInvalid() || mReleaseEnergy) return false; - if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetInput()) - return mMetaTileEntity.isInputFacing(aSide); - } - return false; - } - - private boolean isEnergyOutputSide(byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (!getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) - return false; - if (isInvalid() || mReleaseEnergy) return mReleaseEnergy; - if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) - return mMetaTileEntity.isOutputFacing(aSide); - } - return false; - } - - - protected boolean hasValidMetaTileEntity() { - return mMetaTileEntity != null && mMetaTileEntity.getBaseMetaTileEntity() == this; - } - - - protected boolean canAccessData() { - return !isDead && hasValidMetaTileEntity(); - } - - - public boolean setStoredEU(long aEnergy) { - if (!canAccessData()) return false; - if (aEnergy < 0) aEnergy = 0; - mMetaTileEntity.setEUVar(aEnergy); - return true; - } - - - public boolean setStoredSteam(long aEnergy) { - if (!canAccessData()) return false; - if (aEnergy < 0) aEnergy = 0; - mMetaTileEntity.setSteamVar(aEnergy); - return true; - } - - - public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { - if (!canAccessData()) { - return false; - } - if (mMetaTileEntity.getEUVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) { - setStoredEU(mMetaTileEntity.getEUVar() - aEnergy); - if (mMetaTileEntity.getEUVar() < 0) { - setStoredEU(0); - return false; - } - return true; - } - return false; - } - - - public boolean decreaseStoredSteam(long aEnergy, boolean aIgnoreTooLessEnergy) { - if (!canAccessData()) return false; - if (mMetaTileEntity.getSteamVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) { - setStoredSteam(mMetaTileEntity.getSteamVar() - aEnergy); - if (mMetaTileEntity.getSteamVar() < 0) { - setStoredSteam(0); - return false; - } - return true; - } - return false; - } - - - public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) { - if (!canAccessData()) return false; - if (aCheckPrecicely || privateAccess() || mOwnerName.equals("")) - if (mOwnerName.equals("") && isServerSide()) setOwnerName(aPlayer.getDisplayName()); - else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName())) - return false; - return true; - } - - - public boolean privateAccess() { - if (!canAccessData()) return mLockUpgrade; - return mLockUpgrade || mMetaTileEntity.ownerControl(); - } - - - public void doEnergyExplosion() { - if (getUniversalEnergyCapacity() > 0 && getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 5) { - doExplosion(oOutput * (getUniversalEnergyStored() >= getUniversalEnergyCapacity() ? 4 : getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 2 ? 2 : 1)); - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems"); - } - } - - - @Override - public void doExplosion(long aAmount) { - if (canAccessData()) { - // This is only for Electric Machines - if (GregTech_API.sMachineWireFire && mMetaTileEntity.isElectric()) { - try { - mReleaseEnergy = true; - IEnergyConnected.Util.emitEnergyToNetwork(V[5], Math.max(1, getStoredEU() / V[5]), this); - } catch (Exception e) {/* Fun Fact: all these "do nothing" Comments you see in my Code, are just there to let Eclipse shut up about the intended empty Brackets, but I need eclipse to yell at me in some of the regular Cases where I forget to add Code */} - } - mReleaseEnergy = false; - // Normal Explosion Code - mMetaTileEntity.onExplosion(); - mMetaTileEntity.doExplosion(aAmount); - } - } - - - - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - - - @Override - public ArrayList getDrops() { - ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, mID); - NBTTagCompound tNBT = new NBTTagCompound(); - if (mRecipeStuff != null && !mRecipeStuff.hasNoTags()) tNBT.setTag("GT.CraftingComponents", mRecipeStuff); - if (mMuffler) tNBT.setBoolean("mMuffler", mMuffler); - if (mLockUpgrade) tNBT.setBoolean("mLockUpgrade", mLockUpgrade); - if (mSteamConverter) tNBT.setBoolean("mSteamConverter", mSteamConverter); - if (mColor > 0) tNBT.setByte("mColor", mColor); - if (mOtherUpgrades > 0) tNBT.setByte("mOtherUpgrades", mOtherUpgrades); - if (mStrongRedstone > 0) tNBT.setByte("mStrongRedstone", mStrongRedstone); - for (byte i = 0; i < mCoverSides.length; i++) { - if (mCoverSides[i] != 0) { - tNBT.setIntArray("mCoverData", mCoverData); - tNBT.setIntArray("mCoverSides", mCoverSides); - break; - } - } - if (hasValidMetaTileEntity()) mMetaTileEntity.setItemNBT(tNBT); - if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT); - return new ArrayList(Arrays.asList(rStack)); - } - - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - //TODO - - - public int getUpgradeCount() { - return (mMuffler ? 1 : 0) + (mLockUpgrade ? 1 : 0) + (mSteamConverter ? 1 : 0) + mOtherUpgrades; - } - - - @Override - public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - if (isClientSide()) { - if (getCoverBehaviorAtSide(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) return true; - if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) - return false; - } - if (isServerSide()) { - if (!privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(getOwnerName())) { - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null) { - if (getColorization() >= 0 && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) { - tCurrentItem.func_150996_a(Items.bucket); - setColorization((byte) (getColorization() >= 16 ? -2 : -1)); - return true; - } - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { - if (mMetaTileEntity.onWrenchRightClick(aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) { - GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { - setCoverDataAtSide(aSide, getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)); - mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - mInputDisabled = !mInputDisabled; - if (mInputDisabled) mOutputDisabled = !mOutputDisabled; - GT_Utility.sendChatToPlayer(aPlayer, "Auto-Input: " + (mInputDisabled ? "Disabled" : "Enabled") + " Auto-Output: " + (mOutputDisabled ? "Disabled" : "Enabled")); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - if (mWorks) disableWorking(); - else enableWorking(); - GT_Utility.sendChatToPlayer(aPlayer, "Machine Processing: " + (isAllowedToWork() ? "Enabled" : "Disabled")); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { - byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); - if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { - mStrongRedstone ^= (1 << tSide); - GT_Utility.sendChatToPlayer(aPlayer, "Redstone Output at Side " + tSide + " set to: " + ((mStrongRedstone & (1 << tSide)) != 0 ? "Strong" : "Weak")); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (getCoverIDAtSide(aSide) == 0) { - if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { - if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(aSide, new GT_ItemStack(tCurrentItem), this) && mMetaTileEntity.allowCoverOnSide(aSide, new GT_ItemStack(tCurrentItem))) { - setCoverItemAtSide(aSide, tCurrentItem); - if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--; - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - } else { - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(0), 1.0F, -1, xCoord, yCoord, zCoord); - dropCover(aSide, aSide, false); - } - return true; - } - } - } - - if (getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)) - return true; - - if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) - return false; - - if (isUpgradable() && aPlayer.inventory.getCurrentItem() != null) {/* - if (ItemList.Upgrade_SteamEngine.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (addSteamEngineUpgrade()) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); - if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; - } - return true; - }*/ - if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (addMufflerUpgrade()) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); - if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; - } - return true; - } - if (ItemList.Upgrade_Lock.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (isUpgradable() && !mLockUpgrade) { - mLockUpgrade = true; - setOwnerName(aPlayer.getDisplayName()); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); - if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; - } - return true; - } - } - } - } - - try { - if (hasValidMetaTileEntity()) return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - - return true; - } - - - @Override - public void onLeftclick(EntityPlayer aPlayer) { - try { - if (aPlayer != null && hasValidMetaTileEntity()) mMetaTileEntity.onLeftclick(this, aPlayer); - } catch (Throwable e) { - GT_Log.err.println("GT++ - Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - - @Override - public boolean isDigitalChest() { - if (canAccessData()) return mMetaTileEntity.isDigitalChest(); - return false; - } - - - @Override - public ItemStack[] getStoredItemData() { - if (canAccessData()) return mMetaTileEntity.getStoredItemData(); - return null; - } - - - @Override - public void setItemCount(int aCount) { - if (canAccessData()) mMetaTileEntity.setItemCount(aCount); - } - - - @Override - public int getMaxItemCount() { - if (canAccessData()) return mMetaTileEntity.getMaxItemCount(); - return 0; - } - - /** - * Can put aStack into Slot - */ - - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { - return canAccessData() && mMetaTileEntity.isItemValidForSlot(aIndex, aStack); - } - - /** - * returns all valid Inventory Slots, no matter which Side (Unless it's covered). - * The Side Stuff is done in the following two Functions. - */ - - @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - if (canAccessData() && (getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this))) - return mMetaTileEntity.getAccessibleSlotsFromSide(aSide); - return new int[0]; - } - - /** - * Can put aStack into Slot at Side - */ - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && (mRunningThroughTick || !mInputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); - } - - /** - * Can pull aStack out of Slot from Side - */ - - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); - } - - - @Override - public boolean isUpgradable() { - return canAccessData() && getUpgradeCount() < 8; - } - - - @Override - public byte getInternalInputRedstoneSignal(byte aSide) { - return (byte) (getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) & 15); - } - - - @Override - public byte getInputRedstoneSignal(byte aSide) { - return (byte) (worldObj.getIndirectPowerLevelTo(getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide) & 15); - } - - - @Override - public byte getOutputRedstoneSignal(byte aSide) { - return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : 0; - // return (byte)(getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) || (mRedstone && getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))?mSidedRedstone[aSide]&15:0); - } - - - @Override - public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) { - if (!getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) - setOutputRedstoneSignal(aSide, aStrength); - } - - - @Override - public void setOutputRedstoneSignal(byte aSide, byte aStrength) { - aStrength = (byte) Math.min(Math.max(0, aStrength), 15); - if (aSide >= 0 && aSide < 6 && mSidedRedstone[aSide] != aStrength) { - mSidedRedstone[aSide] = aStrength; - issueBlockUpdate(); - } - } - - - @Override - public boolean isSteamEngineUpgradable() { - return isUpgradable() && !hasSteamEngineUpgrade() && getSteamCapacity() > 0; - } - - - @Override - public boolean addSteamEngineUpgrade() { - if (isSteamEngineUpgradable()) { - issueBlockUpdate(); - mSteamConverter = true; - return true; - } - return false; - } - - - @Override - public boolean hasSteamEngineUpgrade() { - if (canAccessData() && mMetaTileEntity.isSteampowered()) return true; - return mSteamConverter; - } - - - @Override - public boolean hasMufflerUpgrade() { - return mMuffler; - } - - - @Override - public boolean isMufflerUpgradable() { - return isUpgradable() && !hasMufflerUpgrade(); - } - - - @Override - public boolean addMufflerUpgrade() { - if (isMufflerUpgradable()) return mMuffler = true; - return false; - } - - - @Override - public boolean hasInventoryBeenModified() { - return mInventoryChanged; - } - - - @Override - public void setGenericRedstoneOutput(boolean aOnOff) { - mRedstone = aOnOff; - } - - - @Override - public int getErrorDisplayID() { - return mDisplayErrorCode; - } - - - @Override - public void setErrorDisplayID(int aErrorID) { - mDisplayErrorCode = aErrorID; - } - - - @Override - public IMetaTileEntity getMetaTileEntity() { - return hasValidMetaTileEntity() ? mMetaTileEntity : null; - } - - - @Override - public void setMetaTileEntity(IMetaTileEntity aMetaTileEntity) { - mMetaTileEntity = (MetaTileEntityEx) aMetaTileEntity; - } - - - @Override - public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) { - return aSide >= 0 && aSide < mCoverBehaviors.length ? mCoverBehaviors[aSide] : GregTech_API.sNoBehavior; - } - - - @Override - public void setCoverIDAtSide(byte aSide, int aID) { - if (aSide >= 0 && aSide < 6) { - mCoverSides[aSide] = aID; - mCoverData[aSide] = 0; - mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID); - issueCoverUpdate(aSide); - issueBlockUpdate(); - } - } - - - @Override - public void setCoverItemAtSide(byte aSide, ItemStack aCover) { - GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this); - } - - - @Override - public int getCoverIDAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6) return mCoverSides[aSide]; - return 0; - } - - - @Override - public ItemStack getCoverItemAtSide(byte aSide) { - return GT_Utility.intToStack(getCoverIDAtSide(aSide)); - } - - - @Override - public boolean canPlaceCoverIDAtSide(byte aSide, int aID) { - return getCoverIDAtSide(aSide) == 0; - } - - - @Override - public boolean canPlaceCoverItemAtSide(byte aSide, ItemStack aCover) { - return getCoverIDAtSide(aSide) == 0; - } - - - @Override - public void setCoverDataAtSide(byte aSide, int aData) { - if (aSide >= 0 && aSide < 6) mCoverData[aSide] = aData; - } - - - @Override - public int getCoverDataAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6) return mCoverData[aSide]; - return 0; - } - - - public byte getLightValue() { - return mLightValue; - } - - - @Override - public void setLightValue(byte aLightValue) { - mLightValue = (byte) (aLightValue & 15); - } - - - @Override - public long getAverageElectricInput() { - int rEU = 0; - for (int tEU : mAverageEUInput) rEU += tEU; - return rEU / mAverageEUInput.length; - } - - - @Override - public long getAverageElectricOutput() { - int rEU = 0; - for (int tEU : mAverageEUOutput) rEU += tEU; - return rEU / mAverageEUOutput.length; - } - - - @Override - public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { - if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) { - ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this); - if (tStack != null) { - tStack.setTagCompound(null); - EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack); - tEntity.motionX = 0; - tEntity.motionY = 0; - tEntity.motionZ = 0; - worldObj.spawnEntityInWorld(tEntity); - } - setCoverIDAtSide(aSide, 0); - if (mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { - setOutputRedstoneSignal(aSide, (byte) 0); - } else { - setOutputRedstoneSignal(aSide, (byte) 15); - } - return true; - } - return false; - } - - - @Override - public String getOwnerName() { - if (GT_Utility.isStringInvalid(mOwnerName)) return "Player"; - return mOwnerName; - } - - - @Override - public String setOwnerName(String aName) { - if (GT_Utility.isStringInvalid(aName)) return mOwnerName = "Player"; - return mOwnerName = aName; - } - - - @Override - public byte getComparatorValue(byte aSide) { - return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0; - } - - - @Override - public byte getStrongOutputRedstoneSignal(byte aSide) { - return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 ? (byte) (mSidedRedstone[aSide] & 15) : 0; - } - - - @Override - public void setStrongOutputRedstoneSignal(byte aSide, byte aStrength) { - mStrongRedstone |= (1 << aSide); - setOutputRedstoneSignal(aSide, aStrength); - } - - - @Override - public ItemStack decrStackSize(int aIndex, int aAmount) { - if (canAccessData()) { - mInventoryChanged = true; - return mMetaTileEntity.decrStackSize(aIndex, aAmount); - } - return null; - } - - - @Override - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() || !mMetaTileEntity.isElectric() || !inputEnergyFrom(aSide) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) - return 0; - if (aVoltage > getInputVoltage()) { - doExplosion(aVoltage); - return 0; - } - if (increaseStoredEnergyUnits(aVoltage * (aAmperage = Math.min(aAmperage, Math.min(mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), true)) { - mAverageEUInput[mAverageEUInputIndex] += aVoltage * aAmperage; - mAcceptedAmperes += aAmperage; - return aAmperage; - } - return 0; - } - - - @Override - public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() || !mMetaTileEntity.isElectric() || !outputsEnergyTo(aSide) || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) - return false; - if (decreaseStoredEU(aVoltage * aAmperage, false)) { - mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage; - return true; - } - return false; - } - - - @Override - public boolean acceptsRotationalEnergy(byte aSide) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.acceptsRotationalEnergy(aSide); - } - - - @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy); - } - - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) - return mMetaTileEntity.fill(aSide, aFluid, doFill); - return 0; - } - - - @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this)))) - return mMetaTileEntity.drain(aSide, maxDrain, doDrain); - return null; - } - - - @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) - return mMetaTileEntity.drain(aSide, aFluid, doDrain); - return null; - } - - - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) - return mMetaTileEntity.canFill(aSide, aFluid); - return false; - } - - - @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) - return mMetaTileEntity.canDrain(aSide, aFluid); - return false; - } - - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)))) - return mMetaTileEntity.getTankInfo(aSide); - return new FluidTankInfo[]{}; - } - - - public double getOutputEnergyUnitsPerTick() { - return oOutput; - } - - - public boolean isTeleporterCompatible(ForgeDirection aSide) { - return canAccessData() && mMetaTileEntity.isTeleporterCompatible(); - } - - - public double demandedEnergyUnits() { - if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; - return getEUCapacity() - getStoredEU(); - } - - - public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { - return injectEnergyUnits((byte) aDirection.ordinal(), (int) aAmount, 1) > 0 ? 0 : aAmount; - } - - - public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { - return inputEnergyFrom((byte) aDirection.ordinal()); - } - - - public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { - return outputsEnergyTo((byte) aDirection.ordinal()); - } - - - public double getOfferedEnergy() { - return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) ? Math.max(0, oOutput) : 0; - } - - - public void drawEnergy(double amount) { - mAverageEUOutput[mAverageEUOutputIndex] += amount; - decreaseStoredEU((int) amount, true); - } - - - public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { - return injectEnergyUnits((byte) aForgeDirection.ordinal(), aAmount, 1) > 0 ? 0 : aAmount; - } - - - public int addEnergy(int aEnergy) { - if (!canAccessData()) return 0; - if (aEnergy > 0) - increaseStoredEnergyUnits(aEnergy, true); - else - decreaseStoredEU(-aEnergy, true); - return (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getEUVar()); - } - - - public boolean isAddedToEnergyNet() { - return false; - } - - - public int demandsEnergy() { - if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; - return getCapacity() - getStored(); - } - - - public int getCapacity() { - return (int) Math.min(Integer.MAX_VALUE, getEUCapacity()); - } - - - public int getStored() { - return (int) Math.min(Integer.MAX_VALUE, Math.min(getStoredEU(), getCapacity())); - } - - - public void setStored(int aEU) { - if (canAccessData()) setStoredEU(aEU); - } - - - public int getMaxSafeInput() { - return (int) Math.min(Integer.MAX_VALUE, getInputVoltage()); - } - - - public int getMaxEnergyOutput() { - if (mReleaseEnergy) return Integer.MAX_VALUE; - return getOutput(); - } - - - public int getOutput() { - return (int) Math.min(Integer.MAX_VALUE, oOutput); - } - - - public int injectEnergy(Direction aDirection, int aAmount) { - return injectEnergyUnits((byte) aDirection.toSideValue(), aAmount, 1) > 0 ? 0 : aAmount; - } - - - public boolean isTeleporterCompatible(Direction aSide) { - return canAccessData() && mMetaTileEntity.isTeleporterCompatible(); - } - - - public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) { - return inputEnergyFrom((byte) aDirection.toSideValue()); - } - - - public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) { - return outputsEnergyTo((byte) aDirection.toSideValue()); - } - - - @Override - public boolean isInvalidTileEntity() { - return isInvalid(); - } - - - @Override - public boolean addStackToSlot(int aIndex, ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return true; - if (aIndex < 0 || aIndex >= getSizeInventory()) return false; - ItemStack tStack = getStackInSlot(aIndex); - if (GT_Utility.isStackInvalid(tStack)) { - setInventorySlotContents(aIndex, aStack); - return true; - } - aStack = GT_OreDictUnificator.get(aStack); - if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { - tStack.stackSize += aStack.stackSize; - return true; - } - return false; - } - - - @Override - public boolean addStackToSlot(int aIndex, ItemStack aStack, int aAmount) { - return addStackToSlot(aIndex, GT_Utility.copyAmount(aAmount, aStack)); - } - - - @Override - public byte getColorization() { - return (byte) (mColor - 1); - } - - - @Override - public byte setColorization(byte aColor) { - if (aColor > 15 || aColor < -1) aColor = -1; - if (canAccessData()) mMetaTileEntity.onColorChangeServer(aColor); - return mColor = (byte) (aColor + 1); - } - - - @Override - public float getBlastResistance(byte aSide) { - return canAccessData() ? Math.max(0, getMetaTileEntity().getExplosionResistance(aSide)) : 10.0F; - } - - - @Override - public boolean isUniversalEnergyStored(long aEnergyAmount) { - if (getUniversalEnergyStored() >= aEnergyAmount) return true; - mHasEnoughEnergy = false; - return false; - } - - - @Override - public String[] getInfoData() { - { - if (canAccessData()) return getMetaTileEntity().getInfoData(); - return new String[]{}; - } - } - - - @Override - public void markDirty() { - super.markDirty(); - mInventoryChanged = true; - } - - - @Override - public int getLightOpacity() { - return mMetaTileEntity == null ? getLightValue() > 0 ? 0 : 255 : mMetaTileEntity.getLightOpacity(); - } - - - @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { - mMetaTileEntity.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - } - - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - return mMetaTileEntity.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } - -} \ No newline at end of file diff --git a/src/Java/gregtech/api/metatileentity/MetaTileEntityEx.java b/src/Java/gregtech/api/metatileentity/MetaTileEntityEx.java deleted file mode 100644 index acfcf083be..0000000000 --- a/src/Java/gregtech/api/metatileentity/MetaTileEntityEx.java +++ /dev/null @@ -1,972 +0,0 @@ -package gregtech.api.metatileentity; - -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Config; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * Extend this Class to add a new MetaMachine - * Call the Constructor with the desired ID at the load-phase (not preload and also not postload!) - * Implement the newMetaEntity-Method to return a new ready instance of your MetaTileEntity - *

- * Call the Constructor like the following example inside the Load Phase, to register it. - * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");" - */ -public abstract class MetaTileEntityEx implements IMetaTileEntity { - /** - * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName. - */ - public final String mName; - /** - * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO! - */ - public final ItemStack[] mInventory; - public boolean doTickProfilingInThisTick = true; - /** - * accessibility to this Field is no longer given, see below - */ - private IGregTechTileEntity mBaseMetaTileEntity; - - /** - * This registers your Machine at the List. - * Use only ID's larger than 2048, because i reserved these ones. - * See also the List in the API, as it has a Description containing all the reservations. - * - * @param aID the ID - * @example for Constructor overload. - *

- * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) { - * super(aID, mName, mNameRegional); - * } - */ - public MetaTileEntityEx(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { - if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) - throw new IllegalAccessError("This Constructor has to be called in the load Phase"); - if (Meta_GT_Proxy.METATILEENTITIES[aID] == null) { - Meta_GT_Proxy.METATILEENTITIES[aID] = this; - } else { - Utils.LOG_INFO("Taken by: "+Meta_GT_Proxy.METATILEENTITIES[aID].getMetaName()); - throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); - } - mName = aBasicName.replaceAll(" ", "_").toLowerCase(); - setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntity()); - getBaseMetaTileEntity().setMetaTileID((short) aID); - GT_LanguageManager.addStringLocalization("gt.plusplus.blockmachines." + mName + ".name", aRegionalName); - mInventory = new ItemStack[aInvSlotCount]; - - if (GT.isClientSide()) { - ItemStack tStack = new ItemStack(ModBlocks.blockMetaTileEntity, 1, aID); - tStack.getItem().addInformation(tStack, null, new ArrayList(), true); - } - } - - /** - * This is the normal Constructor. - */ - public MetaTileEntityEx(String aName, int aInvSlotCount) { - mInventory = new ItemStack[aInvSlotCount]; - mName = aName; - } - - - @Override - public IGregTechTileEntity getBaseMetaTileEntity() { - return mBaseMetaTileEntity; - } - - - @Override - public void setBaseMetaTileEntity(IGregTechTileEntity aBaseMetaTileEntity) { - if (mBaseMetaTileEntity != null && aBaseMetaTileEntity == null) { - mBaseMetaTileEntity.getMetaTileEntity().inValidate(); - mBaseMetaTileEntity.setMetaTileEntity(null); - } - mBaseMetaTileEntity = aBaseMetaTileEntity; - if (mBaseMetaTileEntity != null) { - mBaseMetaTileEntity.setMetaTileEntity(this); - } - } - - - @Override - public ItemStack getStackForm(long aAmount) { - return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, getBaseMetaTileEntity().getMetaTileID()); - } - - public String getLocalName() { - return GT_LanguageManager.getTranslation("gt.plusplus.blockmachines." + mName + ".name"); - } - - - @Override - public void onServerStart() {/*Do nothing*/} - - - @Override - public void onWorldSave(File aSaveDirectory) {/*Do nothing*/} - - - @Override - public void onWorldLoad(File aSaveDirectory) {/*Do nothing*/} - - - @Override - public void onConfigLoad(GT_Config aConfig) {/*Do nothing*/} - - - @Override - public void setItemNBT(NBTTagCompound aNBT) {/*Do nothing*/} - - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister aBlockIconRegister) {/*Do nothing*/} - - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return true; - } - - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {/*Do nothing*/} - - - @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) { - getBaseMetaTileEntity().setFrontFacing(aWrenchingSide); - return true; - } - return false; - } - - - @Override - public void onExplosion() {/*Do nothing*/} - - - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/} - - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} - - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} - - - @Override - public void inValidate() {/*Do nothing*/} - - - @Override - public void onRemoval() {/*Do nothing*/} - - - @Override - public void initDefaultModes(NBTTagCompound aNBT) {/*Do nothing*/} - - /** - * When a GUI is opened - */ - public void onOpenGUI() {/*Do nothing*/} - - /** - * When a GUI is closed - */ - public void onCloseGUI() {/*Do nothing*/} - - /** - * a Player rightclicks the Machine - * Sneaky rightclicks are not getting passed to this! - */ - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - return false; - } - - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - return onRightclick(aBaseMetaTileEntity, aPlayer); - } - - - @Override - public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {/*Do nothing*/} - - - @Override - public void onValueUpdate(byte aValue) {/*Do nothing*/} - - - @Override - public byte getUpdateData() { - return 0; - } - - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} - - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} - - - @Override - public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) {/*Do nothing*/} - - /** - * @return true if this Device emits Energy at all - */ - public boolean isElectric() { - return true; - } - - /** - * @return true if this Device emits Energy at all - */ - public boolean isPneumatic() { - return false; - } - - /** - * @return true if this Device emits Energy at all - */ - public boolean isSteampowered() { - return false; - } - - /** - * @return true if this Device emits Energy at all - */ - public boolean isEnetOutput() { - return false; - } - - /** - * @return true if this Device consumes Energy at all - */ - public boolean isEnetInput() { - return false; - } - - /** - * @return the amount of EU, which can be stored in this Device. Default is 0 EU. - */ - - public long maxEUStore() { - return 0; - } - - /** - * @return the amount of EU/t, which can be accepted by this Device before it explodes. - */ - - public long maxEUInput() { - return 0; - } - - /** - * @return the amount of EU/t, which can be outputted by this Device. - */ - - public long maxEUOutput() { - return 0; - } - - /** - * @return the amount of E-net Impulses of the maxEUOutput size, which can be outputted by this Device. - * Default is 1 Pulse, this shouldn't be set to smaller Values than 1, as it won't output anything in that Case! - */ - - public long maxAmperesOut() { - return 1; - } - - /** - * How many Amperes this Block can suck at max. Surpassing this value won't blow it up. - */ - - public long maxAmperesIn() { - return 1; - } - - /** - * @return true if that Side is an Output. - */ - - public boolean isOutputFacing(byte aSide) { - return false; - } - - /** - * @return true if that Side is an Input. - */ - - public boolean isInputFacing(byte aSide) { - return false; - } - - /** - * @return true if Transformer Upgrades increase Packet Amount. - */ - - public boolean isTransformingLowEnergy() { - return true; - } - - - @Override - public boolean isFacingValid(byte aFacing) { - return false; - } - - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return false; - } - - - @Override - public boolean isValidSlot(int aIndex) { - return true; - } - - - @Override - public boolean setStackToZeroInsteadOfNull(int aIndex) { - return false; - } - - /** - * This is used to get the internal Energy. I use this for the IDSU. - */ - public long getEUVar() { - return ((BaseMetaTileEntityEx) mBaseMetaTileEntity).mStoredEnergy; - } - - /** - * This is used to set the internal Energy to the given Parameter. I use this for the IDSU. - */ - public void setEUVar(long aEnergy) { - ((BaseMetaTileEntityEx) mBaseMetaTileEntity).mStoredEnergy = aEnergy; - } - - /** - * This is used to get the internal Steam Energy. - */ - public long getSteamVar() { - return ((BaseMetaTileEntityEx) mBaseMetaTileEntity).mStoredSteam; - } - - /** - * This is used to set the internal Steam Energy to the given Parameter. - */ - public void setSteamVar(long aSteam) { - ((BaseMetaTileEntityEx) mBaseMetaTileEntity).mStoredSteam = aSteam; - } - - /** - * @return the amount of Steam, which can be stored in this Device. Default is 0 EU. - */ - - public long maxSteamStore() { - return 0; - } - - /** - * @return the amount of EU, which this Device stores before starting to emit Energy. - * useful if you don't want to emit stored Energy until a certain Level is reached. - */ - - public long getMinimumStoredEU() { - return 512; - } - - /** - * Determines the Tier of the Machine, used for de-charging Tools. - */ - - public long getInputTier() { - return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); - } - - /** - * Determines the Tier of the Machine, used for charging Tools. - */ - - public long getOutputTier() { - return GT_Utility.getTier(getBaseMetaTileEntity().getOutputVoltage()); - } - - /** - * gets the first RechargerSlot - */ - - public int rechargerSlotStartIndex() { - return 0; - } - - /** - * gets the amount of RechargerSlots - */ - - public int rechargerSlotCount() { - return 0; - } - - /** - * gets the first DechargerSlot - */ - - public int dechargerSlotStartIndex() { - return 0; - } - - /** - * gets the amount of DechargerSlots - */ - - public int dechargerSlotCount() { - return 0; - } - - /** - * gets if this is protected from other Players per default or not - */ - - public boolean ownerControl() { - return false; - } - - - @Override - public ArrayList getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList aList) { - return aList; - } - - - @Override - public boolean isLiquidInput(byte aSide) { - return true; - } - - - @Override - public boolean isLiquidOutput(byte aSide) { - return true; - } - - /** - * gets the contained Liquid - */ - - @Override - public FluidStack getFluid() { - return null; - } - - /** - * tries to fill this Tank - */ - - @Override - public int fill(FluidStack resource, boolean doFill) { - return 0; - } - - /** - * tries to empty this Tank - */ - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - return null; - } - - /** - * Tank pressure - */ - - public int getTankPressure() { - return 0; - } - - /** - * Liquid Capacity - */ - - @Override - public int getCapacity() { - return 0; - } - - - @Override - public void onMachineBlockUpdate() {/*Do nothing*/} - - - @Override - public void receiveClientEvent(byte aEventID, byte aValue) {/*Do nothing*/} - - - @Override - public boolean isSimpleMachine() { - return false; - } - - /** - * If this accepts up to 4 Overclockers - */ - - public boolean isOverclockerUpgradable() { - return false; - } - - /** - * If this accepts Transformer Upgrades - */ - - public boolean isTransformerUpgradable() { - return false; - } - - /** - * Progress this machine has already made - */ - - public int getProgresstime() { - return 0; - } - - /** - * Progress this Machine has to do to produce something - */ - - public int maxProgresstime() { - return 0; - } - - /** - * Increases the Progress, returns the overflown Progress. - */ - - public int increaseProgress(int aProgress) { - return 0; - } - - /** - * If this TileEntity makes use of Sided Redstone behaviors. - * Determines only, if the Output Redstone Array is getting filled with 0 for true, or 15 for false. - */ - - public boolean hasSidedRedstoneOutputBehavior() { - return false; - } - - /** - * When the Facing gets changed. - */ - - public void onFacingChange() {/*Do nothing*/} - - /** - * if the IC2 Teleporter can drain from this. - */ - - public boolean isTeleporterCompatible() { - return isEnetOutput() && getBaseMetaTileEntity().getOutputVoltage() >= 128 && getBaseMetaTileEntity().getUniversalEnergyCapacity() >= 500000; - } - - /** - * Gets the Output for the comparator on the given Side - */ - - @Override - public byte getComparatorValue(byte aSide) { - return 0; - } - - - @Override - public boolean acceptsRotationalEnergy(byte aSide) { - return false; - } - - - @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { - return false; - } - - - @Override - public String getSpecialVoltageToolTip() { - return null; - } - - - @Override - public boolean isGivingInformation() { - return false; - } - - - @Override - public String[] getInfoData() { - return new String[]{}; - } - - - public boolean isDigitalChest() { - return false; - } - - - public ItemStack[] getStoredItemData() { - return null; - } - - - public void setItemCount(int aCount) {/*Do nothing*/} - - - public int getMaxItemCount() { - return 0; - } - - - @Override - public int getSizeInventory() { - return mInventory.length; - } - - - @Override - public ItemStack getStackInSlot(int aIndex) { - if (aIndex >= 0 && aIndex < mInventory.length) return mInventory[aIndex]; - return null; - } - - - @Override - public void setInventorySlotContents(int aIndex, ItemStack aStack) { - if (aIndex >= 0 && aIndex < mInventory.length) mInventory[aIndex] = aStack; - } - - - @Override - public String getInventoryName() { - if (GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()] != null) - return GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()].getMetaName(); - return ""; - } - - - @Override - public int getInventoryStackLimit() { - return 64; - } - - - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { - return getBaseMetaTileEntity().isValidSlot(aIndex); - } - - - @Override - public ItemStack decrStackSize(int aIndex, int aAmount) { - ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack); - if (tStack != null) { - if (tStack.stackSize <= aAmount) { - if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0; - else setInventorySlotContents(aIndex, null); - } else { - rStack = tStack.splitStack(aAmount); - if (tStack.stackSize == 0 && !setStackToZeroInsteadOfNull(aIndex)) - setInventorySlotContents(aIndex, null); - } - } - return rStack; - } - - - @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - ArrayList tList = new ArrayList(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity); - for (int i = 0; i < getSizeInventory(); i++) - if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity))) - tList.add(i); - int[] rArray = new int[tList.size()]; - for (int i = 0; i < rArray.length; i++) rArray[i] = tList.get(i); - return rArray; - } - - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); - } - - - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); - } - - - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - return fill(aSide, new FluidStack(aFluid, 1), false) == 1; - } - - - @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - return drain(aSide, new FluidStack(aFluid, 1), false) != null; - } - - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{}; - return new FluidTankInfo[]{getInfo()}; - } - - - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return fill(aFluid, doFill); - } - - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (getBaseMetaTileEntity().hasSteamEngineUpgrade() && GT_ModHandler.isSteam(aFluid) && aFluid.amount > 1) { - int tSteam = (int) Math.min(Integer.MAX_VALUE, Math.min(aFluid.amount / 2, getBaseMetaTileEntity().getSteamCapacity() - getBaseMetaTileEntity().getStoredSteam())); - if (tSteam > 0) { - if (doFill) getBaseMetaTileEntity().increaseStoredSteam(tSteam, true); - return tSteam * 2; - } - } else { - return fill_default(aSide, aFluid, doFill); - } - return 0; - } - - - @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (getFluid() != null && aFluid != null && getFluid().isFluidEqual(aFluid)) - return drain(aFluid.amount, doDrain); - return null; - } - - - @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - return drain(maxDrain, doDrain); - } - - - @Override - public int getFluidAmount() { - return 0; - } - - - @Override - public FluidTankInfo getInfo() { - return new FluidTankInfo(this); - } - - - @Override - public String getMetaName() { - return mName; - } - - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return null; - } - - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - - @Override - public boolean doTickProfilingMessageDuringThisTick() { - return doTickProfilingInThisTick; - } - - - @Override - public void markDirty() { - // - } - - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return false; - } - - - @Override - public void openInventory() { - // - } - - - @Override - public void closeInventory() { - // - } - - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - - @Override - public boolean connectsToItemPipe(byte aSide) { - return false; - } - - - @Override - public float getExplosionResistance(byte aSide) { - return 10.0F; - } - - - @Override - public ItemStack[] getRealInventory() { - return mInventory; - } - - - @Override - public void onColorChangeServer(byte aColor) { - // - } - - - @Override - public void onColorChangeClient(byte aColor) { - // - } - - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInInventory(Block aBlock, int aMeta, RenderBlocks aRenderer) { - return false; - } - - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { - return false; - } - - - @Override - public void doExplosion(long aExplosionPower) { - float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < V[4] * 2 ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F; - int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); - World tWorld = getBaseMetaTileEntity().getWorld(); - GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); - tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) - tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); - } - - - @Override - public int getLightOpacity() { - return ((BaseMetaTileEntityEx) getBaseMetaTileEntity()).getLightValue() > 0 ? 0 : 255; - } - - - @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { - AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) outputAABB.add(axisalignedbb1); - } - - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); - } - - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - // - } - - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - // - } -} \ No newline at end of file diff --git a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachineEx.java b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachineEx.java deleted file mode 100644 index fbf59d4de5..0000000000 --- a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachineEx.java +++ /dev/null @@ -1,798 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_Container_BasicMachine; -import gregtech.api.gui.GT_GUIContainer_BasicMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; - -import java.util.Arrays; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public abstract class GT_MetaTileEntity_BasicMachineEx extends GT_MetaTileEntity_BasicTankEx { - /** - * return values for checkRecipe() - */ - protected static final int - DID_NOT_FIND_RECIPE = 0, - FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, - FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; - private static final int OTHER_SLOT_COUNT = 4; - public final ItemStack[] mOutputItems; - public final int mInputSlotCount, mAmperage; - public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; - public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; - public FluidStack mOutputFluid; - public String mGUIName = "", mNEIName = ""; - private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - /** - * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered - */ - protected GT_Recipe mLastRecipe = null; - private FluidStack mFluidOut; - - /** - * @param aOverlays 0 = SideFacingActive - * 1 = SideFacingInactive - * 2 = FrontFacingActive - * 3 = FrontFacingInactive - * 4 = TopFacingActive - * 5 = TopFacingInactive - * 6 = BottomFacingActive - * 7 = BottomFacingInactive - * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- - * 8 = BottomFacingPipeActive - * 9 = BottomFacingPipeInactive - * 10 = TopFacingPipeActive - * 11 = TopFacingPipeInactive - * 12 = SideFacingPipeActive - * 13 = SideFacingPipeInactive - */ - public GT_MetaTileEntity_BasicMachineEx(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); - mInputSlotCount = Math.max(0, aInputSlotCount); - mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; - mAmperage = aAmperage; - mGUIName = aGUIName; - mNEIName = aNEIName; - } - - public GT_MetaTileEntity_BasicMachineEx(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { - super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); - mInputSlotCount = Math.max(0, aInputSlotCount); - mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; - mAmperage = aAmperage; - mGUIName = aGUIName; - mNEIName = aNEIName; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[14][17][]; - aTextures = Arrays.copyOf(aTextures, 14); - - for (int i = 0; i < aTextures.length; i++) - if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { - if (rTextures[i][c + 1] == null) - rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; - } - - for (byte c = -1; c < 16; c++) { - if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); - if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); - if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); - if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); - if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); - if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); - if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); - if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); - if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); - if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); - if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); - if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); - if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); - if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return mMainFacing > 1 || aFacing > 1; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) { - return aSide != mMainFacing; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return false; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); - } - - @Override - public boolean isLiquidOutput(byte aSide) { - return aSide != mMainFacing; - } - - @Override - public long getMinimumStoredEU() { - return V[mTier] * 16; - } - - @Override - public long maxEUStore() { - return V[mTier] * 64; - } - - @Override - public long maxEUInput() { - return V[mTier]; - } - - @Override - public long maxSteamStore() { - return maxEUStore(); - } - - @Override - public long maxAmperesIn() { - return (mEUt * 2) / V[mTier] + 1; - } - - @Override - public int getInputSlot() { - return OTHER_SLOT_COUNT; - } - - @Override - public int getOutputSlot() { - return OTHER_SLOT_COUNT + mInputSlotCount; - } - - @Override - public int getStackDisplaySlot() { - return 2; - } - - @Override - public int rechargerSlotStartIndex() { - return 1; - } - - @Override - public int dechargerSlotStartIndex() { - return 1; - } - - @Override - public int rechargerSlotCount() { - return mCharge ? 1 : 0; - } - - @Override - public int dechargerSlotCount() { - return mDecharge ? 1 : 0; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public int getProgresstime() { - return mProgresstime; - } - - @Override - public int maxProgresstime() { - return mMaxProgresstime; - } - - @Override - public int increaseProgress(int aProgress) { - mProgresstime += aProgress; - return mMaxProgresstime - mProgresstime; - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); - } - - @Override - public boolean isFluidChangingAllowed() { - return true; - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return true; - } - - @Override - public FluidStack getDisplayedFluid() { - return displaysOutputFluid() ? getDrainableStack() : null; - } - - @Override - public FluidStack getDrainableStack() { - return mFluidOut; - } - - @Override - public FluidStack setDrainableStack(FluidStack aFluid) { - mFluidOut = aFluid; - return mFluidOut; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); - } - - @Override - public void initDefaultModes(NBTTagCompound aNBT) { - mMainFacing = -1; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mFluidTransfer", mFluidTransfer); - aNBT.setBoolean("mItemTransfer", mItemTransfer); - aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); - aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); - aNBT.setInteger("mEUt", mEUt); - aNBT.setInteger("mMainFacing", mMainFacing); - aNBT.setInteger("mProgresstime", mProgresstime); - aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); - aNBT.setTag("GT.CraftingComponents", mRecipeStuff); - if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); - if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); - - for (int i = 0; i < mOutputItems.length; i++) - if (mOutputItems[i] != null) - aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); - mItemTransfer = aNBT.getBoolean("mItemTransfer"); - mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); - mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); - mEUt = aNBT.getInteger("mEUt"); - mMainFacing = aNBT.getInteger("mMainFacing"); - mProgresstime = aNBT.getInteger("mProgresstime"); - mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); - mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); - - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (aBaseMetaTileEntity.isServerSide()) { - mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; - mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; - - doDisplayThings(); - - boolean tSucceeded = false; - - if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { - aBaseMetaTileEntity.setActive(true); - if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { - if (++mProgresstime >= mMaxProgresstime) { - for (int i = 0; i < mOutputItems.length; i++) - for (int j = 0; j < mOutputItems.length; j++) - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) - break; - if (mOutputFluid != null) - if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); - else if (mOutputFluid.isFluidEqual(getDrainableStack())) - getDrainableStack().amount += mOutputFluid.amount; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; - mOutputFluid = null; - mEUt = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mStuttering = false; - tSucceeded = true; - endProcess(); - } - if (mProgresstime > 5) mStuttering = false; - } else { - if (!mStuttering) { - stutterProcess(); - if (canHaveInsufficientEnergy()) mProgresstime = -100; - mStuttering = true; - } - } - } else { - aBaseMetaTileEntity.setActive(false); - } - - boolean tRemovedOutputFluid = false; - - if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { - IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); - if (tTank != null) { - FluidStack tDrained = drain(1000, false); - if (tDrained != null) { - int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); - if (tFilledAmount > 0) - tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); - } - } - if (getDrainableStack() == null) tRemovedOutputFluid = true; - } - - if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { - TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); - } - } - - if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; - else mOutputBlocked++; - - if (allowToCheckRecipe()) { - if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { - if (checkRecipe() == 2) { - if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; - for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; - for (int i = 0; i < mOutputItems.length; i++) { - mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); - if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) - mOutputItems[i].stackSize = 64; - mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); - } - if (mFluid != null && mFluid.amount <= 0) mFluid = null; - mMaxProgresstime = Math.max(1, mMaxProgresstime); - if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { - mEUt = mMaxProgresstime = 1; - } - startProcess(); - } else { - mMaxProgresstime = 0; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; - mOutputFluid = null; - } - } - } else { - if (!mStuttering) { - stutterProcess(); - mStuttering = true; - } - } - } - } - - protected void doDisplayThings() { - if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { - mMainFacing = getBaseMetaTileEntity().getFrontFacing(); - } - if (mMainFacing >= 2 && !mHasBeenUpdated) { - mHasBeenUpdated = true; - getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); - } - - if (displaysInputFluid()) { - int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; - if (getFillableStack() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) - mInventory[tDisplayStackSlot] = null; - } else { - mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); - } - } - } - - protected boolean hasEnoughEnergyToCheckRecipe() { - return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); - } - - protected boolean drainEnergyForProcess(long aEUt) { - return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); - } - - protected void calculateOverclockedNess(GT_Recipe aRecipe) { - calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); - } - - protected void calculateOverclockedNess(int aEUt, int aDuration) { - if (aEUt <= 16) { - mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); - mMaxProgresstime = aDuration / (1 << (mTier - 1)); - } else { - mEUt = aEUt; - mMaxProgresstime = aDuration; - while (mEUt <= V[mTier - 1] * mAmperage) { - mEUt *= 4; - mMaxProgresstime /= 2; - } - } - } - - protected ItemStack getSpecialSlot() { - return mInventory[3]; - } - - protected ItemStack getOutputAt(int aIndex) { - return mInventory[getOutputSlot() + aIndex]; - } - - protected ItemStack[] getAllOutputs() { - ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; - for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); - return rOutputs; - } - - protected boolean canOutput(GT_Recipe aRecipe) { - return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); - } - - protected boolean canOutput(ItemStack... aOutputs) { - if (aOutputs == null) return true; - ItemStack[] tOutputSlots = getAllOutputs(); - for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) - if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { - mOutputBlocked++; - return false; - } - return true; - } - - protected boolean canOutput(FluidStack aOutput) { - return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); - } - - protected ItemStack getInputAt(int aIndex) { - return mInventory[getInputSlot() + aIndex]; - } - - protected ItemStack[] getAllInputs() { - ItemStack[] rInputs = new ItemStack[mInputSlotCount]; - for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); - return rInputs; - } - - protected boolean isOutputEmpty() { - boolean rIsEmpty = true; - for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; - return rIsEmpty; - } - - protected boolean displaysInputFluid() { - return true; - } - - protected boolean displaysOutputFluid() { - return true; - } - - @Override - public void onValueUpdate(byte aValue) { - mMainFacing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) mMainFacing; - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - super.doSound(aIndex, aX, aY, aZ); - if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); - } - - public boolean doesAutoOutput() { - return mItemTransfer; - } - - public boolean doesAutoOutputFluids() { - return mFluidTransfer; - } - - public boolean allowToCheckRecipe() { - return true; - } - - public boolean showPipeFacing() { - return true; - } - - /** - * Called whenever the Machine successfully started a Process, useful for Sound Effects - */ - public void startProcess() { - // - } - - /** - * Called whenever the Machine successfully finished a Process, useful for Sound Effects - */ - public void endProcess() { - // - } - - /** - * Called whenever the Machine aborted a Process, useful for Sound Effects - */ - public void abortProcess() { - // - } - - /** - * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects - */ - public void stutterProcess() { - if (useStandardStutterSound()) sendSound((byte) 8); - } - - /** - * If this Machine can have the Insufficient Energy Line Problem - */ - public boolean canHaveInsufficientEnergy() { - return true; - } - - public boolean useStandardStutterSound() { - return true; - } - - @Override - public String[] getInfoData() { - return new String[]{ - mRecipeStuff.toString(), - mNEIName, - "Progress:", (mProgresstime / 20) + " secs", - (mMaxProgresstime / 20) + " secs", - "Stored Energy:", - getBaseMetaTileEntity().getStoredEU() + "EU", - getBaseMetaTileEntity().getEUCapacity() + "EU"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { - mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); - } - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) - return false; - for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) - if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; - return true; - } - - /** - * @return the Recipe List which is used for this Machine, this is a useful Default Handler - */ - public GT_Recipe_Map getRecipeList() { - return null; - } - - /** - * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case - *

- * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. - *

- * Funny how Eclipse marks the word Enum as not correctly spelled. - * - * @return see constants above - */ - public int checkRecipe() { - GT_Recipe_Map tMap = getRecipeList(); - if (tMap == null) return DID_NOT_FIND_RECIPE; - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); - if (tRecipe == null) return DID_NOT_FIND_RECIPE; - if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; - if (!canOutput(tRecipe)) { - mOutputBlocked++; - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - } - if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - - for (int i = 0; i < mOutputItems.length; i++) - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) - mOutputItems[i] = tRecipe.getOutput(i); - mOutputFluid = tRecipe.getFluidOutput(0); - calculateOverclockedNess(tRecipe); - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; - } - - public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } -} \ No newline at end of file diff --git a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTankEx.java b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTankEx.java deleted file mode 100644 index 46f347cba2..0000000000 --- a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTankEx.java +++ /dev/null @@ -1,251 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.ItemList; -import gregtech.api.gui.GT_Container_BasicTank; -import gregtech.api.gui.GT_GUIContainer_BasicTank; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually - */ -public abstract class GT_MetaTileEntity_BasicTankEx extends GT_MetaTileEntity_TieredMachineBlockEx { - - public FluidStack mFluid; - - /** - * @param aInvSlotCount should be 3 - */ - public GT_MetaTileEntity_BasicTankEx(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_BasicTankEx(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex != getStackDisplaySlot(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - } - - public abstract boolean doesFillContainers(); - - public abstract boolean doesEmptyContainers(); - - public abstract boolean canTankBeFilled(); - - public abstract boolean canTankBeEmptied(); - - public abstract boolean displaysItemStack(); - - public abstract boolean displaysStackSize(); - - public int getInputSlot() { - return 0; - } - - public int getOutputSlot() { - return 1; - } - - public int getStackDisplaySlot() { - return 2; - } - - public boolean isFluidInputAllowed(FluidStack aFluid) { - return true; - } - - public boolean isFluidChangingAllowed() { - return true; - } - - public FluidStack getFillableStack() { - return mFluid; - } - - public FluidStack setFillableStack(FluidStack aFluid) { - mFluid = aFluid; - return mFluid; - } - - public FluidStack getDrainableStack() { - return mFluid; - } - - public FluidStack setDrainableStack(FluidStack aFluid) { - mFluid = aFluid; - return mFluid; - } - - public FluidStack getDisplayedFluid() { - return getDrainableStack(); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) - setFillableStack(null); - - if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { - if (getDisplayedFluid() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) - mInventory[getStackDisplaySlot()] = null; - } else { - mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); - } - } - - if (doesEmptyContainers()) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); - if (tFluid != null && isFluidInputAllowed(tFluid)) { - if (getFillableStack() == null) { - if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - setFillableStack(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } else { - if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - getFillableStack().amount += tFluid.amount; - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } - } - } - - if (doesFillContainers()) { - ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); - if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - if (tFluid != null) getDrainableStack().amount -= tFluid.amount; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); - } - } - } - } - - @Override - public FluidStack getFluid() { - return getDrainableStack(); - } - - @Override - public int getFluidAmount() { - return getDrainableStack() != null ? getDrainableStack().amount : 0; - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) - return 0; - - if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { - if (aFluid.amount <= getCapacity()) { - if (doFill) { - setFillableStack(aFluid.copy()); - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - setFillableStack(aFluid.copy()); - getFillableStack().amount = getCapacity(); - getBaseMetaTileEntity().markDirty(); - } - return getCapacity(); - } - - if (!getFillableStack().isFluidEqual(aFluid)) - return 0; - - int space = getCapacity() - getFillableStack().amount; - if (aFluid.amount <= space) { - if (doFill) { - getFillableStack().amount += aFluid.amount; - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) - getFillableStack().amount = getCapacity(); - return space; - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - if (getDrainableStack() == null || !canTankBeEmptied()) return null; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - return null; - } - - int used = maxDrain; - if (getDrainableStack().amount < used) - used = getDrainableStack().amount; - - if (doDrain) { - getDrainableStack().amount -= used; - getBaseMetaTileEntity().markDirty(); - } - - FluidStack drained = getDrainableStack().copy(); - drained.amount = used; - - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - } - - return drained; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == getOutputSlot(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == getInputSlot(); - } -} \ No newline at end of file diff --git a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlockEx.java b/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlockEx.java deleted file mode 100644 index 7e70c8dafb..0000000000 --- a/src/Java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlockEx.java +++ /dev/null @@ -1,67 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.GT; -import gregtech.api.interfaces.ITexture; -import gregtech.api.metatileentity.MetaTileEntityEx; - -public abstract class GT_MetaTileEntity_TieredMachineBlockEx extends MetaTileEntityEx { - /** - * 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 GT_MetaTileEntity_TieredMachineBlockEx(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 GT_MetaTileEntity_TieredMachineBlockEx(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/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 212e9154be..9ac81bffe4 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -1,6 +1,5 @@ package gtPlusPlus.core.block.machine; -import gregtech.api.items.GT_MetaGenerated_Tool; import gtPlusPlus.GTplusplus; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; @@ -84,12 +83,12 @@ public class Machine_Workbench extends BlockContainer else if (heldItem.getItem() instanceof ITool){ holdingWrench = true; } - else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ + /*else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ GT_MetaGenerated_Tool testTool = (GT_MetaGenerated_Tool) heldItem.getItem(); if (testTool.canWrench(player, x, y, z)){ holdingWrench = true; } - } + }*/ else { holdingWrench = false; } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java index 46c08c0d4d..ce09ddab59 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java @@ -1,6 +1,5 @@ package gtPlusPlus.core.block.machine; -import gregtech.api.items.GT_MetaGenerated_Tool; import gtPlusPlus.GTplusplus; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; @@ -84,12 +83,12 @@ public class Machine_WorkbenchAdvanced extends BlockContainer else if (heldItem.getItem() instanceof ITool){ holdingWrench = true; } - else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ + /*else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ GT_MetaGenerated_Tool testTool = (GT_MetaGenerated_Tool) heldItem.getItem(); if (testTool.canWrench(player, x, y, z)){ holdingWrench = true; } - } + }*/ else { holdingWrench = false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java deleted file mode 100644 index 47c8aedb98..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedWorkbench.java +++ /dev/null @@ -1,180 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.gui; - -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.slots.SlotGtTool; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class CONTAINER_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { - - public CONTAINER_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - public CONTAINER_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) - { - addSlotToContainer(new Slot(mTileEntity, 0, 8, 8)); - addSlotToContainer(new Slot(mTileEntity, 1, 26, 8)); - addSlotToContainer(new Slot(mTileEntity, 2, 44, 8)); - addSlotToContainer(new Slot(mTileEntity, 3, 62, 8)); - addSlotToContainer(new Slot(mTileEntity, 4, 8, 26)); - addSlotToContainer(new Slot(mTileEntity, 5, 26, 26)); - addSlotToContainer(new Slot(mTileEntity, 6, 44, 26)); - addSlotToContainer(new Slot(mTileEntity, 7, 62, 26)); - addSlotToContainer(new Slot(mTileEntity, 8, 8, 44)); - addSlotToContainer(new Slot(mTileEntity, 9, 26, 44)); - addSlotToContainer(new Slot(mTileEntity, 10, 44, 44)); - addSlotToContainer(new Slot(mTileEntity, 11, 62, 44)); - addSlotToContainer(new Slot(mTileEntity, 12, 8, 62)); - addSlotToContainer(new Slot(mTileEntity, 13, 26, 62)); - addSlotToContainer(new Slot(mTileEntity, 14, 44, 62)); - addSlotToContainer(new Slot(mTileEntity, 15, 62, 62)); - - addSlotToContainer(new SlotGtTool(mTileEntity, 16, 82, 8)); - addSlotToContainer(new SlotGtTool(mTileEntity, 17, 100, 8)); - addSlotToContainer(new SlotGtTool(mTileEntity, 18, 118, 8)); - addSlotToContainer(new SlotGtTool(mTileEntity, 19, 136, 8)); - addSlotToContainer(new SlotGtTool(mTileEntity, 20, 154, 8)); - - addSlotToContainer(new Slot(mTileEntity, 21, 82, 28)); - addSlotToContainer(new Slot(mTileEntity, 22, 100, 28)); - addSlotToContainer(new Slot(mTileEntity, 23, 118, 28)); - addSlotToContainer(new Slot(mTileEntity, 24, 82, 46)); - addSlotToContainer(new Slot(mTileEntity, 25, 100, 46)); - addSlotToContainer(new Slot(mTileEntity, 26, 118, 46)); - addSlotToContainer(new Slot(mTileEntity, 27, 82, 64)); - addSlotToContainer(new Slot(mTileEntity, 28, 100, 64)); - addSlotToContainer(new Slot(mTileEntity, 29, 118, 64)); - - addSlotToContainer(new Slot(mTileEntity, 33, 154, 28)); - addSlotToContainer(new Slot(mTileEntity, 34, 154, 64)); - - addSlotToContainer(new Slot(mTileEntity, 30, 136, 28)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 31, 136, 64, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 32, 154, 46, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 32, 136, 46, false, false, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer){ - Utils.LOG_INFO("Player Clicked A Slot. "+aSlotIndex); - if ((aSlotIndex < 21) || (aSlotIndex > 35)) { - Utils.LOG_INFO("Returning slotClick for slot: "+aSlotIndex+" on line 75"); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - if ((mTileEntity == null) || (mTileEntity.getMetaTileEntity() == null)) { - Utils.LOG_INFO("Returning null on Line 79"); - return null; - } - try - { - ItemStack tStack = ((Slot)this.inventorySlots.get(aSlotIndex)).getStack(); - if ((tStack != null) && (tStack.stackSize <= 0) && (!GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack()))) { - Utils.LOG_INFO("Returning null on Line 86"); - return null; - } - if (aSlotIndex == 32) - { - if ((aMouseclick == 0) && (aShifthold == 1)) - { - ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).setBluePrint(null); - Utils.LOG_INFO("Returning null on Line 94"); - return null; - } - } - else - { - if (aSlotIndex == 33) - { - ItemStack tCraftedStack = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(); - if (tCraftedStack != null) { - if (aShifthold == 1) - { - for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i = (byte)(i + 1)) { - for (byte j = 0; (j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); j = (byte)(j + 1)) - { - ItemStack tStack2; - if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { - Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 111"); - return aPlayer.inventory.getItemStack(); - } - Utils.LOG_INFO("Doing something ~ 1"); - aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); - } - } - } - else - { - if (aMouseclick == 0) - { - if (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { - Utils.LOG_INFO("Doing something ~ 2"); - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); - } - Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 127"); - return aPlayer.inventory.getItemStack(); - } - for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) - { - ItemStack tStack2; - if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { - Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 134"); - return aPlayer.inventory.getItemStack(); - } - Utils.LOG_INFO("Doing something ~ 3"); - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); - } - Utils.LOG_INFO("Returning aPlayer.inventory.getItemStack() for slot: "+aSlotIndex+" on line 140"); - return aPlayer.inventory.getItemStack(); - } - } - Utils.LOG_INFO("Returning null on Line 144"); - return null; - } - if (aSlotIndex == 34) - { - ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).mFlushMode = true; - Utils.LOG_INFO("Returning null on Line 150"); - return null; - } - if (aSlotIndex == 35) - { - ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); - Utils.LOG_INFO("Returning null on Line 156"); - return null; - } - } - } - catch (Throwable e) - { - e.printStackTrace(GT_Log.err); - } - Utils.LOG_INFO("Returning super.slotClick() on Line 162"); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() - { - return 33; - } - - @Override - public int getShiftClickSlotCount() - { - return 21; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java deleted file mode 100644 index 650e80ebd5..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_BronzeWorkbench.java +++ /dev/null @@ -1,162 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.gui; - -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class CONTAINER_BronzeWorkbench extends GT_ContainerMetaTile_Machine { - - public CONTAINER_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - public CONTAINER_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) - { - addSlotToContainer(new Slot(this.mTileEntity, 0, 8, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 1, 26, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 2, 44, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 3, 62, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 4, 8, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 5, 26, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 6, 44, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 7, 62, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 8, 8, 44)); - addSlotToContainer(new Slot(this.mTileEntity, 9, 26, 44)); - addSlotToContainer(new Slot(this.mTileEntity, 10, 44, 44)); - addSlotToContainer(new Slot(this.mTileEntity, 11, 62, 44)); - addSlotToContainer(new Slot(this.mTileEntity, 12, 8, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 13, 26, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 14, 44, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 15, 62, 62)); - - addSlotToContainer(new Slot(this.mTileEntity, 16, 82, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 17, 100, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 18, 118, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 19, 136, 8)); - addSlotToContainer(new Slot(this.mTileEntity, 20, 154, 8)); - - addSlotToContainer(new Slot(this.mTileEntity, 21, 82, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 22, 100, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 23, 118, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 24, 82, 46)); - addSlotToContainer(new Slot(this.mTileEntity, 25, 100, 46)); - addSlotToContainer(new Slot(this.mTileEntity, 26, 118, 46)); - addSlotToContainer(new Slot(this.mTileEntity, 27, 82, 64)); - addSlotToContainer(new Slot(this.mTileEntity, 28, 100, 64)); - addSlotToContainer(new Slot(this.mTileEntity, 29, 118, 64)); - - addSlotToContainer(new Slot(this.mTileEntity, 33, 154, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 34, 154, 64)); - - addSlotToContainer(new Slot(this.mTileEntity, 30, 136, 28)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 31, 136, 64, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 154, 46, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 32, 136, 46, false, false, 1)); - } - - public ItemStack func_75144_a(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) - { - if ((aSlotIndex < 21) || (aSlotIndex > 35)) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - if ((this.mTileEntity == null) || (this.mTileEntity.getMetaTileEntity() == null)) { - return null; - } - try - { - ItemStack tStack = ((Slot)this.inventorySlots.get(aSlotIndex)).getStack(); - if ((tStack != null) && (tStack.stackSize <= 0) && (!GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack()))) { - return null; - } - if (aSlotIndex == 32) - { - if ((aMouseclick == 0) && (aShifthold == 1)) - { - ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).setBluePrint(null); - return null; - } - } - else - { - if (aSlotIndex == 33) - { - ItemStack tCraftedStack = ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(); - if (tCraftedStack != null) { - if (aShifthold == 1) - { - for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i = (byte)(i + 1)) { - for (byte j = 0; (j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); j = (byte)(j + 1)) - { - ItemStack tStack2; - if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { - return aPlayer.inventory.getItemStack(); - } - aPlayer.inventory.mainInventory[i] = ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i]); - } - } - } - else - { - if (aMouseclick == 0) - { - if (((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) { - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); - } - return aPlayer.inventory.getItemStack(); - } - for (int i = 0; (i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize) && (((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).canDoCraftingOutput()); i++) - { - ItemStack tStack2; - if ((!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack)) || ((tStack != null) && (tStack.stackSize != tStack2.stackSize))) { - return aPlayer.inventory.getItemStack(); - } - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); - } - return aPlayer.inventory.getItemStack(); - } - } - return null; - } - if (aSlotIndex == 34) - { - ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).mFlushMode = true; - return null; - } - if (aSlotIndex == 35) - { - ((GT_MetaTileEntity_BronzeCraftingTable)this.mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); - return null; - } - } - } - catch (Throwable e) - { - e.printStackTrace(GT_Log.err); - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() - { - return 33; - } - - @Override - public int getShiftClickSlotCount() - { - return 21; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java deleted file mode 100644 index 7da9238bd5..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedWorkbench.java +++ /dev/null @@ -1,30 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.core.lib.CORE; -import net.minecraft.entity.player.InventoryPlayer; - -public class GUI_AdvancedWorkbench -extends GT_GUIContainerMetaTile_Machine -{ - public GUI_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) - { - super(new CONTAINER_AdvancedWorkbench(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "AdvancedCraftingTable.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) - { - //this.fontRendererObj.drawString("Condenser", 8, 4, 4210752); - } - - @Override - 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); - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_BronzeWorkbench.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_BronzeWorkbench.java deleted file mode 100644 index 597edba503..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_BronzeWorkbench.java +++ /dev/null @@ -1,30 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.core.lib.CORE; -import net.minecraft.entity.player.InventoryPlayer; - -public class GUI_BronzeWorkbench -extends GT_GUIContainerMetaTile_Machine -{ - public GUI_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) - { - super(new CONTAINER_BronzeWorkbench(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "BronzeCraftingTable.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) - { - //this.fontRendererObj.drawString("Condenser", 8, 4, 4210752); - } - - @Override - 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); - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 98fcc6d6bb..3ef5af0774 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -11,7 +11,7 @@ import gregtech.api.enums.SubTag; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.ToolDictNames; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.metatileentity.BaseMetaTileEntityEx; +import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.GT_Log; @@ -914,17 +914,17 @@ public class Meta_GT_Proxy { /** * This gives you a new BaseMetaTileEntity. As some Interfaces are not always loaded (Buildcraft, Univeral Electricity) I have to use Invocation at the Constructor of the BaseMetaTileEntity */ - private static Class sBaseMetaTileEntityClass = null; + private static Class sBaseMetaTileEntityClass = null; - public static BaseMetaTileEntityEx constructBaseMetaTileEntity() { + public static BaseMetaTileEntity constructBaseMetaTileEntity() { if (sBaseMetaTileEntityClass == null) { try { - return (BaseMetaTileEntityEx) (sBaseMetaTileEntityClass = BaseMetaTileEntityEx.class).newInstance(); + return (BaseMetaTileEntity) (sBaseMetaTileEntityClass = BaseMetaTileEntity.class).newInstance(); } catch (Throwable e) {/*Do nothing*/} } try { - return (BaseMetaTileEntityEx) (sBaseMetaTileEntityClass.newInstance()); + return (BaseMetaTileEntity) (sBaseMetaTileEntityClass.newInstance()); } catch (Throwable e) { Utils.LOG_INFO("Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); e.printStackTrace(GT_Log.err); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java deleted file mode 100644 index 0b47d3c5c1..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java +++ /dev/null @@ -1,553 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.blocks; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IDebugableBlock; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.items.GT_Generic_Block; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.BaseMetaTileEntityEx; -import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Item_Machines; -import gregtech.common.blocks.GT_Material_Machines; -import gregtech.common.render.GT_Renderer_Block; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.block.ITileEntityProvider; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class GregtechBlockMachines - extends GT_Generic_Block - implements IDebugableBlock, ITileEntityProvider { - public static ThreadLocal mTemporaryTileEntity = new ThreadLocal(); - - public GregtechBlockMachines() { - super(GT_Item_Machines.class, "gt.plusplus.blockmachines", new GT_Material_Machines()); - GregTech_API.registerMachineBlock(this, -1); - setHardness(1.0F); - setResistance(10.0F); - setStepSound(soundTypeMetal); - setCreativeTab(AddToCreativeTab.tabMachines); - this.isBlockContainer = true; - } - - @Override - public String getHarvestTool(int aMeta) { - switch (aMeta / 4) { - case 0: - return "wrench"; - case 1: - return "wrench"; - case 2: - return "cutter"; - case 3: - return "axe"; - default: - break; - } - return "wrench"; - } - - @Override - public int getHarvestLevel(int aMeta) { - return aMeta % 4; - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseTileEntity)) { - ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ); - } - } - - @Override - public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { - super.onBlockAdded(aWorld, aX, aY, aZ); - if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - - @Override - public String getUnlocalizedName() { - return "gt.plusplus.blockmachines"; - } - - @Override - public String getLocalizedName() { - return StatCollector.translateToLocal(getUnlocalizedName() + ".name"); - } - - @Override - public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return 0; - } - - @Override - public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0) ? 100 : 0; - } - - @Override - public int getRenderType() { - if (GT_Renderer_Block.INSTANCE == null) { - return super.getRenderType(); - } - return GT_Renderer_Block.INSTANCE.mRenderID; - } - - @Override - public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { - return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0); - } - - @Override - public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0); - } - - @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean canConnectRedstone(IBlockAccess var1, int var2, int var3, int var4, int var5) { - return true; - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean hasTileEntity(int aMeta) { - return true; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(World aWorld, int aMeta) { - return createTileEntity(aWorld, aMeta); - } - - @Override - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { - return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - - @Override - public IIcon getIcon(int aSide, int aMeta) { - return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - - @Override - public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { - super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity != null ? tTileEntity.receiveClientEvent(aData1, aData2) : false; - } - - @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - ((IGregTechTileEntity) tTileEntity).addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - return; - } - super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - ((IGregTechTileEntity) tTileEntity).onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - return; - } - super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } - - @Override //TODO - @SideOnly(Side.CLIENT) //TODO - public void registerBlockIcons(IIconRegister aIconRegister) { - if (GregTech_API.sPostloadFinished) { - Utils.LOG_INFO("Setting up Icon Register for Blocks"); - Meta_GT_Proxy.sBlockIcons = aIconRegister; - - Utils.LOG_INFO("Registering MetaTileEntity specific Textures"); - for (IMetaTileEntity tMetaTileEntity : Meta_GT_Proxy.METATILEENTITIES) { - try { - if (tMetaTileEntity != null) { - tMetaTileEntity.registerIcons(aIconRegister); - } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - Utils.LOG_INFO("Starting Block Icon Load Phase"); - System.out.println("Starting Block Icon Load Phase"); - for (Runnable tRunnable : Meta_GT_Proxy.GT_BlockIconload) { - try { - tRunnable.run(); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - Utils.LOG_INFO("Finished Block Icon Load Phase"); - System.out.println("Finished Block Icon Load Phase"); - } - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return super.getBlockHardness(aWorld, aX, aY, aZ); - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof BaseMetaTileEntityEx)) && (((BaseMetaTileEntityEx) tTileEntity).privateAccess()) && (!((BaseMetaTileEntityEx) tTileEntity).playerOwnsThis(aPlayer, true))) { - return -1.0F; - } - return super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); - } - - @Override - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, float par2, float par3) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return false; - } - if(aPlayer.isSneaking()){ - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if(tCurrentItem!=null){ - if(!GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)){ - return false; - } - }else {return false;} - } - if ((tTileEntity instanceof IGregTechTileEntity)) { - if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { - return false; - } - if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) { - return true; - } - return ((IGregTechTileEntity) tTileEntity).onRightclick(aPlayer, (byte) aSide, par1, par2, par3); - } - return false; - } - - @Override - public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity != null) && - ((tTileEntity instanceof IGregTechTileEntity))) { - ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); - } - } - - @Override - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - return ((IGregTechTileEntity) tTileEntity).getMetaTileID(); - } - return 0; - } - - @Override - public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntityEx)) { - ((BaseMetaTileEntityEx) tTileEntity).doEnergyExplosion(); - } - super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); - } - - @Override - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; - Random tRandom = new Random(); - mTemporaryTileEntity.set(tGregTechTileEntity); - for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { - ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); - if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) { - EntityItem tItemEntity = new EntityItem(aWorld, aX + tRandom.nextFloat() * 0.8F + 0.1F, aY + tRandom.nextFloat() * 0.8F + 0.1F, aZ + tRandom.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); - if (tItem.hasTagCompound()) { - tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); - } - tItemEntity.motionX = (tRandom.nextGaussian() * 0.0500000007450581D); - tItemEntity.motionY = (tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D); - tItemEntity.motionZ = (tRandom.nextGaussian() * 0.0500000007450581D); - aWorld.spawnEntityInWorld(tItemEntity); - tItem.stackSize = 0; - tGregTechTileEntity.setInventorySlotContents(i, null); - } - } - } - super.breakBlock(aWorld, aX, aY, aZ, par5, par6); - aWorld.removeTileEntity(aX, aY, aZ); - } - - @Override - public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - return ((IGregTechTileEntity) tTileEntity).getDrops(); - } - return mTemporaryTileEntity.get() == null ? new ArrayList() : ((IGregTechTileEntity) mTemporaryTileEntity.get()).getDrops(); - } - - @Override - public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechTileEntity))) { - return ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide); - } - return 0; - } - - @Override - public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if ((aSide < 0) || (aSide > 5)) { - return 0; - } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechTileEntity))) { - return ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); - } - return 0; - } - - @Override - public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if ((aSide < 0) || (aSide > 5)) { - return 0; - } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechTileEntity))) { - return ((IGregTechTileEntity) tTileEntity).getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); - } - return 0; - } - - @Override - public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) { - if (!aWorld.isRemote) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity != null) && (chance < 1.0F)) { - if (((tTileEntity instanceof BaseMetaTileEntityEx)) && (GregTech_API.sMachineNonWrenchExplosions)) { - ((BaseMetaTileEntityEx) tTileEntity).doEnergyExplosion(); - } - } else { - super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7); - } - } - } - - @Override - public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { - if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { - return true; - } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null) { - if ((tTileEntity instanceof BaseMetaTileEntityEx)) { - return true; - } - if (((tTileEntity instanceof BaseMetaPipeEntity)) && ((((BaseMetaPipeEntity) tTileEntity).mConnections & 0xFFFFFFC0) != 0)) { - return true; - } - if (((tTileEntity instanceof ICoverable)) && (((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 0)) { - return true; - } - } - return false; - } - - @Override - public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return 0; - } - if ((tTileEntity instanceof IGregTechTileEntity)) { - return ((IGregTechTileEntity) tTileEntity).getLightOpacity(); - } - return aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 255 : 0; - } - - @Override - public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntityEx)) { - return ((BaseMetaTileEntityEx) tTileEntity).getLightValue(); - } - return 0; - } - - @Override //TODO - public TileEntity createTileEntity(World aWorld, int aMeta) { - if (aMeta < 4) { - return Meta_GT_Proxy.constructBaseMetaTileEntity(); - } - return new BaseMetaPipeEntity(); - } - - @Override - public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, double explosionY, double explosionZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechTileEntity))) { - return ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6); - } - return 10.0F; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 1; i < Meta_GT_Proxy.METATILEENTITIES.length; i++) { - if (Meta_GT_Proxy.METATILEENTITIES[i] != null) { - par3List.add(new ItemStack(par1, 1, i)); - } - } - } - - @Override - public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return; - } - if ((tTileEntity instanceof IGregTechTileEntity)) { - IGregTechTileEntity var6 = (IGregTechTileEntity) tTileEntity; - if (aPlayer == null) { - var6.setFrontFacing((byte) 1); - } else { - int var7 = MathHelper.floor_double(aPlayer.rotationYaw * 4.0F / 360.0F + 0.5D) & 0x3; - int var8 = Math.round(aPlayer.rotationPitch); - if ((var8 >= 65) && (var6.isValidFacing((byte) 1))) { - var6.setFrontFacing((byte) 1); - } else if ((var8 <= -65) && (var6.isValidFacing((byte) 0))) { - var6.setFrontFacing((byte) 0); - } else { - switch (var7) { - case 0: - var6.setFrontFacing((byte) 2); - break; - case 1: - var6.setFrontFacing((byte) 5); - break; - case 2: - var6.setFrontFacing((byte) 3); - break; - case 3: - var6.setFrontFacing((byte) 4); - } - } - } - } - } - - @Override - public ArrayList getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { - TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntityEx)) { - return ((BaseMetaTileEntityEx) tTileEntity).getDebugInfo(aPlayer, aLogLevel); - } - if ((tTileEntity instanceof BaseMetaPipeEntity)) { - return ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); - } - return null; - } - - @Override - public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) ((aColor ^ 0xFFFFFFFF) & 0xF)) { - return false; - } - ((IGregTechTileEntity) tTileEntity).setColorization((byte) ((aColor ^ 0xFFFFFFFF) & 0xF)); - return true; - } - return false; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java deleted file mode 100644 index b150ea32cb..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java +++ /dev/null @@ -1,555 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage; - -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_AdvancedWorkbench; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_AdvancedWorkbench; - -import java.util.ArrayList; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.fluids.FluidStack; - -public class GT_MetaTileEntity_AdvancedCraftingTable -extends GT_MetaTileEntity_BasicTank -{ - public boolean mFlushMode = false; - - public GT_MetaTileEntity_AdvancedCraftingTable(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "WorkBench pro noSc0pe"); - } - - public GT_MetaTileEntity_AdvancedCraftingTable(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - Utils.LOG_INFO("Right Click on Block"); - if (aBaseMetaTileEntity.isClientSide()){ - Utils.LOG_INFO("MTE is ClientSide"); - return true; - } - Utils.LOG_INFO("MTE is not ClientSide"); - aBaseMetaTileEntity.openGUI(aPlayer); - Utils.LOG_INFO("MTE is now has an open GUI"); - return true; - } - - @Override - public String[] getInfoData() { - - if (mFluid == null) { - return new String[]{ - GT_Values.VOLTAGE_NAMES[mTier]+" Workbench", - "Stored Fluid:", - "No Fluid", - Integer.toString(0) + "L", - Integer.toString(getCapacity()) + "L"}; - } - return new String[]{ - GT_Values.VOLTAGE_NAMES[mTier]+" Workbench", - "Stored Fluid:", - mFluid.getLocalizedName(), - Integer.toString(mFluid.amount) + "L", - Integer.toString(getCapacity()) + "L"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - Utils.LOG_INFO("Dumping Fluid data. Name: "+mFluid.getFluid().getName()+" Amount: "+mFluid.amount+"L"); - if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - } - - @Override - public boolean isTransformerUpgradable() - { - return true; - } - - public boolean isBatteryUpgradable() - { - return true; - } - - @Override - public boolean isSimpleMachine() - { - return true; - } - - @Override - public boolean isValidSlot(int aIndex) - { - return (aIndex < 31) || (aIndex > 32); - } - - @Override - public boolean isFacingValid(byte aFacing) - { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) - { - return true; - } - - @Override - public boolean isEnetInput() - { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) - { - return true; - } - - @Override - public long maxEUInput() - { - return 128; - } - - @Override - public long maxEUStore() - { - return 128000; - } - - public int getInvSize() - { - return 35; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) - { - return new GT_MetaTileEntity_AdvancedCraftingTable(mName, mTier, mDescription, mTextures); - } - - public void onRightclick(EntityPlayer aPlayer) - { - getBaseMetaTileEntity().openGUI(aPlayer, 160); - } - - public void onFirstTick() - { - getCraftingOutput(); - } - - @Override - public boolean doesFillContainers() - { - return false; - } - - @Override - public boolean doesEmptyContainers() - { - return false; - } - - @Override - public boolean canTankBeFilled() - { - return true; - } - - @Override - public boolean canTankBeEmptied() - { - return true; - } - - @Override - public boolean displaysItemStack() - { - return false; - } - - @Override - public boolean displaysStackSize() - { - return false; - } - - public void onPostTick() - { - if (getBaseMetaTileEntity().isServerSide()) - { - if (getBaseMetaTileEntity().hasInventoryBeenModified()) { - getCraftingOutput(); - } - fillLiquidContainers(); - if (this.mFlushMode) - { - this.mFlushMode = false; - for (byte i = 21; i < 30; i = (byte)(i + 1)) { - if (this.mInventory[i] != null) { - if (this.mInventory[i].stackSize == 0) - { - this.mInventory[i] = null; - } - else - { - this.mFlushMode = true; - break; - } - } - } - } - } - } - - public void sortIntoTheInputSlots() - { - for (byte i = 21; i < 30; i = (byte)(i + 1)) { - if (this.mInventory[i] != null) - { - if (this.mInventory[i].stackSize == 0) { - this.mInventory[i] = null; - } - if (this.mInventory[i] != null) { - for (byte j = 0; j < 16; j = (byte)(j + 1)) { - if (GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])) { - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), i, j, (byte)64, (byte)1, (byte)64, (byte)1); - } - } - } - if (this.mInventory[i] != null) { - for (byte j = 0; j < 16; j = (byte)(j + 1)) { - if (this.mInventory[j] == null) { - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), i, j, (byte)64, (byte)1, (byte)64, (byte)1); - } - } - } - } - } - } - - private void fillLiquidContainers() - { - for (byte i = 16; (i < 21) && (this.mFluid != null); i = (byte)(i + 1)) - { - ItemStack tOutput = GT_Utility.fillFluidContainer(this.mFluid, this.mInventory[i], true, true); - if (tOutput != null) - { - if (this.mInventory[i].stackSize == 1) - { - this.mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; - this.mInventory[i] = tOutput; - } - else - { - for (byte j = 16; j < 21; j = (byte)(j + 1)) { - if ((this.mInventory[j] == null) || ((GT_Utility.areStacksEqual(tOutput, this.mInventory[j])) && (this.mInventory[j].stackSize + tOutput.stackSize <= tOutput.getMaxStackSize()))) - { - this.mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; - getBaseMetaTileEntity().decrStackSize(i, 1); - if (this.mInventory[j] == null) - { - this.mInventory[j] = tOutput; break; - } - this.mInventory[j].stackSize += 1; - - break; - } - } - } - if ((this.mFluid != null) && (this.mFluid.amount <= 0)) { - this.mFluid = null; - } - } - } - if ((this.mFluid != null) && (this.mFluid.amount <= 0)) { - this.mFluid = null; - } - } - - public void setBluePrint(ItemStack aStack) - { - if (aStack == null) { - aStack = this.mInventory[30]; - } - if ((this.mInventory[31] == null) || (aStack == null) /*|| (aStack.itemID != -2)*/ || (aStack.getItemDamage() != 0) || (aStack.stackSize != 1) || (aStack.hasTagCompound())) { - return; - } - NBTTagCompound tNBT = new NBTTagCompound(); - NBTTagList tNBT_ItemList = new NBTTagList(); - for (int i = 0; i < 9; i++) - { - ItemStack tStack = this.mInventory[(i + 21)]; - if (tStack != null) - { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte)i); - tStack.writeToNBT(tag); - tNBT_ItemList.appendTag(tag); - } - } - tNBT.setTag("Inventory", tNBT_ItemList); - aStack.setTagCompound(tNBT); - } - - public ItemStack getCraftingOutput() - { - if ((this.mInventory[30] != null) /*&& (this.mInventory[30].itemID == -2)*/ && (this.mInventory[30].getItemDamage() == 0) && (this.mInventory[30].hasTagCompound())) - { - NBTTagCompound tNBT = this.mInventory[30].getTagCompound(); - NBTTagList tNBT_ItemList = tNBT.getTagList("Blueprint", 10); //TODO - for (int i = 0; (i < tNBT_ItemList.tagCount()) && (i < 9); i++) - { - NBTTagCompound tag = (NBTTagCompound)tNBT_ItemList.getCompoundTagAt(i); - byte slot = tag.getByte("Slot"); - if ((slot >= 0) && (slot < 9) && (this.mInventory[(slot + 21)] == null)) - { - this.mInventory[(slot + 21)] = GT_Utility.loadItem(tag); - if (this.mInventory[(slot + 21)] != null) { - this.mInventory[(slot + 21)].stackSize = 0; - } - } - } - } - this.mInventory[31] = GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), new ItemStack[] { this.mInventory[21], this.mInventory[22], this.mInventory[23], this.mInventory[24], this.mInventory[25], this.mInventory[26], this.mInventory[27], this.mInventory[28], this.mInventory[29] }); - return this.mInventory[31]; - } - - public boolean canDoCraftingOutput() - { - if (this.mInventory[31] == null) { - return false; - } - for (ItemStack tStack : recipeContent()) { - if (tStack.stackSize > getAmountOf(tStack)) { - return false; - } - } - return true; - } - - private int getAmountOf(ItemStack aStack) - { - int tAmount = 0; - for (byte i = 0; (i < 30) && (tAmount < 9); i = (byte)(i + 1)) { - if (GT_Utility.areStacksOrToolsEqual(aStack, this.mInventory[i])) { - tAmount += this.mInventory[i].stackSize; - } - } - return tAmount; - } - - private ArrayList recipeContent() - { - ArrayList tList = new ArrayList(); - for (byte i = 21; i < 30; i = (byte)(i + 1)) { - if (this.mInventory[i] != null) - { - boolean temp = false; - for (byte j = 0; j < tList.size(); j = (byte)(j + 1)) { - if (GT_Utility.areStacksOrToolsEqual(this.mInventory[i], (ItemStack)tList.get(j))) - { - ((ItemStack)tList.get(j)).stackSize += 1; - temp = true; - break; - } - } - if (!temp) { - tList.add(GT_Utility.copyAmount(1L, new Object[] { this.mInventory[i] })); - } - } - } - return tList; - } - - public ItemStack consumeMaterials(EntityPlayer aPlayer, ItemStack aHoldStack) - { - if (this.mInventory[31] == null) { - return aHoldStack; - } - if (aHoldStack != null) - { - if (!GT_Utility.areStacksEqual(aHoldStack, this.mInventory[31])) { - return aHoldStack; - } - if (aHoldStack.stackSize + this.mInventory[31].stackSize > aHoldStack.getMaxStackSize()) { - return aHoldStack; - } - } - for (byte i = 21; i < 30; i = (byte)(i + 1)) { - if (this.mInventory[i] != null) { - for (byte j = 0; j <= i; j = (byte)(j + 1)) { - if (((j < 21) || (j == i)) && - (GT_Utility.areStacksOrToolsEqual(this.mInventory[i], this.mInventory[j])) && (this.mInventory[j].stackSize > 0)) - { - ItemStack tStack = GT_Utility.getContainerItem(this.mInventory[j], true); - if ((tStack == null) || ((tStack.isItemStackDamageable()) && (tStack.getItemDamage() >= tStack.getMaxDamage()))) - { - getBaseMetaTileEntity().decrStackSize(j, 1); break; - } - if (this.mInventory[j].stackSize == 1) - { - this.mInventory[j] = tStack; break; - } - getBaseMetaTileEntity().decrStackSize(j, 1); - for (byte k = 0; k < 21; k = (byte)(k + 1)) - { - if (this.mInventory[k] == null) - { - this.mInventory[k] = tStack; - break; - } - if ((GT_Utility.areStacksEqual(tStack, this.mInventory[k])) && - (tStack.stackSize + this.mInventory[k].stackSize <= this.mInventory[k].getMaxStackSize())) - { - this.mInventory[k].stackSize += tStack.stackSize; - break; - } - } - break; - } - } - } - } - if (aHoldStack == null) - { - aHoldStack = GT_Utility.copy(new Object[] { this.mInventory[31] }); - aHoldStack.onCrafting(getBaseMetaTileEntity().getWorld(), aPlayer, this.mInventory[31].stackSize); - } - else - { - aHoldStack.stackSize += this.mInventory[31].stackSize; - aHoldStack.onCrafting(getBaseMetaTileEntity().getWorld(), aPlayer, this.mInventory[31].stackSize); - } - fillLiquidContainers(); - - return aHoldStack; - } - - @Override - public long getInputTier() - { - return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); - } - - @Override - public long getOutputTier() - { - return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); - } - - @Override - public int rechargerSlotStartIndex() - { - return 16; - } - - @Override - public int rechargerSlotCount() - { - return 5; - } - - public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) - { - if (aSide == 0) { - return 32; - } - if (aSide == 1) { - return 290; - } - if ((aFacing == 0) || (aFacing == 1)) { - return 222; - } - if ((aFacing == 2) || (aFacing == 3)) { - return 223; - } - return 215; - } - - @Override - public String[] getDescription() - { - return new String[]{"For the very large Projects"}; - } - - public boolean allowPutStack(int aIndex, byte aSide, ItemStack aStack) - { - if (aIndex < 16) - { - for (byte i = 0; i < 16; i = (byte)(i + 1)) { - if (GT_Utility.areStacksOrToolsEqual(aStack, this.mInventory[i])) { - return aIndex == i; - } - } - return true; - } - return false; - } - - public boolean allowPullStack(int aIndex, byte aSide, ItemStack aStack) - { - return (aIndex == 33) || ((this.mFlushMode) && (aIndex >= 21) && (aIndex < 30)); - } - - @Override - public int getCapacity() - { - return 64000; - } - - @Override - public int getTankPressure() - { - return -100; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) - { - return new CONTAINER_AdvancedWorkbench(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) - { - return new GUI_AdvancedWorkbench(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide == 1 ? new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CRAFTING)} : new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java deleted file mode 100644 index d0f15c5da2..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java +++ /dev/null @@ -1,160 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage; - -import gregtech.api.GregTech_API; -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 gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_BronzeWorkbench; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_BronzeWorkbench; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_MetaTileEntity_BronzeCraftingTable -extends GT_MetaTileEntity_AdvancedCraftingTable -{ - public GT_MetaTileEntity_BronzeCraftingTable(int aID, String aName, String aNameRegional, int aTier) - { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_BronzeCraftingTable(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - @Override - public boolean isElectric() - { - return false; - } - - @Override - public boolean isPneumatic() - { - return false; - } - - @Override - public boolean isSteampowered() - { - return false; - } - - @Override - public boolean isTransformerUpgradable() - { - return false; - } - - @Override - public boolean isBatteryUpgradable() - { - return false; - } - - @Override - public boolean isEnetInput() - { - return false; - } - - @Override - public boolean isInputFacing(byte aSide) - { - return false; - } - - @Override - public long maxEUInput() - { - return 0; - } - - @Override - public long maxEUStore() - { - return 0; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) - { - return new GT_MetaTileEntity_BronzeCraftingTable(mName, mTier, mDescription, mTextures); - } - - @Override - public void onRightclick(EntityPlayer aPlayer) - { - getBaseMetaTileEntity().openGUI(aPlayer, 161); - } - - @SuppressWarnings({ "static-method", "unused" }) - public boolean allowCoverOnSide(byte aSide, int aCoverID) - { - return GregTech_API.getCoverBehavior(aCoverID).isSimpleCover(); - } - - @Override - public int rechargerSlotStartIndex() - { - return 0; - } - - @Override - public int rechargerSlotCount() - { - return 0; - } - - @Override - public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) - { - if (aSide == 0) { - return 315; - } - if (aSide == 1) { - return 317; - } - if ((aFacing == 0) || (aFacing == 1)) { - return 318; - } - if ((aFacing == 2) || (aFacing == 3)) { - return 319; - } - return 320; - } - - @Override - public String[] getDescription() - { - return new String[] {"For the smaller Projects"}; - } - - @Override - public int getCapacity() - { - return 16000; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) - { - return new CONTAINER_BronzeWorkbench(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) - { - return new GUI_BronzeWorkbench(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide == 1 ? new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CRAFTING)} : new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java index b0ea5cff3c..0c9a113070 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java @@ -7,192 +7,179 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.fluid.FluidUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -public class GT_MetaTileEntity_TieredTank - extends GT_MetaTileEntity_BasicTank { - - private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - - /*protected String fluidName = getFluidName(); - protected int fluidAmount = getInternalFluidAmount();*/ - - /*private String getFluidName(){ - String x; - if (internalTank != null){ - x = internalTank.getFluid().getName(); +public class GT_MetaTileEntity_TieredTank extends GT_MetaTileEntity_BasicTank { + + private NBTTagCompound mRecipeStuff = new NBTTagCompound(); + private String thisName = ""; + private int thisAmount = 0; + + public GT_MetaTileEntity_TieredTank(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); + } + + public GT_MetaTileEntity_TieredTank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + NBTTagCompound dRecipeStuff = this.mRecipeStuff; + if (dRecipeStuff != null){ + this.thisName = dRecipeStuff.getString("xFluidName"); + this.thisAmount = dRecipeStuff.getInteger("xFluidAmount"); + if (this.thisName.equals("")){ + this.thisName = "Empty"; + } + if (this.thisName == "Empty" && this.thisAmount == 0){ + //Do Nothing + } + else { + return new String[] {mDescription, "Stored Fluid: "+this.thisName, "Stored Amount: "+this.thisAmount+"l", CORE.GT_Tooltip}; + } } - else { - x = "null"; + return new String[] {mDescription, CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER)}; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + //Utils.LOG_INFO("Dumping Fluid data. Name: "+mFluid.getFluid().getName()+" Amount: "+mFluid.amount+"L"); + if (mFluid != null){ + aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + mRecipeStuff.setString("xFluidName", mFluid.getFluid().getName()); + mRecipeStuff.setInteger("xFluidAmount", mFluid.amount); + aNBT.setTag("GT.CraftingComponents", mRecipeStuff); + this.thisName = mRecipeStuff.getString("xFluidName"); + this.thisAmount = mRecipeStuff.getInteger("xFluidAmount"); } - return x; + + + + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); + this.thisName = mRecipeStuff.getString("xFluidName"); + this.thisAmount = mRecipeStuff.getInteger("xFluidAmount"); + //mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + mFluid = FluidUtils.getFluidStack(mRecipeStuff.getString("xFluidName"), mRecipeStuff.getInteger("xFluidAmount")); } - - private int getInternalFluidAmount(){ - int x; - if (internalTank != null){ - x = internalTank.amount; + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + return true; } - else { - x = 0; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public final byte getUpdateData() { + return 0x00; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public String[] getInfoData() { + + if (mFluid == null) { + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", + "Stored Fluid:", + "No Fluid", + Integer.toString(0) + "L", + Integer.toString(getCapacity()) + "L"}; } - return x; - }*/ - - public GT_MetaTileEntity_TieredTank(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); - } - - public GT_MetaTileEntity_TieredTank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER)}; - } - - /* @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - }*/ - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - Utils.LOG_INFO("Dumping Fluid data. Name: "+mFluid.getFluid().getName()+" Amount: "+mFluid.amount+"L"); - if (mFluid != null){ - aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - mRecipeStuff.setString("xFluidName", mFluid.getFluid().getName()); - mRecipeStuff.setInteger("xFluidAmount", mFluid.amount); - aNBT.setTag("GT.CraftingComponents", mRecipeStuff); - } - - - - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - //mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - mFluid = FluidUtils.getFluidStack(mRecipeStuff.getString("xFluidName"), mRecipeStuff.getInteger("xFluidAmount")); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - Utils.LOG_INFO("Right Click on Block"); - if (aBaseMetaTileEntity.isClientSide()){ - Utils.LOG_INFO("MTE is ClientSide"); - return true; - } - Utils.LOG_INFO("MTE is not ClientSide"); - aBaseMetaTileEntity.openGUI(aPlayer); - Utils.LOG_INFO("MTE is now has an open GUI"); - return true; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public final byte getUpdateData() { - return 0x00; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public String[] getInfoData() { - - if (mFluid == null) { - return new String[]{ - GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", - "Stored Fluid:", - "No Fluid", - Integer.toString(0) + "L", - Integer.toString(getCapacity()) + "L"}; - } - return new String[]{ - GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", - "Stored Fluid:", - mFluid.getLocalizedName(), - Integer.toString(mFluid.amount) + "L", - Integer.toString(getCapacity()) + "L"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TieredTank(mName, mTier, mDescription, mTextures); - } - - @Override - public int getCapacity() { - return (int) (Math.pow(2, mTier) * 32000); - } - - @Override - public int getTankPressure() { - return 100; - } + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", + "Stored Fluid:", + mFluid.getLocalizedName(), + Integer.toString(mFluid.amount) + "L", + Integer.toString(getCapacity()) + "L"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TieredTank(mName, mTier, mDescription, mTextures); + } + + @Override + public int getCapacity() { + this.thisName = mRecipeStuff.getString("xFluidName"); + this.thisAmount = mRecipeStuff.getInteger("xFluidAmount"); + return (int) (Math.pow(2, mTier) * 32000); + } + + @Override + public int getTankPressure() { + return 100; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java deleted file mode 100644 index 77787cd2bf..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java +++ /dev/null @@ -1,202 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage; - -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntityEx; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTankEx; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.core.util.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -public class GT_NBT_Tank - extends GT_MetaTileEntity_BasicTankEx { - - - /*protected String fluidName = getFluidName(); - protected int fluidAmount = getInternalFluidAmount();*/ - - /*private String getFluidName(){ - String x; - if (internalTank != null){ - x = internalTank.getFluid().getName(); - } - else { - x = "null"; - } - return x; - } - - private int getInternalFluidAmount(){ - int x; - if (internalTank != null){ - x = internalTank.amount; - } - else { - x = 0; - } - return x; - }*/ - - public GT_NBT_Tank(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); - } - - public GT_NBT_Tank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER)}; - } - - /* @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - }*/ - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - Utils.LOG_INFO("Dumping Fluid data. Name: "+mFluid.getFluid().getName()+" Amount: "+mFluid.amount+"L"); - if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - Utils.LOG_INFO("Right Click on Block"); - if (aBaseMetaTileEntity.isClientSide()){ - Utils.LOG_INFO("MTE is ClientSide"); - return true; - } - Utils.LOG_INFO("MTE is not ClientSide"); - aBaseMetaTileEntity.openGUI(aPlayer); - Utils.LOG_INFO("MTE is now has an open GUI"); - return true; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public final byte getUpdateData() { - return 0x00; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public String[] getInfoData() { - - if (mFluid == null) { - return new String[]{ - GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", - "Stored Fluid:", - "No Fluid", - Integer.toString(0) + "L", - Integer.toString(getCapacity()) + "L"}; - } - return new String[]{ - GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", - "Stored Fluid:", - mFluid.getLocalizedName(), - Integer.toString(mFluid.amount) + "L", - Integer.toString(getCapacity()) + "L"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public MetaTileEntityEx newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_NBT_Tank(mName, mTier, mDescription, mTextures); - } - - @Override - public int getCapacity() { - return (int) (Math.pow(2, mTier) * 32000); - } - - @Override - public int getTankPressure() { - return 100; - } - - @Override - public void sendSound(byte aIndex) { - - } - - @Override - public void sendLoopStart(byte aIndex) { - - } - - @Override - public void sendLoopEnd(byte aIndex) { - - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java index 5cda3ac867..8a92d34a8e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java @@ -1,6 +1,6 @@ package gtPlusPlus.xmod.gregtech.loaders; -import gregtech.api.metatileentity.BaseMetaTileEntityEx; +import gregtech.api.metatileentity.BaseMetaTileEntity; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; @@ -26,7 +26,7 @@ public class Gregtech_Blocks { private static void registerDefailtGtTe(){ Utils.LOG_INFO("Registering new GT TileEntities."); - BaseMetaTileEntityEx tBaseMetaTileEntity = Meta_GT_Proxy.constructBaseMetaTileEntity(); + BaseMetaTileEntity tBaseMetaTileEntity = Meta_GT_Proxy.constructBaseMetaTileEntity(); Utils.LOG_INFO("Testing BaseMetaTileEntity."); if (tBaseMetaTileEntity == null) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java index 3d8f8ce61c..0b71b612f4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java @@ -5,8 +5,6 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; public class Gregtech4Content { @@ -24,8 +22,8 @@ public class Gregtech4Content private static void workbenches(){ //Gregtech 4 Workbenches Utils.LOG_INFO("Gregtech 4 Content | Registering Workbenches."); - GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(828, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); - GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(829, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); + //Free //GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(828, "workbench.bronze", "Bronze Workbench", 0).getStackForm(1L)); + //Free //GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(829, "workbench.advanced", "Advanced Workbench", 1).getStackForm(1L)); } private static void tesseracts(){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java index 690ebcc0ec..d18e12a519 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java @@ -4,22 +4,19 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredTank; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_NBT_Tank; public class GregtechTieredFluidTanks { public static void run() { if (LoadedMods.Gregtech){ - Utils.LOG_INFO("Gregtech5u Content | Registering Fluid Tanks."); + Utils.LOG_INFO("Gregtech5u Content | Registering Portable Fluid Tanks."); run1(); - //run2(); } } - private static void run1() - { + private static void run1() { int ID = 817; GregtechItemList.GT_FluidTank_ULV.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.00", "Ultra Low Voltage Fluid Tank", 0).getStackForm(1L)); GregtechItemList.GT_FluidTank_LV.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.01", "Low Voltage Fluid Tank", 1).getStackForm(1L)); @@ -32,21 +29,4 @@ public class GregtechTieredFluidTanks GregtechItemList.GT_FluidTank_UV.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.08", "Ultimate Voltage Fluid Tank", 8).getStackForm(1L)); GregtechItemList.GT_FluidTank_MAX.set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); } - - private static void run2() - { - int ID = 900; - GregtechItemList.GT_FluidTank_ULV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.00", "Ultra Low Voltage Fluid Tank", 0).getStackForm(1L)); - GregtechItemList.GT_FluidTank_LV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.01", "Low Voltage Fluid Tank", 1).getStackForm(1L)); - GregtechItemList.GT_FluidTank_MV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.02", "Medium Voltage Fluid Tank", 2).getStackForm(1L)); - GregtechItemList.GT_FluidTank_HV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.03", "High Voltage Fluid Tank", 3).getStackForm(1L)); - GregtechItemList.GT_FluidTank_EV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.04", "Extreme Voltage Fluid Tank", 4).getStackForm(1L)); - GregtechItemList.GT_FluidTank_IV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.05", "Insane Voltage Fluid Tank", 5).getStackForm(1L)); - GregtechItemList.GT_FluidTank_LuV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.06", "Ludicrous Voltage Fluid Tank", 6).getStackForm(1L)); - GregtechItemList.GT_FluidTank_ZPM.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.07", "ZPM Voltage Fluid Tank", 7).getStackForm(1L)); - GregtechItemList.GT_FluidTank_UV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.08", "Ultimate Voltage Fluid Tank", 8).getStackForm(1L)); - GregtechItemList.GT_FluidTank_MAX.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); - - - } } -- cgit From ff409ce305de28b2b90c17bb357bbf44715a5f9e Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sat, 22 Oct 2016 06:09:00 +1000 Subject: + Added more Dehydrator Recipes. + Added new dusts for nuclear fuel production. $ Fixed OreDictionary not working for some recipes. $ Changed the Textures on some machines, to now use GT4 overlay textures. --- src/Java/gtPlusPlus/core/item/ModItems.java | 10 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 80 ++++++++-- .../gtPlusPlus/core/recipe/RECIPES_General.java | 4 +- .../interfaces/internal/IGregtech_RecipeAdder.java | 24 ++- .../blocks/textures/CasingTextureHandler.java | 2 +- .../common/blocks/textures/TexturesGtBlocks.java | 70 ++++++--- .../GregtechMetaTileEntityGeothermalGenerator.java | 9 +- .../GregtechMetaTileEntityRocketFuelGenerator.java | 34 ++-- .../GregtechMetaTileEntityIronBlastFurnace.java | 2 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 172 +++++++++++---------- .../registration/gregtech/GregtechDehydrator.java | 8 +- 11 files changed, 278 insertions(+), 137 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index b33a8b747f..a0304727f0 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -132,6 +132,10 @@ public final class ModItems { public static BaseItemBackpack backpack_White; public static Item dustLithiumCarbonate; + + public static Item dustUraniumTetraFluoride; + public static Item dustUraniumHexaFluoride; + public static Item dustLithiumFluoride; public static ItemBlueprint itemBlueprintBase; @@ -233,7 +237,11 @@ public final class ModItems { dustLithiumCarbonate = UtilsItems.generateSpecialUseDusts("LithiumCarbonate", "Lithium Carbonate", Utils.rgbtoHexValue(137, 139, 142))[0]; - + + //Nuclear Fuel Dusts + dustUraniumTetraFluoride = UtilsItems.generateSpecialUseDusts("UraniumTetrafluoride", "Uranium Tetrafluoride", Utils.rgbtoHexValue(17, 179, 42))[0]; + dustUraniumHexaFluoride = UtilsItems.generateSpecialUseDusts("UraniumHexafluoride", "Uranium Hexafluoride", Utils.rgbtoHexValue(9, 199, 32))[0]; + dustLithiumFluoride = UtilsItems.generateSpecialUseDusts("LithiumFluoride", "Lithium Fluoride", Utils.rgbtoHexValue(245, 245, 245))[0]; boolean gtStyleTools = LoadedMods.Gregtech; diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 6a1e496305..e583e05473 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -131,19 +131,19 @@ public class RECIPES_GREGTECH { 30); //EU }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");}*/ try { - + ItemStack cells = UtilsItems.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:itemCellEmpty", "Empty Fluid Cells", 0, 12); - + if (cells == null){ cells = UtilsItems.getItemStackOfAmountFromOreDictNoBroken("cellEmpty", 12); } - + ItemStack[] input = {cells, UtilsItems.getItemStackOfAmountFromOreDict("dustLepidolite", 20)}; - + CORE.RA.addDehydratorRecipe( input, //Item input (Array, up to 2) FluidUtils.getFluidStack("sulfuricacid", 10000), //Fluid input (slot 1) - FluidUtils.getFluidStack("sulfuriclithium", 10000), //Fluid output (slot 1) + FluidUtils.getFluidStack("sulfuriclithium", 10000), //Fluid output (slot 2) new ItemStack[]{ UtilsItems.getItemStackOfAmountFromOreDict("dustPotassium", 1), UtilsItems.getItemStackOfAmountFromOreDict("dustAluminium", 4), @@ -152,11 +152,61 @@ public class RECIPES_GREGTECH { UtilsItems.getItemStackOfAmountFromOreDict("dustLithiumCarbonate", 3), //LithiumCarbonate }, //Output Array of Items - Upto 9, new int[]{0}, - 90*20, //Time in ticks + 75*20, //Time in ticks + 1000); //EU + + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + try { + + CORE.RA.addDehydratorRecipe( + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("cellWater", 10) + }, //Item input (Array, up to 2) + FluidUtils.getFluidStack("uraniumtetrafluoride", 1440), //Fluid input (slot 1) + null, //Fluid output (slot 2) + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("dustUraniumTetrafluoride", 10), + UtilsItems.getItemStackOfAmountFromOreDictNoBroken("cellEmpty", 10) + }, //Output Array of Items - Upto 9, + new int[]{0}, + 150*20, //Time in ticks 2000); //EU }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} - + try { + + CORE.RA.addDehydratorRecipe( + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("cellWater", 10) + }, //Item input (Array, up to 2) + FluidUtils.getFluidStack("uraniumhexafluoride", 1440), //Fluid input (slot 1) + null, //Fluid output (slot 2) + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("dustUraniumHexafluoride", 10), + UtilsItems.getItemStackOfAmountFromOreDictNoBroken("cellEmpty", 10) + }, //Output Array of Items - Upto 9, + new int[]{0}, + 300*20, //Time in ticks + 4000); //EU + + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + try { + + CORE.RA.addDehydratorRecipe( + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("cropGrape", 1) + }, //Item input (Array, up to 2) + null, //Fluid input (slot 1) + null, //Fluid output (slot 2) + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("foodRaisins", 1) + }, //Output Array of Items - Upto 9, + new int[]{0}, + 10*20, //Time in ticks + 8); //EU + + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + } private static void assemblerRecipes(){ @@ -176,9 +226,9 @@ public class RECIPES_GREGTECH { GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketFire_water", 0, 1), null, 120, 0); GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketHootch", 0, 1), null, 36, 0); - - - + + + //CORE.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); GT_Values.RA.addFuel(UtilsItems.getSimpleStack(Items.lava_bucket), null, 32, 2); GT_Values.RA.addFuel(UtilsItems.getIC2Cell(2), null, 32, 2); @@ -202,6 +252,16 @@ public class RECIPES_GREGTECH { chances, 30*20, 240); + + GT_Values.RA.addChemicalBathRecipe( + UtilsItems.getItemStackOfAmountFromOreDict("dustLithiumCarbonate", 10), + FluidUtils.getFluidStack("hydrofluoricacid", 20000), + UtilsItems.getItemStackOfAmountFromOreDict("dustLithiumFluoride", 5), + null, + null, + new int[]{}, + 90*20, + 500); } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 2f57dc4c81..5d1a4cc353 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -13,10 +13,10 @@ import net.minecraft.item.ItemStack; public class RECIPES_General { static ItemStack RECIPE_Paper = UtilsItems.getSimpleStack(Items.paper); - static ItemStack RECIPE_LapisDust = UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustLazurite", 2); + static String RECIPE_LapisDust = "dustLazurite"; static ItemStack OUTPUT_Blueprint = UtilsItems.getSimpleStack(ModItems.itemBlueprintBase); static ItemStack RECIPE_CraftingTable = UtilsItems.getSimpleStack(Item.getItemFromBlock(Blocks.crafting_table)); - static ItemStack RECIPE_BronzePlate = UtilsItems.getItemStackOfAmountFromOreDictNoBrokenExcluding("ic2", "plateAnyBronze", 1); + static String RECIPE_BronzePlate = "plateAnyBronze"; static ItemStack RECIPE_BasicCasingIC2; static ItemStack OUTPUT_Workbench_Bronze = UtilsItems.getSimpleStack(Item.getItemFromBlock(ModBlocks.blockWorkbench)); static ItemStack NULL = null; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 96f2cbcfcf..3b876e6d93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -37,19 +37,33 @@ public interface IGregtech_RecipeAdder { /** - * Adds a Recipe for the Sifter. (up to 9 Outputs) + * Adds a Recipe for the Dehydrator. (up to 9 Outputs) * - * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aInput = Input itemstack (not null, and respects StackSize) * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aOutputItems = Itemstack[] (not null, and respects StackSize) * @param aDuration = Duration (must be >= 0) * @param aEUt = EU needed for heating up (must be >= 0) * @return true if the Recipe got added, otherwise false. */ - - /*public boolean addDehydratorRecipe(FluidStack aFluid, FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int aEUt); + public boolean addDehydratorRecipe(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutputItems, int aDuration, int aEUt); - public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt); + /*public boolean addDehydratorRecipe(FluidStack aFluid, FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int aEUt);*/ + /*public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt); public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, FluidStack aFluid, ItemStack[] aOutputItems, FluidStack aOutputFluid, int aDuration, int aEUt);*/ + + /** + * Adds a Recipe for the Dehydrator. (up to 9 Outputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aOutputItems = ItemStack[] (not null, and respects StackSize) + * @param aChances = Output Change (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ public boolean addDehydratorRecipe(ItemStack[] aInput, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack[] aOutputItems, int[] aChances, int aDuration, int aEUt); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java index 0f4a9f522c..c5b8985396 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java @@ -46,7 +46,7 @@ public class CasingTextureHandler { return TexturesGtBlocks.Casing_Machine_Dimensional_Adv.getIcon(); //Iron Blast Fuance Textures case 10: - return TexturesGtBlocks.Casing_Machine_Simple.getIcon(); + return TexturesGtBlocks.Casing_Machine_Simple_Top.getIcon(); //Multitank Exterior Casing case 11: return Textures.BlockIcons.MACHINE_CASING_GRATE.getIcon(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java index 672fc58ff7..e82355ae8c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java @@ -56,8 +56,17 @@ public class TexturesGtBlocks { //Machine Casings - private static final CustomIcon Internal_Casing_Machine_Simple = new CustomIcon("TileEntities/machine_top"); - public static final CustomIcon Casing_Machine_Simple = Internal_Casing_Machine_Simple; + //Simple + private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); + public static final CustomIcon Casing_Machine_Simple_Top = Internal_Casing_Machine_Simple_Top; + private static final CustomIcon Internal_Casing_Machine_Simple_Bottom = new CustomIcon("TileEntities/machine_bottom"); + public static final CustomIcon Casing_Machine_Simple_Bottom = Internal_Casing_Machine_Simple_Bottom; + //Advanced and Ultra + private static final CustomIcon Internal_Casing_Machine_Advanced = new CustomIcon("TileEntities/high_adv_machine"); + public static final CustomIcon Casing_Machine_Advanced = Internal_Casing_Machine_Advanced; + private static final CustomIcon Internal_Casing_Machine_Ultra = new CustomIcon("TileEntities/adv_machine_lesu"); + public static final CustomIcon Casing_Machine_Ultra = Internal_Casing_Machine_Ultra; + //Dimensional - Non Overlay private static final CustomIcon Internal_Casing_Machine_Dimensional = new CustomIcon("TileEntities/adv_machine_dimensional"); public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = new CustomIcon("TileEntities/high_adv_machine_dimensional"); @@ -78,25 +87,34 @@ public class TexturesGtBlocks { public static final CustomIcon Casing_Material_Zeron100 = Internal_Casing_Zeron100; private static final CustomIcon Internal_Casing_Potin = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_POTIN"); public static final CustomIcon Casing_Material_Potin = Internal_Casing_Potin; - - //Misc Casings - private static final CustomIcon Internal_Casing_Machine_Sound = new CustomIcon("TileEntities/audio_out"); - public static final CustomIcon Casing_Machine_Sound = Internal_Casing_Machine_Sound; - private static final CustomIcon Internal_Casing_Machine_Sound_Active = new CustomIcon("TileEntities/audio_out_active"); - public static final CustomIcon Casing_Machine_Sound_Active = Internal_Casing_Machine_Sound_Active; - + //Misc Casings private static final CustomIcon Internal_Casing_Machine_Redstone_Off = new CustomIcon("TileEntities/cover_redstone_conductor"); public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; private static final CustomIcon Internal_Casing_Machine_Redstone_On = new CustomIcon("TileEntities/cover_redstone_emitter"); public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; - private static final CustomIcon Internal_Casing_Machine_Vent = new CustomIcon("TileEntities/machine_top_vent_rotating"); - public static final CustomIcon Casing_Machine_Vent = Internal_Casing_Machine_Vent; - private static final CustomIcon Internal_Casing_Machine_Vent_Fast = new CustomIcon("TileEntities/machine_top_vent_rotating_fast"); - public static final CustomIcon Casing_Machine_Vent_Fast = Internal_Casing_Machine_Vent_Fast; - private static final CustomIcon Internal_Casing_Machine_Vent_Adv = new CustomIcon("TileEntities/adv_machine_vent_rotating"); - public static final CustomIcon Casing_Machine_Vent_Adv = Internal_Casing_Machine_Vent_Adv; - + //Overlays + //Fan Textures + private static final CustomIcon Internal_Overlay_Machine_Vent = new CustomIcon("TileEntities/machine_top_vent_rotating"); + public static final CustomIcon Overlay_Machine_Vent = Internal_Overlay_Machine_Vent; + private static final CustomIcon Internal_Overlay_Machine_Vent_Fast = new CustomIcon("TileEntities/machine_top_vent_rotating_fast"); + public static final CustomIcon Overlay_Machine_Vent_Fast = Internal_Overlay_Machine_Vent_Fast; + private static final CustomIcon Internal_Overlay_Machine_Vent_Adv = new CustomIcon("TileEntities/adv_machine_vent_rotating"); + public static final CustomIcon Overlay_Machine_Vent_Adv = Internal_Overlay_Machine_Vent_Adv; + //Speaker Texture + private static final CustomIcon Internal_Overlay_Machine_Sound = new CustomIcon("TileEntities/audio_out"); + public static final CustomIcon Overlay_Machine_Sound = Internal_Overlay_Machine_Sound; + private static final CustomIcon Internal_Overlay_Machine_Sound_Active = new CustomIcon("TileEntities/audio_out_active"); + public static final CustomIcon Overlay_Machine_Sound_Active = Internal_Overlay_Machine_Sound_Active; + //Diesel Engines + private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical = new CustomIcon("TileEntities/machine_top_dieselmotor"); + public static final CustomIcon Overlay_Machine_Diesel_Vertical = Internal_Overlay_Machine_Diesel_Vertical; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal = new CustomIcon("TileEntities/machine_top_dieselmotor2"); + public static final CustomIcon Overlay_Machine_Diesel_Horizontal = Internal_Overlay_Machine_Diesel_Horizontal; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical_Active = new CustomIcon("TileEntities/machine_top_dieselmotor_active"); + public static final CustomIcon Overlay_Machine_Diesel_Vertical_Active = Internal_Overlay_Machine_Diesel_Vertical_Active; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal_Active = new CustomIcon("TileEntities/machine_top_dieselmotor2_active"); + public static final CustomIcon Overlay_Machine_Diesel_Horizontal_Active = Internal_Overlay_Machine_Diesel_Horizontal_Active; //Computer Screens private static final CustomIcon Internal_Casing_Machine_Screen_1 = new CustomIcon("TileEntities/adv_machine_screen_random1"); public static final CustomIcon Casing_Machine_Screen_1 = Internal_Casing_Machine_Screen_1; @@ -106,12 +124,26 @@ public class TexturesGtBlocks { public static final CustomIcon Casing_Machine_Screen_3 = Internal_Casing_Machine_Screen_3; private static final CustomIcon Internal_Casing_Machine_Screen_Frequency = new CustomIcon("TileEntities/adv_machine_screen_frequency"); public static final CustomIcon Casing_Machine_Screen_Frequency = Internal_Casing_Machine_Screen_Frequency; - - //Overlays + private static final CustomIcon Internal_Overlay_Machine_Screen_Logo = new CustomIcon("TileEntities/adv_machine_screen_logo"); + public static final CustomIcon Overlay_Machine_Screen_Logo = Internal_Overlay_Machine_Screen_Logo; + //Crafting Overlays private static final CustomIcon Internal_Overlay_Crafting_Bronze = new CustomIcon("TileEntities/bronze_top_crafting"); public static final CustomIcon Overlay_Crafting_Bronze = Internal_Overlay_Crafting_Bronze; private static final CustomIcon Internal_Overlay_Crafting_Steel = new CustomIcon("TileEntities/cover_crafting"); public static final CustomIcon Overlay_Crafting_Steel = Internal_Overlay_Crafting_Steel; - + //Dimensional + private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); + public static final CustomIcon Overlay_Machine_Dimensional_Blue = Internal_Overlay_Machine_Dimensional_Blue; + private static final CustomIcon Internal_Overlay_Machine_Dimensional_Orange = new CustomIcon("TileEntities/adv_machine_dimensional_cover_orange"); + public static final CustomIcon Overlay_Machine_Dimensional_Orange = Internal_Overlay_Machine_Dimensional_Orange; + //Icons + private static final CustomIcon Internal_Overlay_MatterFab = new CustomIcon("TileEntities/adv_machine_matterfab"); + public static final CustomIcon Overlay_MatterFab = Internal_Overlay_MatterFab; + private static final CustomIcon Internal_Overlay_MatterFab_Active = new CustomIcon("TileEntities/adv_machine_matterfab_active"); + public static final CustomIcon Overlay_MatterFab_Active = Internal_Overlay_MatterFab_Active; + private static final CustomIcon Internal_Overlay_Oil = new CustomIcon("TileEntities/adv_machine_oil"); + public static final CustomIcon Overlay_Oil = Internal_Overlay_Oil; + private static final CustomIcon Internal_Overlay_UU_Matter = new CustomIcon("TileEntities/adv_machine_uum"); + public static final CustomIcon Overlay_UU_Matter = Internal_Overlay_UU_Matter; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java index a84ba6d249..b68fb7155c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java @@ -11,6 +11,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenera import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.registry.GameRegistry; @@ -76,12 +77,12 @@ extends GT_MetaTileEntity_BasicGenerator @Override public ITexture[] getFront(byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; } @Override public ITexture[] getBack(byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP)}; + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Diesel_Vertical)}; } @Override @@ -101,12 +102,12 @@ extends GT_MetaTileEntity_BasicGenerator @Override public ITexture[] getFrontActive(byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; } @Override public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE)}; + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Diesel_Vertical_Active)}; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index 892f573add..f3bff0c2f4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -21,7 +21,7 @@ public class GregtechMetaTileEntityRocketFuelGenerator public int mEfficiency; public GregtechMetaTileEntityRocketFuelGenerator(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires liquid Fuel", new ITexture[0]); + super(aID, aName, aNameRegional, aTier, "Requires two liquid Fuels. Fuel A is Fastburn, Fuel B is slowburn.", new ITexture[0]); onConfigLoad(); } @@ -67,20 +67,36 @@ public class GregtechMetaTileEntityRocketFuelGenerator } return rValue; } + + private GT_RenderedTexture getCasingTexture(){ + if (this.mTier <= 4){ + return new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Top); + } + else if (this.mTier == 5){ + + return new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Advanced); + } + else if (this.mTier >= 6){ + + return new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Ultra); + } + return new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Top); + } + @Override public ITexture[] getFront(byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + return new ITexture[]{super.getFront(aColor)[0], getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; } @Override public ITexture[] getBack(byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Vent)}; + return new ITexture[]{super.getBack(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Vent)}; } @Override public ITexture[] getBottom(byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple)}; + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Bottom)}; } @Override @@ -90,22 +106,22 @@ public class GregtechMetaTileEntityRocketFuelGenerator @Override public ITexture[] getSides(byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Sound)}; + return new ITexture[]{super.getSides(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Diesel_Horizontal)}; } @Override public ITexture[] getFrontActive(byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + return new ITexture[]{super.getFrontActive(aColor)[0], getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; } @Override public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Vent_Fast)}; + return new ITexture[]{super.getBackActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Vent_Fast)}; } @Override public ITexture[] getBottomActive(byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple)}; + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Bottom)}; } @Override @@ -115,6 +131,6 @@ public class GregtechMetaTileEntityRocketFuelGenerator @Override public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Sound_Active)}; + return new ITexture[]{super.getSidesActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Diesel_Horizontal_Active)}; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java index 5ac474e844..f15757491c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java @@ -25,7 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntityIronBlastFurnace extends MetaTileEntity { - private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple)}; + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Top)}; private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_Off)}; private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_On)}; public int mMaxProgresstime = 0; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index 6374a5f36a..4b0cf94032 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -12,7 +12,7 @@ import net.minecraftforge.fluids.FluidStack; public class GregtechRecipeAdder implements IGregtech_RecipeAdder { - + @Override public boolean addCokeOvenRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput, int aDuration, int aEUt) { @@ -66,7 +66,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { return false; } } - + @Override public boolean addMatterFabricatorRecipe(FluidStack aFluidInput, FluidStack aFluidOutput, int aDuration, int aEUt) { try { @@ -80,7 +80,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } catch (NullPointerException e){e.getStackTrace();} try{ - + //RECIPEHANDLER_MatterFabricator.debug4(aFluidInput, aFluidOutput, aDuration, aEUt); if (aFluidInput == null){ //Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, null, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); @@ -107,13 +107,13 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addFuel(ItemStack aInput1, ItemStack aOutput1, int aEU, int aType) { - if (aInput1 == null) { - Utils.LOG_INFO("Fuel Input is Invalid."); - return false; - } - //new GregtechRecipe(aInput1, aOutput1, GregTech_API.sRecipeFile.get("fuel_" + aType, aInput1, aEU), aType); - return true; - } + if (aInput1 == null) { + Utils.LOG_INFO("Fuel Input is Invalid."); + return false; + } + //new GregtechRecipe(aInput1, aOutput1, GregTech_API.sRecipeFile.get("fuel_" + aType, aInput1, aEU), aType); + return true; + } /*@Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, FluidStack aFluid, ItemStack[] aOutputItems, FluidStack aOutputFluid, int aDuration, int aEUt) { @@ -132,7 +132,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } return false; } - + @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt) { if ((aItemA == null) || (aItemB == null) || (aOutputItems == null)) { @@ -145,20 +145,9 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, null, null, aOutputItems, aDuration, aEUt); return true; } - - @Override - public boolean addDehydratorRecipe(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutput, int aDuration, int aEUt) { - if ((aInput == null) || (aFluid == null) || (aOutput == null)) { - return false; - } - if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aInput, aDuration)) <= 0) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, new ItemStack[]{aInput}, aOutput, null, new FluidStack[]{aFluid}, null, aDuration, aEUt, 0); - RECIPEHANDLER_Dehydrator.debug5(aInput, null, aFluid, null, aOutput, aDuration, aEUt); - return true; - } - + + + @Override public boolean addDehydratorRecipe(FluidStack aFluid, FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int aEUt){ if ((aFluid == null) || (aOutputFluid == null || aOutputItems == null)) { @@ -171,64 +160,85 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { RECIPEHANDLER_Dehydrator.debug5(null, null, aFluid, aOutputFluid, aOutputItems, aDuration, aEUt); return true; }*/ - - - - + + + @Override + public boolean addDehydratorRecipe(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutput, int aDuration, int aEUt) { + Utils.LOG_INFO("Trying to add a Dehydrator recipe."); + try{ + if ((aInput == null) || (aFluid == null) || (aOutput == null)) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aInput, aDuration)) <= 0) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, new ItemStack[]{aInput}, aOutput, null, new FluidStack[]{aFluid}, null, aDuration, aEUt, 0); + //RECIPEHANDLER_Dehydrator.debug5(aInput, null, aFluid, null, aOutput, aDuration, aEUt); + return true; + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");return false;} + } + + + + @Override - public boolean addDehydratorRecipe(ItemStack[] aInput, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack[] aOutputItems, int[] aChances, int aDuration, int aEUt) { + public boolean addDehydratorRecipe(ItemStack[] aInput, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack[] aOutputItems, int[] aChances, int aDuration, int aEUt) throws IndexOutOfBoundsException{ Utils.LOG_INFO("Trying to add a Dehydrator recipe."); - if (aInput[0] != null){ - Utils.LOG_INFO("Recipe requires input: "+aInput[0].getDisplayName()+" x"+aInput[0].stackSize); - } - if (aInput[1] != null){ - Utils.LOG_INFO("Recipe requires input: "+aInput[1].getDisplayName()+" x"+aInput[1].stackSize); - } - if (aFluidInput != null){ - Utils.LOG_INFO("Recipe requires input: "+aFluidInput.getFluid().getName()+" "+aFluidInput.amount+"mbst"); - } + try{ + if (aInput[0] != null){ + Utils.LOG_INFO("Recipe requires input: "+aInput[0].getDisplayName()+" x"+aInput[0].stackSize); + } + if (aInput.length > 1){ + if (aInput[1] != null){ + Utils.LOG_INFO("Recipe requires input: "+aInput[1].getDisplayName()+" x"+aInput[1].stackSize); + } + } + if (aFluidInput != null){ + Utils.LOG_INFO("Recipe requires input: "+aFluidInput.getFluid().getName()+" "+aFluidInput.amount+"mbst"); + } if (((aInput[0] == null) && (aFluidInput == null)) || ((aOutputItems == null) && (aFluidOutput == null))) { - return false; - } - if ((aOutputItems != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aOutputItems[0], aDuration)) <= 0)) { - return false; - } - if (aOutputItems != null){ - Utils.LOG_INFO("Recipe will output: "+UtilsItems.getArrayStackNames(aOutputItems)); - } - if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - return false; - } - if (aFluidOutput != null){ - Utils.LOG_INFO("Recipe will output: "+aFluidOutput.getFluid().getName()); - } - - - - if (aInput[1] == null){ - Utils.LOG_INFO("Dehydrator recipe only has a single input item."); - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); - - } - else { - Utils.LOG_INFO("Dehydrator recipe has two input items."); - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); - - } - - return true; - } - - - - - - - - - - - - + return false; + } + if ((aOutputItems != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aOutputItems[0], aDuration)) <= 0)) { + return false; + } + if (aOutputItems != null){ + Utils.LOG_INFO("Recipe will output: "+UtilsItems.getArrayStackNames(aOutputItems)); + } + if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { + return false; + } + if (aFluidOutput != null){ + Utils.LOG_INFO("Recipe will output: "+aFluidOutput.getFluid().getName()); + } + + + + if (aInput.length == 1){ + Utils.LOG_INFO("Dehydrator recipe only has a single input item."); + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); + + } + else { + Utils.LOG_INFO("Dehydrator recipe has two input items."); + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); + + } + + return true; + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");return false;} + } + + + + + + + + + + + + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java index cd9cb88f44..33dfb60e3f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java @@ -40,7 +40,7 @@ public class GregtechDehydrator GregtechItemList.GT_Dehydrator_EV.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe( 813, "advancedmachine.dehydrator.tier.01", "Chemical Dehydrator I", 4, - "Remind Alkalus to add something here."+CORE.GT_Tooltip, + "This dehydrates your Grapes into Raisins. "+CORE.GT_Tooltip, Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes, 2, 9, 10000, @@ -52,7 +52,7 @@ public class GregtechDehydrator null).getStackForm(1L)); GregtechItemList.GT_Dehydrator_IV.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe( 814, "advancedmachine.dehydrator.tier.02", "Chemical Dehydrator II", 5, - "Remind Alkalus to add something here."+CORE.GT_Tooltip, + "A hangover is the way your body reacts to dehydration. "+CORE.GT_Tooltip, Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes, 2, 9, 10000, @@ -64,7 +64,7 @@ public class GregtechDehydrator null).getStackForm(1L)); GregtechItemList.GT_Dehydrator_LuV.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe( 815, "advancedmachine.dehydrator.tier.03", "Chemical Dehydrator III", 6, - "Remind Alkalus to add something here."+CORE.GT_Tooltip, + "You could probably make space icecream with this.. "+CORE.GT_Tooltip, Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes, 2, 9, 10000, @@ -76,7 +76,7 @@ public class GregtechDehydrator null).getStackForm(1L)); GregtechItemList.GT_Dehydrator_ZPM.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe( 816, "advancedmachine.dehydrator.tier.04", "Chemical Dehydrator IV", 7, - "Remind Alkalus to add something here."+CORE.GT_Tooltip, + "You can definitely make space icecream with this.. "+CORE.GT_Tooltip, Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes, 2, 9, 10000, -- cgit From 6105925bfec6d55b22a88e89e6d9e2549390bd86 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 24 Oct 2016 04:31:24 +1000 Subject: + Added nice new textures to the energy buffers. + Added Subscript integers to Chemical Formulas. --- src/Java/gtPlusPlus/core/material/Material.java | 4 +- .../implementations/GregtechMetaEnergyBuffer.java | 87 ++++++++++++++++++++-- 2 files changed, 82 insertions(+), 9 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 16cccc9660..44a8c021f9 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -4,6 +4,7 @@ import static gregtech.api.enums.GT_Values.M; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.math.MathUtils; import java.util.ArrayList; @@ -453,7 +454,8 @@ public class Material { dummyFormula = dummyFormula+""; } } - return dummyFormula; + return MaterialUtils.subscript(dummyFormula); + //return dummyFormula; } Utils.LOG_INFO("dummyFormulaArray <= 0"); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java index 45f05f4495..f797b92935 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java @@ -14,6 +14,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; import ic2.api.item.IElectricItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -47,7 +48,81 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { /* * MACHINE_STEEL_SIDE */ - @Override + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = getFront(i); + rTextures[1][i + 1] = getBack(i); + rTextures[2][i + 1] = getBottom(i); + rTextures[3][i + 1] = getTop(i); + rTextures[4][i + 1] = getSides(i); + rTextures[5][i + 1] = getFrontActive(i); + rTextures[6][i + 1] = getBackActive(i); + rTextures[7][i + 1] = getBottomActive(i); + rTextures[8][i + 1] = getTopActive(i); + rTextures[9][i + 1] = getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + + public ITexture[] getBack(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getTop(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Screen_Logo)}; + } + + + public ITexture[] getSides(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Screen_Logo)}; + } + + + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + } + + /*@Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[2][17][]; for (byte i = -1; i < 16; i++) { @@ -60,7 +135,7 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; } return rTextures; - } + }*/ /* * @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { @@ -84,10 +159,10 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { * } return rTextures; } */ - @Override + /*@Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; - } + }*/ @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -313,10 +388,6 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { return 0; } - @Override - public void markDirty() { - } - @Override public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { return false; -- cgit From ffa66d97ddb837817948a1048de41674ba450cfd Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 24 Oct 2016 15:24:33 +1000 Subject: $ Fixed the getItemStackInPlayersHand method, now it has variable server/client versions, all with various constructors. (World/String/UUID) - Closes #31 % Moved a heap of Code to separate Utils classes. --- .../core/block/machine/Machine_Workbench.java | 4 +- .../block/machine/Machine_WorkbenchAdvanced.java | 6 +- src/Java/gtPlusPlus/core/commands/CommandMath.java | 3 +- .../core/handler/events/LoginEventHandler.java | 3 +- .../events/PickaxeBlockBreakEventHandler.java | 5 +- .../core/item/base/BaseItemComponent.java | 4 +- .../core/item/base/dusts/BaseItemDust.java | 3 +- .../core/item/base/dusts/BaseItemDustUnique.java | 3 +- .../core/item/base/ingots/BaseItemIngot.java | 3 +- .../core/item/base/itemblock/ItemBlockGtBlock.java | 4 +- .../core/item/general/ItemBlueprint.java | 5 +- .../core/item/general/ItemHealingDevice.java | 5 +- src/Java/gtPlusPlus/core/util/Utils.java | 90 --------------- .../gtPlusPlus/core/util/entity/EntityUtils.java | 68 +++++++++++ src/Java/gtPlusPlus/core/util/item/UtilsItems.java | 29 +---- .../gtPlusPlus/core/util/player/PlayerUtils.java | 128 +++++++++++++++++++++ .../implementations/GregtechMetaEnergyBuffer.java | 3 +- .../base/machines/GregtechMetaSafeBlockBase.java | 5 +- .../GT_MetaTileEntity_TesseractGenerator.java | 5 +- .../GT_MetaTileEntity_TesseractTerminal.java | 5 +- ...GregtechMetaTileEntityIndustrialCentrifuge.java | 3 +- 21 files changed, 239 insertions(+), 145 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/util/entity/EntityUtils.java create mode 100644 src/Java/gtPlusPlus/core/util/player/PlayerUtils.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 9ac81bffe4..22536aa19b 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -5,7 +5,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.player.PlayerUtils; import ic2.core.item.tool.ItemToolWrench; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -70,7 +70,7 @@ public class Machine_Workbench extends BlockContainer { if (world.isRemote) return true; - ItemStack heldItem = UtilsItems.getItemStackInPlayersHand(); + ItemStack heldItem = PlayerUtils.getItemStackInPlayersHand(); boolean holdingWrench = false; if (heldItem != null){ diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java index ce09ddab59..2f061ea298 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java @@ -5,7 +5,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.player.PlayerUtils; import ic2.core.item.tool.ItemToolWrench; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -68,9 +68,9 @@ public class Machine_WorkbenchAdvanced extends BlockContainer @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) { - if (world.isRemote) return true; - ItemStack heldItem = UtilsItems.getItemStackInPlayersHand(); + ItemStack heldItem = PlayerUtils.getItemStackInPlayersHand(player); + if (world.isRemote) return true; boolean holdingWrench = false; if (heldItem != null){ diff --git a/src/Java/gtPlusPlus/core/commands/CommandMath.java b/src/Java/gtPlusPlus/core/commands/CommandMath.java index 2a726dd8b1..01091d84e3 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandMath.java +++ b/src/Java/gtPlusPlus/core/commands/CommandMath.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.commands; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; import java.util.ArrayList; import java.util.List; @@ -101,7 +102,7 @@ public class CommandMath implements ICommand } } catch(NullPointerException e) { - Utils.messagePlayer(P, "You do not have a spawn, so..."); + PlayerUtils.messagePlayer(P, "You do not have a spawn, so..."); } if (Y == null || Y.equals(null)) { Y = W.getSpawnPoint(); diff --git a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java index 1db26846c7..e529d47699 100644 --- a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java @@ -3,6 +3,7 @@ package gtPlusPlus.core.handler.events; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerCache; +import gtPlusPlus.core.util.player.PlayerUtils; import java.util.UUID; @@ -37,7 +38,7 @@ public class LoginEventHandler { Utils.LOG_INFO("You're not using the latest recommended version of GT++, consider updating."); Utils.LOG_INFO("Latest version is: "+CORE.MASTER_VERSION); Utils.LOG_INFO("You currently have: "+CORE.VERSION); - Utils.messagePlayer(localPlayerRef, "You're not using the latest recommended version of GT++, consider updating."); + PlayerUtils.messagePlayer(localPlayerRef, "You're not using the latest recommended version of GT++, consider updating."); } else { Utils.LOG_INFO("You're using the latest recommended version of GT++."); diff --git a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java index a7c689a79a..49b844f057 100644 --- a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java @@ -5,6 +5,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.BaseTileEntity; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase; import java.util.UUID; @@ -42,12 +43,12 @@ public class PickaxeBlockBreakEventHandler { Utils.LOG_INFO("UUID info. Accessor: "+accessorUUID + " | Owner: "+ownerUUID); if (accessorUUID == ownerUUID){ - Utils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed."); + PlayerUtils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed."); event.setCanceled(false); } else { event.setCanceled(true); - Utils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed."); + PlayerUtils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed."); } // } diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 02f8f63175..7ee08cabee 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -4,7 +4,7 @@ import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.item.UtilsItems; import java.util.List; @@ -107,7 +107,7 @@ public class BaseItemComponent extends Item{ @Override public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(componentMaterial.vRadioationLevel, world, entityHolding); + EntityUtils.applyRadiationDamageToEntity(componentMaterial.vRadioationLevel, world, entityHolding); } diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java index 7638da6f0a..f199f87f68 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -7,6 +7,7 @@ import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; @@ -93,7 +94,7 @@ public class BaseItemDust extends Item{ protected final int sRadiation; @Override public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + EntityUtils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); } @Override diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java index 78067e48c7..77e0b7324b 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java @@ -4,6 +4,7 @@ import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; @@ -82,7 +83,7 @@ public class BaseItemDustUnique extends Item{ protected final int sRadiation; @Override public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + EntityUtils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); } @Override diff --git a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java index e193636043..d58522756f 100644 --- a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java +++ b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java @@ -5,6 +5,7 @@ import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; @@ -113,6 +114,6 @@ public class BaseItemIngot extends Item{ protected final int sRadiation; @Override public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + EntityUtils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); } } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java index ed21b3642a..cd89b027d0 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java @@ -3,7 +3,7 @@ package gtPlusPlus.core.item.base.itemblock; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.block.base.BlockBaseModular; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.item.UtilsItems; import java.util.List; @@ -47,7 +47,7 @@ public class ItemBlockGtBlock extends ItemBlock{ @Override public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { - Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + EntityUtils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); } } diff --git a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java index 4323a39307..efecb03d9f 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java @@ -6,6 +6,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.player.PlayerUtils; import java.util.List; @@ -86,11 +87,11 @@ public class ItemBlueprint extends Item implements IItemBlueprint{ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) { //Let the player know what blueprint is held if (itemStack.hasTagCompound()) { - Utils.messagePlayer(par3Entity, "This Blueprint holds NBT data. "+"|"+getNBT(itemStack, "mID")+"|"+getNBT(itemStack, "mBlueprint")+"|"+getNBT(itemStack, "mName")+"|"+UtilsItems.getArrayStackNames(readItemsFromNBT(itemStack))); + PlayerUtils.messagePlayer(par3Entity, "This Blueprint holds NBT data. "+"|"+getNBT(itemStack, "mID")+"|"+getNBT(itemStack, "mBlueprint")+"|"+getNBT(itemStack, "mName")+"|"+UtilsItems.getArrayStackNames(readItemsFromNBT(itemStack))); } else { createNBT(itemStack); - Utils.messagePlayer(par3Entity, "This is a placeholder. "+getNBT(itemStack, "mID")); + PlayerUtils.messagePlayer(par3Entity, "This is a placeholder. "+getNBT(itemStack, "mID")); } diff --git a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java index 5e05221ed7..aa67e0f10c 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java @@ -5,6 +5,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.player.PlayerUtils; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; @@ -220,8 +221,8 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI Utils.LOG_INFO("rx:"+rx); arg1.heal(rx*2); discharge(arg0, (1638400/4)*rx, 6, true, true, false); - Utils.messagePlayer((EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger. It Healed "+rx+" hp."); - Utils.messagePlayer((EntityPlayer) arg1, "You check it's remaining uses, it has "+secondsLeft(arg0)+"."); + PlayerUtils.messagePlayer((EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger. It Healed "+rx+" hp."); + PlayerUtils.messagePlayer((EntityPlayer) arg1, "You check it's remaining uses, it has "+secondsLeft(arg0)+"."); } } } diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index cdfa556de9..93621200ab 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -8,10 +8,8 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; -import ic2.core.IC2Potion; import ic2.core.Ic2Items; import ic2.core.init.InternalName; -import ic2.core.item.armor.ItemArmorHazmat; import ic2.core.item.resources.ItemCell; import java.awt.Color; @@ -24,21 +22,12 @@ import java.util.List; import java.util.Map; import java.util.Timer; import java.util.TimerTask; -import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -49,7 +38,6 @@ import org.apache.commons.lang3.EnumUtils; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.registry.EntityRegistry; public class Utils { @@ -169,11 +157,6 @@ public class Utils { return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage())); } - //TODO - public static void registerEntityToBiomeSpawns(Class classy, EnumCreatureType EntityType, BiomeGenBase baseBiomeGen){ - EntityRegistry.addSpawn(classy, 6, 1, 5, EntityType, baseBiomeGen); //change the values to vary the spawn rarity, biome, etc. - } - //Non-Dev Comments public static void LOG_INFO(String s){ //if (CORE.DEBUG){ @@ -206,10 +189,6 @@ public class Utils { g.drawRect (MinA, MinB, MaxA, MaxB); } - public static void messagePlayer(EntityPlayer P, String S){ - gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); - } - /** * Returns if that Liquid is IC2Steam. */ @@ -337,53 +316,6 @@ public class Utils { return targetList; } - public static EntityPlayer getPlayerOnServerFromUUID(UUID parUUID){ - if (parUUID == null) - { - return null; - } - List allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayerMP player : allPlayers) - { - if (player.getUniqueID().equals(parUUID)) - { - return player; - } - } - return null; - } - - @Deprecated - public static Block findBlockUnderEntityNonBoundingBox(Entity parEntity){ - int blockX = MathHelper.floor_double(parEntity.posX); - int blockY = MathHelper.floor_double(parEntity.posY-0.2D - (double)parEntity.yOffset); - int blockZ = MathHelper.floor_double(parEntity.posZ); - return parEntity.worldObj.getBlock(blockX, blockY, blockZ); - } - - public static Block findBlockUnderEntity(Entity parEntity){ - int blockX = MathHelper.floor_double(parEntity.posX); - int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1; - int blockZ = MathHelper.floor_double(parEntity.posZ); - return parEntity.worldObj.getBlock(blockX, blockY, blockZ); - } - - public static int getFacingDirection(Entity entity){ - int d = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360) + 0.50) & 3; - return d; - } - - public static boolean isPlayerOP(EntityPlayer player){ - if (player.canCommandSenderUseCommand(2, "")){ - return true; - } - return false; - } - - public static void setEntityOnFire(Entity entity, int length){ - entity.setFire(length); - } - public static void spawnCustomParticle(Entity entity){ GTplusplus.proxy.generateMysteriousParticles(entity); } @@ -537,28 +469,6 @@ public class Utils { return true; } - public static boolean applyRadiationDamageToEntity(int damage, World world, Entity entityHolding){ - if (!world.isRemote){ - if (damage > 0 && (entityHolding instanceof EntityLivingBase)) { - EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; - if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) { - int duration; - if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null){ - //Utils.LOG_INFO("t"); - duration = (damage*5)+entityLiving.getActivePotionEffect(IC2Potion.radiation).getDuration(); - } - else { - //Utils.LOG_INFO("f"); - duration = damage*30; - } - IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); - } - } - return true; - } - return false; - } - private static short cellID = 15; public static ItemStack createInternalNameAndFluidCell(String s){ Utils.LOG_WARNING("1"); diff --git a/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java new file mode 100644 index 0000000000..21d31a42ee --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java @@ -0,0 +1,68 @@ +package gtPlusPlus.core.util.entity; + +import ic2.core.IC2Potion; +import ic2.core.item.armor.ItemArmorHazmat; +import cpw.mods.fml.common.registry.EntityRegistry; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class EntityUtils { + + public static void setEntityOnFire(Entity entity, int length){ + entity.setFire(length); + } + + public static int getFacingDirection(Entity entity){ + int d = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360) + 0.50) & 3; + return d; + } + + @Deprecated + public static Block findBlockUnderEntityNonBoundingBox(Entity parEntity){ + int blockX = MathHelper.floor_double(parEntity.posX); + int blockY = MathHelper.floor_double(parEntity.posY-0.2D - (double)parEntity.yOffset); + int blockZ = MathHelper.floor_double(parEntity.posZ); + return parEntity.worldObj.getBlock(blockX, blockY, blockZ); + } + + public static Block findBlockUnderEntity(Entity parEntity){ + int blockX = MathHelper.floor_double(parEntity.posX); + int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1; + int blockZ = MathHelper.floor_double(parEntity.posZ); + return parEntity.worldObj.getBlock(blockX, blockY, blockZ); + } + + //TODO + public static void registerEntityToBiomeSpawns(Class classy, EnumCreatureType EntityType, BiomeGenBase baseBiomeGen){ + EntityRegistry.addSpawn(classy, 6, 1, 5, EntityType, baseBiomeGen); //change the values to vary the spawn rarity, biome, etc. + } + + public static boolean applyRadiationDamageToEntity(int damage, World world, Entity entityHolding){ + if (!world.isRemote){ + if (damage > 0 && (entityHolding instanceof EntityLivingBase)) { + EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; + if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) { + int duration; + if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null){ + //Utils.LOG_INFO("t"); + duration = (damage*5)+entityLiving.getActivePotionEffect(IC2Potion.radiation).getDuration(); + } + else { + //Utils.LOG_INFO("f"); + duration = damage*30; + } + IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); + } + } + return true; + } + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java index 41dccda796..b067be1c24 100644 --- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java +++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java @@ -41,7 +41,6 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; @@ -236,32 +235,8 @@ public class UtilsItems { return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); }*/ - - public static Item getItemInPlayersHand(){ - Minecraft mc = Minecraft.getMinecraft(); - Item heldItem = null; - - try{heldItem = mc.thePlayer.getHeldItem().getItem(); - }catch(NullPointerException e){return null;} - - if (heldItem != null){ - return heldItem; - } - - return null; - } - - public static ItemStack getItemStackInPlayersHand(){ - Minecraft mc = Minecraft.getMinecraft(); - ItemStack heldItem = null; - try{heldItem = mc.thePlayer.getHeldItem(); - }catch(NullPointerException e){return null;} - if (heldItem != null){ - return heldItem; - } - return null; - } - + + public static void generateSpawnEgg(String entityModID, String parSpawnName, int colourEgg, int colourOverlay){ Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay).setUnlocalizedName("spawn_egg_"+parSpawnName.toLowerCase()).setTextureName(CORE.MODID+":spawn_egg"); GameRegistry.registerItem(itemSpawnEgg, "spawnEgg"+parSpawnName); diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java new file mode 100644 index 0000000000..132bfe12ce --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java @@ -0,0 +1,128 @@ +package gtPlusPlus.core.util.player; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PlayerUtils { + + public static void messagePlayer(EntityPlayer P, String S){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); + } + + public static EntityPlayer getPlayer(String name){ + List i = new ArrayList(); + Iterator crunchifyIterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator(); + while (crunchifyIterator.hasNext()) { + i.add((crunchifyIterator.next())); + } + try{ + for (EntityPlayer temp : i) { + if (temp.getDisplayName().toLowerCase().equals(name.toLowerCase())){ + return temp; + } + } + } + catch(NullPointerException e){} + return null; + } + + public static EntityPlayer getPlayerOnServerFromUUID(UUID parUUID){ + if (parUUID == null) + { + return null; + } + List allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayerMP player : allPlayers) + { + if (player.getUniqueID().equals(parUUID)) + { + return player; + } + } + return null; + } + + //Not Clientside + public static EntityPlayer getPlayerInWorld(World world, String Name){ + List i = world.playerEntities; + Minecraft mc = Minecraft.getMinecraft(); + try{ + for (EntityPlayer temp : i) { + if (temp.getDisplayName().toLowerCase().equals(Name.toLowerCase())){ + return temp; + } + } + } + catch(NullPointerException e){} + return null; + } + + public static boolean isPlayerOP(EntityPlayer player){ + if (player.canCommandSenderUseCommand(2, "")){ + return true; + } + return false; + } + + //Not Clientside + public static ItemStack getItemStackInPlayersHand(World world, String Name){ + EntityPlayer thePlayer = getPlayer(Name); + ItemStack heldItem = null; + try{heldItem = thePlayer.getHeldItem(); + }catch(NullPointerException e){return null;} + if (heldItem != null){ + return heldItem; + } + return null; + } + + @SideOnly(Side.CLIENT) + public static ItemStack getItemStackInPlayersHand(){ + Minecraft mc = Minecraft.getMinecraft(); + ItemStack heldItem = null; + try{heldItem = mc.thePlayer.getHeldItem(); + }catch(NullPointerException e){return null;} + if (heldItem != null){ + return heldItem; + } + return null; + } + + @SideOnly(Side.SERVER) + public static ItemStack getItemStackInPlayersHand(EntityPlayer player){ + ItemStack heldItem = null; + try{heldItem = player.getHeldItem(); + }catch(NullPointerException e){return null;} + if (heldItem != null){ + return heldItem; + } + return null; + } + + public static Item getItemInPlayersHand(){ + Minecraft mc = Minecraft.getMinecraft(); + Item heldItem = null; + + try{heldItem = mc.thePlayer.getHeldItem().getItem(); + }catch(NullPointerException e){return null;} + + if (heldItem != null){ + return heldItem; + } + + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java index f797b92935..30634620c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java @@ -13,6 +13,7 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; import ic2.api.item.IElectricItem; @@ -233,7 +234,7 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { long tempStorage = getStoredEnergy()[0]; final double c = ((double) tempStorage / maxEUStore()) * 100; final double roundOff = Math.round(c * 100.00) / 100.00; - Utils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff+"%)"); + PlayerUtils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff+"%)"); } //Utils.LOG_WARNING("Begin Show Energy"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java index ddbc5aab96..2c43293e87 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java @@ -10,6 +10,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.handler.events.UnbreakableBlockManager; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerCache; +import gtPlusPlus.core.util.player.PlayerUtils; import java.util.UUID; @@ -222,8 +223,8 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered //Utils.LOG_WARNING("GUI should now be open for you sir."); } else { - Utils.messagePlayer(aPlayer, "Access Denied, This does not belong to you."); - Utils.messagePlayer(aPlayer, "it is owned by: "+PlayerCache.lookupPlayerByUUID(ownerUUID)); + PlayerUtils.messagePlayer(aPlayer, "Access Denied, This does not belong to you."); + PlayerUtils.messagePlayer(aPlayer, "it is owned by: "+PlayerCache.lookupPlayerByUUID(ownerUUID)); Utils.LOG_WARNING("Expecting Player : "+PlayerCache.lookupPlayerByUUID(ownerUUID)); Utils.LOG_ERROR("Access Denied."); return true; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java index dde2c6927c..42f5e67396 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java @@ -12,6 +12,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -202,8 +203,8 @@ extends GT_MetaTileEntity_BasicTank //Utils.LOG_INFO("Did not click the correct place."); break; } - Utils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); - Utils.messagePlayer(aPlayer, ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null) && (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this) ? EnumChatFormatting.RED + " (Occupied)" : "")); + PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + PlayerUtils.messagePlayer(aPlayer, ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null) && (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this) ? EnumChatFormatting.RED + " (Occupied)" : "")); } return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java index 51eb199e2a..3a2260d086 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java @@ -10,6 +10,7 @@ import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -175,8 +176,8 @@ extends GT_MetaTileEntity_BasicTank //Utils.LOG_INFO("Did not click the correct place."); break; } - Utils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); - Utils.messagePlayer(aPlayer, (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); + PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + PlayerUtils.messagePlayer(aPlayer, (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); } return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java index c76afc23be..70804e9d6e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java @@ -14,6 +14,7 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.configSwitches; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks.CustomIcon; @@ -235,7 +236,7 @@ extends GregtechMeta_MultiBlockBase { if (configSwitches.disableCentrifugeFormation){ EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(this.getBaseMetaTileEntity().getOwnerName()); if (!player.getEntityWorld().isRemote && isDisabled == false) - Utils.messagePlayer(player, "This Multiblock is disabled via the config. [Only re-enable if you're bugtesting.]"); + PlayerUtils.messagePlayer(player, "This Multiblock is disabled via the config. [Only re-enable if you're bugtesting.]"); isDisabled = true; return false; } -- cgit From 361263a1ecc79bca479d16af2fee3f30c20cefcb Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 24 Oct 2016 17:53:22 +1000 Subject: + Added the initial work for the Alloy Blast Furnace. % Renamed lots of classes. --- .../xmod/gregtech/api/gui/CONTAINER_MatterFab.java | 6 +- .../textures/TexturesCentrifugeMultiblock.java | 34 +- .../common/blocks/textures/TexturesGregtech58.java | 34 +- .../common/blocks/textures/TexturesGregtech59.java | 34 +- .../machines/multi/GregtechMTENuclearReactor.java | 287 ---------------- .../machines/multi/GregtechMTE_NuclearReactor.java | 287 ++++++++++++++++ ...GregtechMetaTileEntityIndustrialCentrifuge.java | 320 ----------------- .../GregtechMetaTileEntityIndustrialCokeOven.java | 272 --------------- ...egtechMetaTileEntityIndustrialElectrolyzer.java | 258 -------------- .../GregtechMetaTileEntityIndustrialMacerator.java | 278 --------------- ...GregtechMetaTileEntityIndustrialPlatePress.java | 204 ----------- .../GregtechMetaTileEntityIndustrialSinter.java | 263 -------------- .../GregtechMetaTileEntityIndustrialWireMill.java | 246 ------------- ...regtechMetaTileEntityIndustrial_PlatePress.java | 204 +++++++++++ .../GregtechMetaTileEntityIronBlastFurnace.java | 380 --------------------- .../GregtechMetaTileEntityMassFabricator.java | 353 ------------------- .../multi/GregtechMetaTileEntityMultiTank.java | 284 --------------- ...echMetaTileEntityPowerSubStationController.java | 189 ---------- .../GregtechMetaTileEntity_AlloyBlastFurnace.java | 214 ++++++++++++ ...regtechMetaTileEntity_IndustrialCentrifuge.java | 320 +++++++++++++++++ .../GregtechMetaTileEntity_IndustrialCokeOven.java | 272 +++++++++++++++ ...gtechMetaTileEntity_IndustrialElectrolyzer.java | 258 ++++++++++++++ ...GregtechMetaTileEntity_IndustrialMacerator.java | 278 +++++++++++++++ .../GregtechMetaTileEntity_IndustrialSinter.java | 263 ++++++++++++++ .../GregtechMetaTileEntity_IndustrialWireMill.java | 246 +++++++++++++ .../GregtechMetaTileEntity_IronBlastFurnace.java | 380 +++++++++++++++++++++ .../GregtechMetaTileEntity_MassFabricator.java | 353 +++++++++++++++++++ .../multi/GregtechMetaTileEntity_MultiTank.java | 284 +++++++++++++++ ...chMetaTileEntity_PowerSubStationController.java | 189 ++++++++++ .../gregtech/GregtechIndustrialCentrifuge.java | 4 +- .../gregtech/GregtechIndustrialCokeOven.java | 4 +- .../gregtech/GregtechIndustrialElectrolyzer.java | 4 +- .../gregtech/GregtechIndustrialMacerator.java | 4 +- .../gregtech/GregtechIndustrialMassFabricator.java | 4 +- .../gregtech/GregtechIndustrialMultiTank.java | 4 +- .../gregtech/GregtechIndustrialPlatePress.java | 4 +- .../gregtech/GregtechIndustrialSinter.java | 4 +- .../gregtech/GregtechIndustrialWiremill.java | 4 +- .../gregtech/GregtechIronBlastFurnace.java | 4 +- .../gregtech/GregtechPowerSubStation.java | 4 +- 40 files changed, 3624 insertions(+), 3410 deletions(-) delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTENuclearReactor.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialElectrolyzer.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialMacerator.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialWireMill.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrial_PlatePress.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMassFabricator.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMultiTank.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityPowerSubStationController.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastFurnace.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java index a258274f07..1c94298e09 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.api.gui; import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityMassFabricator; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_MassFabricator; import net.minecraft.entity.player.InventoryPlayer; /** @@ -12,8 +12,8 @@ import net.minecraft.entity.player.InventoryPlayer; */ public class CONTAINER_MatterFab extends GT_ContainerMetaTile_Machine { - public int mUUA_USED = ((GregtechMetaTileEntityMassFabricator)this.mTileEntity.getMetaTileEntity()).getAmplifierUsed(); - public int mUUM_MADE = ((GregtechMetaTileEntityMassFabricator)this.mTileEntity.getMetaTileEntity()).getMatterProduced(); + public int mUUA_USED = ((GregtechMetaTileEntity_MassFabricator)this.mTileEntity.getMetaTileEntity()).getAmplifierUsed(); + public int mUUM_MADE = ((GregtechMetaTileEntity_MassFabricator)this.mTileEntity.getMetaTileEntity()).getMatterProduced(); public CONTAINER_MatterFab(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java index bc7827916e..f466c2e972 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java @@ -5,7 +5,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks.CustomIcon; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialCentrifuge; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialCentrifuge; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -89,49 +89,49 @@ public class TexturesCentrifugeMultiblock { if ((aSide == 2) || (aSide == 3)) { TileEntity tTileEntity; IMetaTileEntity tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[0].getIcon(); } return CENTRIFUGE[0].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[3].getIcon(); } return CENTRIFUGE[3].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[6].getIcon(); } return CENTRIFUGE[6].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[1].getIcon(); } return CENTRIFUGE[1].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[7].getIcon(); } return CENTRIFUGE[7].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[8].getIcon(); } return CENTRIFUGE[8].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[5].getIcon(); } return CENTRIFUGE[5].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[2].getIcon(); } @@ -140,49 +140,49 @@ public class TexturesCentrifugeMultiblock { } else if ((aSide == 4) || (aSide == 5)) { TileEntity tTileEntity; Object tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[0].getIcon(); } return CENTRIFUGE[0].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[3].getIcon(); } return CENTRIFUGE[3].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[6].getIcon(); } return CENTRIFUGE[6].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[1].getIcon(); } return CENTRIFUGE[1].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[7].getIcon(); } return CENTRIFUGE[7].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[8].getIcon(); } return CENTRIFUGE[8].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[5].getIcon(); } return CENTRIFUGE[5].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return CENTRIFUGE_ACTIVE[2].getIcon(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java index 869df45989..2fdfc0587c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java @@ -4,7 +4,7 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialCentrifuge; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialCentrifuge; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -89,49 +89,49 @@ public class TexturesGregtech58 { if ((aSide == 2) || (aSide == 3)) { TileEntity tTileEntity; IMetaTileEntity tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[0].getIcon(); } return TURBINE[0].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[3].getIcon(); } return TURBINE[3].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[6].getIcon(); } return TURBINE[6].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[1].getIcon(); } return TURBINE[1].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[7].getIcon(); } return TURBINE[7].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[8].getIcon(); } return TURBINE[8].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[5].getIcon(); } return TURBINE[5].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[2].getIcon(); } @@ -140,49 +140,49 @@ public class TexturesGregtech58 { } else if ((aSide == 4) || (aSide == 5)) { TileEntity tTileEntity; Object tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[0].getIcon(); } return TURBINE[0].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[3].getIcon(); } return TURBINE[3].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[6].getIcon(); } return TURBINE[6].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[1].getIcon(); } return TURBINE[1].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[7].getIcon(); } return TURBINE[7].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[8].getIcon(); } return TURBINE[8].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[5].getIcon(); } return TURBINE[5].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[2].getIcon(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java index c0b1e1ec4a..84de389827 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java @@ -4,7 +4,7 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialCentrifuge; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialCentrifuge; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -89,49 +89,49 @@ public IIcon handleCasingsGT59(IBlockAccess aWorld, int xCoord, int yCoord, int if ((aSide == 2) || (aSide == 3)) { TileEntity tTileEntity; IMetaTileEntity tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[0].getIcon(); } return TURBINE[0].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[3].getIcon(); } return TURBINE[3].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[6].getIcon(); } return TURBINE[6].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[1].getIcon(); } return TURBINE[1].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[7].getIcon(); } return TURBINE[7].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[8].getIcon(); } return TURBINE[8].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[5].getIcon(); } return TURBINE[5].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[2].getIcon(); } @@ -140,49 +140,49 @@ public IIcon handleCasingsGT59(IBlockAccess aWorld, int xCoord, int yCoord, int } else if ((aSide == 4) || (aSide == 5)) { TileEntity tTileEntity; Object tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[0].getIcon(); } return TURBINE[0].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[3].getIcon(); } return TURBINE[3].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[6].getIcon(); } return TURBINE[6].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[1].getIcon(); } return TURBINE[1].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[7].getIcon(); } return TURBINE[7].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[8].getIcon(); } return TURBINE[8].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[5].getIcon(); } return TURBINE[5].getIcon(); } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntityIndustrialCentrifuge))) { + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { if (((IGregTechTileEntity) tTileEntity).isActive()) { return TURBINE_ACTIVE[2].getIcon(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTENuclearReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTENuclearReactor.java deleted file mode 100644 index 32bae133ba..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTENuclearReactor.java +++ /dev/null @@ -1,287 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Config; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.Recipe_GT; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; - -import java.util.ArrayList; -import java.util.Arrays; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import org.apache.commons.lang3.ArrayUtils; - -public class GregtechMTENuclearReactor extends GT_MetaTileEntity_MultiBlockBase { - - public static int sUUAperUUM = 1; - public static int sUUASpeedBonus = 4; - public static int sDurationMultiplier = 3215; - public static boolean sRequiresUUA = false; - private int recipeCounter = 0; - private static Block IC2Glass = Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass")); - //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); - - public GregtechMTENuclearReactor(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTENuclearReactor(String aName) { - super(aName); - } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Nuclear Reactor", - "Produces heat from Radioactive beta decay.", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", - "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", - "1x Input Hatch (Any bottom layer casing)", - "1x Output Hatch (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", - "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", - "1x Energy Hatch (Any bottom layer casing)", - "24x IC2 Reinforced Glass for the walls", - "Matter Fabricator Casings for the edges & top (40 at least!)", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); - } - - @Override - public void onConfigLoad(GT_Config aConfig) { - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tFluidList = getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, tFluidList.size()); - if (tFluids.length > 0) { - for(int i = 0;i 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - this.mOutputFluids = tRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(mOutputFluids); - recipeCounter++; - updateSlots(); - //Utils.LOG_INFO("Recipes Finished: "+recipeCounter); - return true; - } - } - else { - Utils.LOG_INFO("Invalid Recipe"); - } - } - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - for (int i = -2; i < 3; i++) { - for (int j = -2; j < 3; j++) { - for (int h = 0; h < 4; h++) { - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - - if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he - if (h == 0) {// inner floor 3x3 - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Coils missings from the bottom layer, inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { - Utils.LOG_INFO("Coils missings from the bottom layer, inner 3x3."); - return false; - } - } else if (h == 3) {//Roofing blocks 3x3 (casings + input + muffler) - if ((!addMufflerToMachineList(tTileEntity, 66))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Casings Missing from one of the top layers inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Casings Missing from one of the top layers inner 3x3."); - return false; - } - } - } else {// Inner Air section, may require blocks here. - if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { - Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); - return false; - } - } - } else {// Outer 5x5 - if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) - if ((!addMaintenanceToMachineList(tTileEntity, 66)) && (!addInputToMachineList(tTileEntity, 66)) && (!addOutputToMachineList(tTileEntity, 66)) && (!addEnergyInputToMachineList(tTileEntity, 66))) { - if ((xDir + i != 0) || (zDir + j != 0)) {//no controller - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); - return false; - } - } - } - } else {// au�en �ber boden (ulv casings) - if (h == 1) { - - if ((i == -2 || i == 2) && (j == -2 || j == 2)){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); - return false; - } - } - - else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); - return false; - } - } - } - if (h == 2) { - if ((i == -2 || i == 2) && (j == -2 || j == 2)){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); - return false; - } - } - - else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the third layer."); - return false; - } - } - } - if (h == 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); - return false; - } - } - } - } - } - } - } - Utils.LOG_INFO("Multiblock Formed."); - return true; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMTENuclearReactor(this.mName); - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java new file mode 100644 index 0000000000..db984d18b8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java @@ -0,0 +1,287 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.ArrayUtils; + +public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase { + + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3215; + public static boolean sRequiresUUA = false; + private int recipeCounter = 0; + private static Block IC2Glass = Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass")); + //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); + + public GregtechMTE_NuclearReactor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_NuclearReactor(String aName) { + super(aName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Nuclear Reactor", + "Produces heat from Radioactive beta decay.", + "Size(WxHxD): 5x4x5, Controller (Bottom center)", + "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", + "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", + "1x Input Hatch (Any bottom layer casing)", + "1x Output Hatch (Any bottom layer casing)", + "1x Maintenance Hatch (Any bottom layer casing)", + "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", + "1x Energy Hatch (Any bottom layer casing)", + "24x IC2 Reinforced Glass for the walls", + "Matter Fabricator Casings for the edges & top (40 at least!)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) { + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, tFluidList.size()); + if (tFluids.length > 0) { + for(int i = 0;i 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + this.mOutputFluids = tRecipe.mFluidOutputs.clone(); + ArrayUtils.reverse(mOutputFluids); + recipeCounter++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+recipeCounter); + return true; + } + } + else { + Utils.LOG_INFO("Invalid Recipe"); + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + for (int h = 0; h < 4; h++) { + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + + if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he + if (h == 0) {// inner floor 3x3 + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Coils missings from the bottom layer, inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { + Utils.LOG_INFO("Coils missings from the bottom layer, inner 3x3."); + return false; + } + } else if (h == 3) {//Roofing blocks 3x3 (casings + input + muffler) + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Casings Missing from one of the top layers inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Casings Missing from one of the top layers inner 3x3."); + return false; + } + } + } else {// Inner Air section, may require blocks here. + if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { + Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); + return false; + } + } + } else {// Outer 5x5 + if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) + if ((!addMaintenanceToMachineList(tTileEntity, 66)) && (!addInputToMachineList(tTileEntity, 66)) && (!addOutputToMachineList(tTileEntity, 66)) && (!addEnergyInputToMachineList(tTileEntity, 66))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); + return false; + } + } + } + } else {// au�en �ber boden (ulv casings) + if (h == 1) { + + if ((i == -2 || i == 2) && (j == -2 || j == 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + return false; + } + } + + else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { + Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); + return false; + } + } + } + if (h == 2) { + if ((i == -2 || i == 2) && (j == -2 || j == 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); + return false; + } + } + + else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { + Utils.LOG_INFO("Glass Casings Missing from somewhere in the third layer."); + return false; + } + } + } + if (h == 3) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); + return false; + } + } + } + } + } + } + } + Utils.LOG_INFO("Multiblock Formed."); + return true; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMTE_NuclearReactor(this.mName); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java deleted file mode 100644 index 70804e9d6e..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java +++ /dev/null @@ -1,320 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.CORE.configSwitches; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.player.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks.CustomIcon; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import org.apache.commons.lang3.ArrayUtils; - -public class GregtechMetaTileEntityIndustrialCentrifuge -extends GregtechMeta_MultiBlockBase { - private static boolean controller; - private static boolean isDisabled = false; - private static ITexture frontFace; - private static ITexture frontFaceActive; - private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); - private static CustomIcon GT9_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); - //public static double recipesComplete = 0; - - public GregtechMetaTileEntityIndustrialCentrifuge(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - frontFaceActive = new GT_RenderedTexture(GT9_5_Active); - frontFace = new GT_RenderedTexture(GT9_5); - } - - public GregtechMetaTileEntityIndustrialCentrifuge(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIndustrialCentrifuge(this.mName); - } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Industrial Centrifuge", - "Size: 3x3x3 (Hollow)", - "Controller (Front Center) [Orange]", - "1x Maintenance Hatch (Rear Center) [Green]", - "The rest can be placed anywhere except the Front [Red]", - "1x Input Hatch", - "1x Output Hatch", - "1x Input Bus", - "1x Output Bus", - "1x [EV] Energy Hatch (Can be higher Tier) [Blue]", - "Centrifuge Casings for the rest (16 at least)", - CORE.GT_Tooltip}; - } - - - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? frontFaceActive : frontFace : Textures.BlockIcons.CASING_BLOCKS[57]}; - } - - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialCentrifuge.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - ArrayList tInputList = getStoredInputs(); - GT_Recipe mLastRecipe; - - @Override - public boolean checkRecipe(ItemStack aStack) { - /*if (!isCorrectMachinePart(mInventory[1])) { - return false; - }*/ - - Utils.LOG_WARNING("Centrifuge Debug - 1"); - GT_Recipe.GT_Recipe_Map map = getRecipeMap(); - if (map == null) { - Utils.LOG_WARNING("Centrifuge Debug - False - No recipe map"); - return false; - } - Utils.LOG_WARNING("Centrifuge Debug - 2"); - ArrayList tInputList = getStoredInputs(); - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - Utils.LOG_WARNING("Centrifuge Debug - Tier variable: "+tTier); - ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); - ArrayList tFluidList = getStoredFluids(); - FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); - if (tInputList.size() > 0 || tFluids.length > 0) { - GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null) { - Utils.LOG_WARNING("Recipe was not invalid"); - mLastRecipe = tRecipe; - this.mEUt = 0; - this.mOutputItems = null; - this.mOutputFluids = null; - if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - - Utils.LOG_WARNING("False: 1"); - return false; - } - - this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - Utils.LOG_WARNING("Centrifuge Debug - 2 - Max Progress Time: "+this.mMaxProgresstime); - if (tRecipe.mEUt <= 16) { - Utils.LOG_WARNING("Centrifuge Debug - Using < 16eu/t"); - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - Utils.LOG_WARNING("Centrifuge Debug - 3.1 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); - } else { - Utils.LOG_WARNING("Centrifuge Debug - using > 16eu/t"); - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - Utils.LOG_WARNING("Centrifuge Debug - 3.2 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - Utils.LOG_WARNING("Centrifuge Debug - 4 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); - } - } - this.mEUt *= 1; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - Utils.LOG_WARNING("Centrifuge Debug - 5 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); - } - ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - tOut[h] = tRecipe.getOutput(h).copy(); - tOut[h].stackSize = 0; - } - FluidStack tFOut = null; - if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); - for (int f = 0; f < tOut.length; f++) { - if (tRecipe.mOutputs[f] != null && tOut[f] != null) { - for (int g = 0; g < 1; g++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) - tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - if (tFOut != null) { - int tSize = tFOut.amount; - tFOut.amount = tSize * 6; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mMaxProgresstime /= 4; - if (this.mMaxProgresstime <= 0){ - this.mMaxProgresstime++; - } - Utils.LOG_WARNING("Centrifuge Debug - 6 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); - List overStacks = new ArrayList(); - for (int f = 0; f < tOut.length; f++) { - if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - ItemStack tmp = tOut[f].copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); - overStacks.add(tmp); - } - } - } - if (overStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[overStacks.size()]; - tmp = overStacks.toArray(tmp); - tOut = ArrayUtils.addAll(tOut, tmp); - } - List tSList = new ArrayList(); - for (ItemStack tS : tOut) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOut = tSList.toArray(new ItemStack[tSList.size()]); - this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[]{tFOut}; - updateSlots(); - Utils.LOG_WARNING("Centrifuge: True"); - return true; - } - } - Utils.LOG_WARNING("Centrifuge: Recipe was invalid."); - return false; - } - - @SuppressWarnings("static-method") - public Block getCasingBlock() { - return ModBlocks.blockCasingsMisc; - } - - @SuppressWarnings("static-method") - public byte getCasingMeta() { - return 0; - } - - @SuppressWarnings("static-method") - public byte getCasingTextureIndex() { - return 0; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - if (configSwitches.disableCentrifugeFormation){ - EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(this.getBaseMetaTileEntity().getOwnerName()); - if (!player.getEntityWorld().isRemote && isDisabled == false) - PlayerUtils.messagePlayer(player, "This Multiblock is disabled via the config. [Only re-enable if you're bugtesting.]"); - isDisabled = true; - return false; - } - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - //Utils.LOG_WARNING("X:"+xDir+" Y:"+yDir+" Z:"+zDir); - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { //X-Dir - for (int j = -1; j < 2; j++) { //Z-Dir - for (int h = -1; h < 2; h++) { //Y-Dir - if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - //Utils.LOG_WARNING("X:"+tTileEntity.getXCoord()+" Y:"+tTileEntity.getYCoord()+" Z:"+tTileEntity.getZCoord()); - if ((!addMaintenanceToMachineList(tTileEntity, 57)) && (!addInputToMachineList(tTileEntity, 57)) && (!addOutputToMachineList(tTileEntity, 57)) && (!addEnergyInputToMachineList(tTileEntity, 57))) { - - //Maintenance Hatch - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if (tTileEntity.getXCoord() == aBaseMetaTileEntity.getXCoord() && tTileEntity.getYCoord() == aBaseMetaTileEntity.getYCoord() && tTileEntity.getZCoord() == (aBaseMetaTileEntity.getZCoord()+2)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - Utils.LOG_WARNING("MAINT HATCH IN CORRECT PLACE"); - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - } else { - return false; - } - } - else { - Utils.LOG_WARNING("MAINT HATCH IN WRONG PLACE"); - } - } - - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { - return false; - } - tAmount++; - - } - } - } - } - } - return tAmount >= 16; - } - - @SuppressWarnings("static-method") - public boolean ignoreController(Block tTileEntity) { - if (!controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; - } - return false; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java deleted file mode 100644 index 9c67502cae..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java +++ /dev/null @@ -1,272 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.Recipe_GT; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -import java.util.ArrayList; -import java.util.Arrays; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -public class GregtechMetaTileEntityIndustrialCokeOven - extends GregtechMeta_MultiBlockBase { - private int mLevel = 0; - - public GregtechMetaTileEntityIndustrialCokeOven(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityIndustrialCokeOven(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIndustrialCokeOven(this.mName); - } - - @Override - public String[] getDescription() { - return new String[]{"Processes Logs and Coal into Charcoal and Coal Coke.", - "Controller Block for the Industrial Coke Oven", - "Size: 3x3x3 (Hollow)", - "Controller (front middle at bottom)", - "8x Heat Resistant/Proof Coils (middle Layer, hollow)", - "1x Input (one of bottom)", - "1x Output (one of bottom)", - "1x Energy Hatch (one of bottom)", - "1x Maintenance Hatch (one of bottom)", - "1x Muffler Hatch (top middle)", - "Structural Coke Oven Casings for the rest", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "CokeOven.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; - - } - - /* @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - }*/ - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { - if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - ArrayList tFluidList = getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 0) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if ((tRecipe != null) && (this.mLevel >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; - updateSlots(); - //Utils.LOG_INFO("Coke oven: True"); - return true; - } - } - //Utils.LOG_INFO("Coke oven: False"); - return false; - } - /*public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - if (!tInputList.isEmpty()) { - byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); - - int j = 0; - this.mOutputItems = new ItemStack[12 * this.mLevel]; - for (int i = 0; (i < 100) && (j < this.mOutputItems.length); i++) { - if (null != (this.mOutputItems[j] = GT_ModHandler.getSmeltingOutput((ItemStack) tInputList.get(i % tInputList.size()), true, null))) { - j++; - } - } - if (j > 0) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - this.mEUt = (-4 * (1 << tTier - 1) * (1 << tTier - 1) * this.mLevel); - this.mMaxProgresstime = Math.max(1, 512 / (1 << tTier - 1)); - } - updateSlots(); - return true; - } - return false; - }*/ - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int xr = aBaseMetaTileEntity.getXCoord(); - int yr = aBaseMetaTileEntity.getYCoord(); - int zr = aBaseMetaTileEntity.getZCoord(); - this.mLevel = 0; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - return false; - } - addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), GTID+1); - - byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); - switch (tUsedMeta) { - case 2: - this.mLevel = 1; - break; - case 3: - this.mLevel = 2; - break; - default: - return false; - } - this.mOutputItems = new ItemStack[12 * this.mLevel]; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if ((i != 0) || (j != 0)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 1) { - return false; - } - } - } - } - for (int i = -1; i < 2; i++) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - //Utils.LOG_WARNING("STEP 1 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); - for (int j = -1; j < 2; j++) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - //Utils.LOG_WARNING("STEP 2 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); - if ((xDir + i != 0) || (zDir + j != 0)) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - //Utils.LOG_WARNING("STEP 3 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, GTID+1)) && (!addInputToMachineList(tTileEntity, GTID+1)) && (!addOutputToMachineList(tTileEntity, GTID+1)) && (!addEnergyInputToMachineList(tTileEntity, GTID+1))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 1) { - return false; - } - } - } - } - } - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - /* @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - }*/ - - @Override - public int getAmountOfOutputs() { - return 24; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialElectrolyzer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialElectrolyzer.java deleted file mode 100644 index e300de3d88..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialElectrolyzer.java +++ /dev/null @@ -1,258 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import org.apache.commons.lang3.ArrayUtils; - -public class GregtechMetaTileEntityIndustrialElectrolyzer -extends GT_MetaTileEntity_MultiBlockBase { - public GregtechMetaTileEntityIndustrialElectrolyzer(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityIndustrialElectrolyzer(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIndustrialElectrolyzer(this.mName); - } - - @Override - public String[] getDescription() { - return new String[]{"Controller Block for the Industrial Electrolyzer", - "Size: 3x3x3 (Hollow)", - "Controller (front centered)", - "1x Input Bus (anywhere)", - "1x Output Bus (anywhere)", - "1x Input Hatch (anywhere)", - "1x Output Hatch (anywhere)", - "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", - "1x Muffler (anywhere)", - "Electrolyzer Casings for the rest (16 at least!)", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5], new GT_RenderedTexture(aActive ? Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE : Textures.BlockIcons.STEAM_TURBINE_SIDE)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialElectrolyzer.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - ArrayList tInputList = getStoredInputs(); - GT_Recipe mLastRecipe; - - @Override - public boolean checkRecipe(ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full - ArrayList tInputList = getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { - if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - ArrayList tFluidList = getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 0) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if ((tRecipe != null) && (7500 >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - tOut[h] = tRecipe.getOutput(h).copy(); - tOut[h].stackSize = 0; - } - FluidStack tFOut = null; - if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); - for (int f = 0; f < tOut.length; f++) { - if (tRecipe.mOutputs[f] != null && tOut[f] != null) { - for (int g = 0; g < 1; g++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) - tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - if (tFOut != null) { - int tSize = tFOut.amount; - tFOut.amount = tSize * 1; - } - - List overStacks = new ArrayList(); - for (int f = 0; f < tOut.length; f++) { - if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - ItemStack tmp = tOut[f].copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); - overStacks.add(tmp); - } - } - } - if (overStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[overStacks.size()]; - tmp = overStacks.toArray(tmp); - tOut = ArrayUtils.addAll(tOut, tmp); - } - List tSList = new ArrayList(); - for (ItemStack tS : tOut) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOut = tSList.toArray(new ItemStack[tSList.size()]); - this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[]{tFOut}; - updateSlots(); - - /* this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - updateSlots();*/ - return true; - } - } - return false; - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 62)) && (!addMufflerToMachineList(tTileEntity, 62)) && (!addInputToMachineList(tTileEntity, 62)) && (!addOutputToMachineList(tTileEntity, 62)) && (!addEnergyInputToMachineList(tTileEntity, 62))) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (((tBlock != ModBlocks.blockCasingsMisc) || (tMeta != 5))) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialMacerator.java deleted file mode 100644 index ff8b6c7f22..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialMacerator.java +++ /dev/null @@ -1,278 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -public class GregtechMetaTileEntityIndustrialMacerator -extends GregtechMeta_MultiBlockBase { - private static boolean controller; - - public GregtechMetaTileEntityIndustrialMacerator(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityIndustrialMacerator(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIndustrialMacerator(this.mName); - } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Industrial Maceration Stack", - "Size[WxHxL]: 3x6x3 (Hollow)", - "Controller (Center Bottom)", - "1x Input Bus (Any bottom layer casing)", - "5x Output Bus (Any casing besides bottom layer)", - "1x Maintenance Hatch (Any casing)", - "1x Energy Hatch (Any casing)", - "Maceration Stack Casings for the rest (26 at least!)", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MacerationStack.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; - } - - /*@Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - }*/ - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { - Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, aBaseMetaTileEntity.getYCoord() + 0.3f + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 1.2F - tRandom.nextFloat() * 1.6F, 0.0D, 0.0D, 0.0D); - } - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(201)), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public void startProcess() { - sendLoopStart((byte) 1); - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { - if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - if (tInputList.size() > 0) { - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); - if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - this.mEUt = (-tRecipe.mEUt); - this.mMaxProgresstime = Math.max(1, (tRecipe.mDuration/5)); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - sendLoopStart((byte) 20); - updateSlots(); - return true; - } - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - return false; - } - int tAmount = 0; - controller = false; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = 0; h < 6; h++) { - if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) - { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 64)) && (!addInputToMachineList(tTileEntity, 64)) && (!addOutputToMachineList(tTileEntity, 64)) && (!addEnergyInputToMachineList(tTileEntity, 64)) && (!ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Returned False 1"); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 7) { - Utils.LOG_INFO("Returned False 2"); - return false; - } - tAmount++; - } - } - } - } - } - if (this.mOutputHatches.size() != 0 || this.mInputBusses.size() != 1 || this.mOutputBusses.size() != 5) { - Utils.LOG_INFO("Returned False 3"); - return false; - } - int height = this.getBaseMetaTileEntity().getYCoord(); - if (this.mInputBusses.get(0).getBaseMetaTileEntity().getYCoord() != height) { - Utils.LOG_INFO("height: "+height+" | Returned False 4"); - return false; - } - GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; - for (int i = 0; i < this.mOutputBusses.size(); i++) { - int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; - if (tmpHatches[hatchNumber] == null) { - tmpHatches[hatchNumber] = this.mOutputBusses.get(i); - } else { - Utils.LOG_INFO("Returned False 5"); - return false; - } - } - this.mOutputBusses.clear(); - for (int i = 0; i < tmpHatches.length; i++) { - this.mOutputBusses.add(tmpHatches[i]); - } - return tAmount >= 26; - } - - /*public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - return false; - } - int tAmount = 0; - controller = false; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = 0; h < 6; h++) { - if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) - { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 64)) && (!addInputToMachineList(tTileEntity, 64)) && (!addOutputToMachineList(tTileEntity, 64)) && (!addEnergyInputToMachineList(tTileEntity, 64)) && (!ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { - return false; - } - tAmount++; - } - } - } - } - } - if (this.mOutputBusses.size() != 5 || this.mInputBusses.size() != 1) { - return false; - } - int height = this.getBaseMetaTileEntity().getYCoord(); - if (this.mInputHatches.get(0).getBaseMetaTileEntity().getYCoord() != height) { - return false; - } - GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; - for (int i = 0; i < this.mOutputBusses.size(); i++) { - int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; - if (tmpHatches[hatchNumber] == null) { - tmpHatches[hatchNumber] = this.mOutputBusses.get(i); - } else { - return false; - } - } - this.mOutputBusses.clear(); - for (int i = 0; i < tmpHatches.length; i++) { - this.mOutputBusses.add(tmpHatches[i]); - } - return tAmount >= 26; - }*/ - - public boolean ignoreController(Block tTileEntity) { - if (!controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; - } - return false; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - /*@Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - }*/ - - @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java deleted file mode 100644 index df60138c60..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java +++ /dev/null @@ -1,204 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; - -import java.util.ArrayList; -import java.util.Arrays; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -public class GregtechMetaTileEntityIndustrialPlatePress -extends GT_MetaTileEntity_MultiBlockBase { - public GregtechMetaTileEntityIndustrialPlatePress(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityIndustrialPlatePress(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIndustrialPlatePress(this.mName); - } - - @Override - public String[] getDescription() { - return new String[]{"Controller Block for the Material Press", - "Size: 3x3x3 (Hollow)", - "Controller (front centered)", - "1x Input Bus (anywhere)", - "1x Output Bus (anywhere)", - "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", - "1x Muffler (anywhere)", - "Material Press Machine Casings for the rest (16 at least!)", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MaterialPress.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBenderRecipes; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full - ArrayList tInputList = getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { - if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - ArrayList tFluidList = getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 0) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBenderRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if ((tRecipe != null) && (2500 >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - updateSlots(); - return true; - } - } - return false; - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 61)) && (!addMufflerToMachineList(tTileEntity, 61)) && (!addInputToMachineList(tTileEntity, 61)) && (!addOutputToMachineList(tTileEntity, 61)) && (!addEnergyInputToMachineList(tTileEntity, 61))) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (((tBlock != ModBlocks.blockCasingsMisc) || (tMeta != 4))) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java deleted file mode 100644 index ca5e102521..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java +++ /dev/null @@ -1,263 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - -public class GregtechMetaTileEntityIndustrialSinter -extends GT_MetaTileEntity_MultiBlockBase { - - - RenderBlocks asdasd = RenderBlocks.getInstance(); - - public GregtechMetaTileEntityIndustrialSinter(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityIndustrialSinter(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIndustrialSinter(this.mName); - } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Industrial Sinter Furnace", - "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", - "2x Input Bus (side centered)", - "2x Output Bus (side centered)", - "1x Energy Hatch (top or bottom centered)", - "1x Maintenance Hatch (back centered)", - "Sinter Furnace Casings for the rest (32 at least!)", - CORE.GT_Tooltip - }; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "WireFactory.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - for (ItemStack tInput : tInputList) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - updateSlots(); - return true; - } - } - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int controllerX = aBaseMetaTileEntity.getXCoord(); - int controllerY = aBaseMetaTileEntity.getYCoord(); - int controllerZ = aBaseMetaTileEntity.getZCoord(); - - byte tSide = getBaseMetaTileEntity().getBackFacing(); - if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { - int tAirCount = 0; - for (byte i = -1; i < 2; i = (byte) (i + 1)) { - for (byte j = -1; j < 2; j = (byte) (j + 1)) { - for (byte k = -1; k < 2; k = (byte) (k + 1)) { - if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { - Utils.LOG_INFO("Found Air at: "+(controllerX+i)+" "+(controllerY+k)+" "+(controllerZ+k)); - //if (aBaseMetaTileEntity.getWorld().isRemote){ - //asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, (controllerX+i), (controllerY+k), (controllerZ+k)); - //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.YELLOW_GREEN); - //} - tAirCount++; - } - } - } - } - if (tAirCount != 10) { - Utils.LOG_INFO("False. Air != 10. Air == "+tAirCount); - //return false; - } - for (byte i = 2; i < 6; i = (byte) (i + 1)) { - //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ), Color.LIME_GREEN); - IGregTechTileEntity tTileEntity; - if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && - (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && - ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntityIndustrialSinter))) { - //Utils.LOG_INFO("False 1"); - return false; - } - } - int tX = getBaseMetaTileEntity().getXCoord(); - int tY = getBaseMetaTileEntity().getYCoord(); - int tZ = getBaseMetaTileEntity().getZCoord(); - for (byte i = -1; i < 2; i = (byte) (i + 1)) { - for (byte j = -1; j < 2; j = (byte) (j + 1)) { - if ((i != 0) || (j != 0)) { - for (byte k = 0; k < 5; k = (byte) (k + 1)) { - //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.ORANGE); - if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { - //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.TOMATO); - if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { - } - else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { - Utils.LOG_INFO("False 2"); - return false; - } - } - else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { - } - else { - Utils.LOG_INFO("False 3"); - return false; - } - } - } - } - } - if (this.mOutputHatches.size() != 0 || this.mInputHatches.size() != 0) { - Utils.LOG_INFO("Use Busses, Not Hatches for Input/Output."); - return false; - } - if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { - Utils.LOG_INFO("Incorrect amount of Input & Output busses."); - return false; - } - this.mMaintenanceHatches.clear(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - } else { - Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); - return false; - } - } - if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1) { - Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); - return false; - } - } else { - Utils.LOG_INFO("False 5"); - return false; - } - Utils.LOG_INFO("True"); - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasingsMisc; - } - - - public byte getCasingMeta() { - return 6; - } - - - public byte getCasingTextureIndex() { - return 63; - } - - private boolean addToMachineList(IGregTechTileEntity tTileEntity) { - return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); - } - - private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { - return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialWireMill.java deleted file mode 100644 index b0bc87c74a..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialWireMill.java +++ /dev/null @@ -1,246 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - -public class GregtechMetaTileEntityIndustrialWireMill -extends GT_MetaTileEntity_MultiBlockBase { - public GregtechMetaTileEntityIndustrialWireMill(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityIndustrialWireMill(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIndustrialWireMill(this.mName); - } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Industrial Wire Factory", - "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", - "2x Input Bus (side centered)", - "2x Output Bus (side centered)", - "1x Energy Hatch (top or bottom centered)", - "1x Maintenance Hatch (back centered)", - "Wire Factory Casings for the rest (32 at least!)", - CORE.GT_Tooltip - }; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "WireFactory.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - for (ItemStack tInput : tInputList) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - updateSlots(); - return true; - } - } - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - byte tSide = getBaseMetaTileEntity().getBackFacing(); - if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { - int tAirCount = 0; - for (byte i = -1; i < 2; i = (byte) (i + 1)) { - for (byte j = -1; j < 2; j = (byte) (j + 1)) { - for (byte k = -1; k < 2; k = (byte) (k + 1)) { - if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { - tAirCount++; - } - } - } - } - if (tAirCount != 10) { - Utils.LOG_INFO("False 1"); - return false; - } - for (byte i = 2; i < 6; i = (byte) (i + 1)) { - IGregTechTileEntity tTileEntity; - if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && - (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && - ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntityIndustrialWireMill))) { - //Utils.LOG_INFO("False 1"); - return false; - } - } - int tX = getBaseMetaTileEntity().getXCoord(); - int tY = getBaseMetaTileEntity().getYCoord(); - int tZ = getBaseMetaTileEntity().getZCoord(); - for (byte i = -1; i < 2; i = (byte) (i + 1)) { - for (byte j = -1; j < 2; j = (byte) (j + 1)) { - if ((i != 0) || (j != 0)) { - for (byte k = 0; k < 5; k = (byte) (k + 1)) { - if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { - if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { - } - else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { - Utils.LOG_INFO("False 2"); - return false; - } - } - else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { - } - else { - Utils.LOG_INFO("False 3"); - return false; - } - } - } - } - } - if (this.mOutputHatches.size() != 0 || this.mInputHatches.size() != 0) { - Utils.LOG_INFO("Use Busses, Not Hatches for Input/Output."); - return false; - } - if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { - Utils.LOG_INFO("Incorrect amount of Input & Output busses."); - return false; - } - this.mMaintenanceHatches.clear(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - } else { - Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); - return false; - } - } - if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1) { - Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); - return false; - } - } else { - Utils.LOG_INFO("False 5"); - return false; - } - Utils.LOG_INFO("True"); - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasingsMisc; - } - - - public byte getCasingMeta() { - return 6; - } - - - public byte getCasingTextureIndex() { - return 63; - } - - private boolean addToMachineList(IGregTechTileEntity tTileEntity) { - return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); - } - - private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { - return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrial_PlatePress.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrial_PlatePress.java new file mode 100644 index 0000000000..b0828776ed --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrial_PlatePress.java @@ -0,0 +1,204 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntityIndustrial_PlatePress +extends GT_MetaTileEntity_MultiBlockBase { + public GregtechMetaTileEntityIndustrial_PlatePress(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityIndustrial_PlatePress(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrial_PlatePress(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{"Controller Block for the Material Press", + "Size: 3x3x3 (Hollow)", + "Controller (front centered)", + "1x Input Bus (anywhere)", + "1x Output Bus (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "1x Muffler (anywhere)", + "Material Press Machine Casings for the rest (16 at least!)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MaterialPress.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBenderRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full + ArrayList tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBenderRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (2500 >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots(); + return true; + } + } + return false; + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 61)) && (!addMufflerToMachineList(tTileEntity, 61)) && (!addInputToMachineList(tTileEntity, 61)) && (!addOutputToMachineList(tTileEntity, 61)) && (!addEnergyInputToMachineList(tTileEntity, 61))) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (((tBlock != ModBlocks.blockCasingsMisc) || (tMeta != 4))) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java deleted file mode 100644 index f15757491c..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java +++ /dev/null @@ -1,380 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -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.MetaTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_IronBlastFurnace; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_IronBlastFurnace; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -public class GregtechMetaTileEntityIronBlastFurnace - extends MetaTileEntity { - private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Top)}; - private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_Off)}; - private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_On)}; - public int mMaxProgresstime = 0; - public int mUpdate = 30; - public int mProgresstime = 0; - public boolean mMachine = false; - public ItemStack mOutputItem1; - public ItemStack mOutputItem2; - - public GregtechMetaTileEntityIronBlastFurnace(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, 4); - } - - public GregtechMetaTileEntityIronBlastFurnace(String aName) { - super(aName, 4); - } - - @Override - public String[] getDescription() { - return new String[]{"Sloooowly, Skip the Bronze age, Get some Steel!", - "Multiblock: 3x3x5 hollow with opening on top", - "40 Iron Plated Bricks required", - "----", - "Even though Iron melts hotter than bronze,", - "this machine is to help players skip looking", - "for tin and copper, which are not as common", - "as Iron is. This machine takes 5x longer than the bronze", - "blast furnace as a result.", - "----", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return aActive ? FACING_ACTIVE : FACING_FRONT; - } - return FACING_SIDE; - } - - @Override - public boolean isSteampowered() { - return false; - } - - @Override - public boolean isElectric() { - return false; - } - - @Override - public boolean isPneumatic() { - return false; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(byte aSide) { - return false; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return false; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public int getProgresstime() { - return this.mProgresstime; - } - - @Override - public int maxProgresstime() { - return this.mMaxProgresstime; - } - - @Override - public int increaseProgress(int aProgress) { - this.mProgresstime += aProgress; - return this.mMaxProgresstime - this.mProgresstime; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIronBlastFurnace(this.mName); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mProgresstime", this.mProgresstime); - aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); - if (this.mOutputItem1 != null) { - NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem1.writeToNBT(tNBT); - aNBT.setTag("mOutputItem1", tNBT); - } - if (this.mOutputItem2 != null) { - NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem2.writeToNBT(tNBT); - aNBT.setTag("mOutputItem2", tNBT); - } - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mUpdate = 30; - this.mProgresstime = aNBT.getInteger("mProgresstime"); - this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); - this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); - } - - private boolean checkMachine() { - int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 4; j++) { //This is height - for (int k = -1; k < 2; k++) { - if ((xDir + i != 0) || (j != 0) || (zDir + k != 0)) { - if ((i != 0) || (j == -1) || (k != 0)) { - if ((getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) != ModBlocks.blockCasingsMisc) || (getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) { - return false; - } - } else if ((!GT_Utility.arrayContains(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[]{Blocks.lava, Blocks.flowing_lava, null})) && (!getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { - return false; - } - } - } - } - } - return true; - } - - @Override - public void onMachineBlockUpdate() { - this.mUpdate = 30; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if ((aBaseMetaTileEntity.isClientSide()) && - (aBaseMetaTileEntity.isActive())) { - aBaseMetaTileEntity.getWorld().spawnParticle("cloud", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, 0.0D); - } - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate-- == 0) { - this.mMachine = checkMachine(); - } - if (this.mMachine) { - if (this.mMaxProgresstime > 0) { - if (++this.mProgresstime >= this.mMaxProgresstime) { - addOutputProducts(); - this.mOutputItem1 = null; - this.mOutputItem2 = null; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - try { - // GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel"); - } catch (Exception e) { - } - } - } else if (aBaseMetaTileEntity.isAllowedToWork()) { - checkRecipe(); - } - } - aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); - if (aBaseMetaTileEntity.isActive()) { - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); - this.mUpdate = 1; - } - } else { - if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); - this.mUpdate = 1; - } - } - } - } - - private void addOutputProducts() { - if (this.mOutputItem1 != null) { - if (this.mInventory[2] == null) { - this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1}); - } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { - this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize); - } - } - if (this.mOutputItem2 != null) { - if (this.mInventory[3] == null) { - this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2}); - } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { - this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize); - } - } - } - - private boolean spaceForOutput(ItemStack aStack1, ItemStack aStack2) { - if (((this.mInventory[2] == null) || (aStack1 == null) || ((this.mInventory[2].stackSize + aStack1.stackSize <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && ( - (this.mInventory[3] == null) || (aStack2 == null) || ((this.mInventory[3].stackSize + aStack2.stackSize <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { - return true; - } - return false; - } - - private boolean checkRecipe() { - if (!this.mMachine) { - return false; - } - if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = 36000; - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = 4800*5; - return true; - } - if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 9); - getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = 64800*5; - return true; - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = 3600*5; - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 1*3); - this.mMaxProgresstime = 2400*5; - return true; - } - if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { - getBaseMetaTileEntity().decrStackSize(0, 9); - getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = 32400*5; - return true; - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 64); - this.mMaxProgresstime = 64800*9; - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 18*3); - this.mMaxProgresstime = 43200*5; - return true; - } - if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = 64800*5; - return true; - } - } - } - this.mOutputItem1 = null; - this.mOutputItem2 = null; - return false; - } - - @Override - public boolean isGivingInformation() { - return false; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex > 1; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aIndex < 2) { - } - return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); - } - - @Override - public byte getTileEntityBaseType() { - return 0; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMassFabricator.java deleted file mode 100644 index ed5718cc6c..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMassFabricator.java +++ /dev/null @@ -1,353 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.enums.ConfigCategories; -import gregtech.api.enums.Materials; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Config; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.Recipe_GT; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.fluid.FluidUtils; -import gtPlusPlus.core.util.item.UtilsItems; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; - -import java.util.ArrayList; -import java.util.Arrays; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import org.apache.commons.lang3.ArrayUtils; - -public class GregtechMetaTileEntityMassFabricator extends GT_MetaTileEntity_MultiBlockBase { - - public static int sUUAperUUM = 1; - public static int sUUASpeedBonus = 4; - public static int sDurationMultiplier = 3215; - public static boolean sRequiresUUA = false; - private int mAmplifierUsed = 0; - private int mMatterProduced = 0; - private static Block IC2Glass = Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass")); - FluidStack tempFake = FluidUtils.getFluidStack("uuamplifier", 1); - GT_Recipe fakeRecipe; - - public int getAmplifierUsed(){ - return mAmplifierUsed; - } - - public int getMatterProduced(){ - return mMatterProduced; - } - - //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); - - public GregtechMetaTileEntityMassFabricator(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityMassFabricator(String aName) { - super(aName); - } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Matter Fabricator", - "Produces UU-Matter from UU-Amplifier", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", - "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", - "1x Input Hatch (Any bottom layer casing)", - "1x Output Hatch (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", - "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", - "1x Energy Hatch (Any bottom layer casing)", - "24x IC2 Reinforced Glass for the walls", - "Matter Fabricator Casings for the edges & top (40 at least!)", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66], - new GT_RenderedTexture(aActive ? TexturesGtBlocks.Casing_Machine_Screen_3 : TexturesGtBlocks.Casing_Machine_Screen_1)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); - } - - @Override - public void onConfigLoad(GT_Config aConfig) { - super.onConfigLoad(aConfig); - sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUM_Duration_Multiplier", sDurationMultiplier); - sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_per_UUM", sUUAperUUM); - sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Speed_Bonus", sUUASpeedBonus); - sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Requirement", sRequiresUUA); - Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tFluidList = getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, tFluidList.size()); - if (tFluids.length > 0) { - //Utils.LOG_INFO("Input fluid found"); - for(int i = 0;i 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - this.mOutputFluids = tRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(mOutputFluids); - mMatterProduced++; - mAmplifierUsed++; - updateSlots(); - //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); - return true; - } - } - else { - //Utils.LOG_INFO("Invalid Recipe"); - return false; - } - } - } - else if (tFluids.length == 0) { - //Utils.LOG_INFO("Input fluid not found"); - fakeRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tempFake}, new ItemStack[]{}); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - this.mEUt = 32; - this.mMaxProgresstime = (160*20); - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - if (fakeRecipe != null) { - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{fakeRecipe.getOutput(0)}; - this.mOutputFluids = fakeRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(mOutputFluids); - mMatterProduced++; - updateSlots(); - //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); - return true; - } - } - else { - //Utils.LOG_INFO("Invalid no input Recipe"); - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - for (int i = -2; i < 3; i++) { - for (int j = -2; j < 3; j++) { - for (int h = 0; h < 4; h++) { - - //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { - Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); - double tX = tTileEntity.getXCoord(); - double tY = tTileEntity.getYCoord(); - double tZ = tTileEntity.getZCoord(); - Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); - //return false; - }*/ - if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he - if (h == 0) {// innen boden (kantal coils) - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); - return false; - } - } else if (h == 3) {// innen decke (ulv casings + input + muffler) - if ((!addMufflerToMachineList(tTileEntity, 66))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - } - } else {// innen air - if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { - Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); - return false; - } - } - } else {// Outer 5x5 - if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) - if ((!addMaintenanceToMachineList(tTileEntity, 66)) && (!addInputToMachineList(tTileEntity, 66)) && (!addOutputToMachineList(tTileEntity, 66)) && (!addEnergyInputToMachineList(tTileEntity, 66))) { - if ((xDir + i != 0) || (zDir + j != 0)) {//no controller - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); - return false; - } - } - } - } else {// au�en �ber boden (ulv casings) - if (h == 1) { - - if ((i == -2 || i == 2) && (j == -2 || j == 2)){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); - return false; - } - } - - else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); - return false; - } - } - } - if (h == 2) { - if ((i == -2 || i == 2) && (j == -2 || j == 2)){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); - return false; - } - } - - else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the third layer."); - return false; - } - } - } - if (h == 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); - return false; - } - } - } - } - } - } - } - Utils.LOG_INFO("Multiblock Formed."); - return true; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityMassFabricator(this.mName); - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMultiTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMultiTank.java deleted file mode 100644 index 7d6c3caec7..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMultiTank.java +++ /dev/null @@ -1,284 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -import java.util.ArrayList; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -public class GregtechMetaTileEntityMultiTank - extends GregtechMeta_MultiBlockBase { - public GregtechMetaTileEntityMultiTank(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - private long fluidStored = 0; - private short multiblockCasingCount = 0; - private short storageMultiplier = getStorageMultiplier(); - private long maximumFluidStorage = getMaximumTankStorage(); - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mEUt", mEUt); - aNBT.setInteger("mProgresstime", mProgresstime); - aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); - aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); - aNBT.setInteger("mEfficiency", mEfficiency); - aNBT.setInteger("mPollution", mPollution); - aNBT.setInteger("mRuntime", mRuntime); - aNBT.setLong("mFluidStored", fluidStored); - aNBT.setShort("mStorageMultiplier", storageMultiplier); - aNBT.setLong("mMaxFluidStored", maximumFluidStorage); - aNBT.setShort("mCasingCount", multiblockCasingCount); - - if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++) - if (mOutputItems[i] != null) { - NBTTagCompound tNBT = new NBTTagCompound(); - mOutputItems[i].writeToNBT(tNBT); - aNBT.setTag("mOutputItem" + i, tNBT); - } - if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++) - if (mOutputFluids[i] != null) { - NBTTagCompound tNBT = new NBTTagCompound(); - mOutputFluids[i].writeToNBT(tNBT); - aNBT.setTag("mOutputFluids" + i, tNBT); - } - - aNBT.setBoolean("mWrench", mWrench); - aNBT.setBoolean("mScrewdriver", mScrewdriver); - aNBT.setBoolean("mSoftHammer", mSoftHammer); - aNBT.setBoolean("mHardHammer", mHardHammer); - aNBT.setBoolean("mSolderingTool", mSolderingTool); - aNBT.setBoolean("mCrowbar", mCrowbar); - } - - private short getStorageMultiplier(){ - int tempstorageMultiplier = (1*multiblockCasingCount); - if (tempstorageMultiplier <= 0){ - return 1; - } - return (short) tempstorageMultiplier; - } - - private long getMaximumTankStorage(){ - int multiplier = getStorageMultiplier(); - Utils.LOG_WARNING("x = "+multiplier+" * 96000"); - long tempTankStorageMax = (96000*multiplier); - Utils.LOG_WARNING("x = "+tempTankStorageMax); - if (tempTankStorageMax <= 0){ - return 96000; - } - return tempTankStorageMax; - } - - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mEUt = aNBT.getInteger("mEUt"); - mProgresstime = aNBT.getInteger("mProgresstime"); - mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - if (mMaxProgresstime > 0) mRunningOnLoad = true; - mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - mEfficiency = aNBT.getInteger("mEfficiency"); - mPollution = aNBT.getInteger("mPollution"); - mRuntime = aNBT.getInteger("mRuntime"); - fluidStored = aNBT.getLong("mFluidStored"); - storageMultiplier = aNBT.getShort("mStorageMultiplier"); - maximumFluidStorage = aNBT.getLong("mMaxFluidStored"); - multiblockCasingCount = aNBT.getShort("mCasingCount"); - mOutputItems = new ItemStack[getAmountOfOutputs()]; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - mOutputFluids = new FluidStack[getAmountOfOutputs()]; - for (int i = 0; i < mOutputFluids.length; i++) - mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); - mWrench = aNBT.getBoolean("mWrench"); - mScrewdriver = aNBT.getBoolean("mScrewdriver"); - mSoftHammer = aNBT.getBoolean("mSoftHammer"); - mHardHammer = aNBT.getBoolean("mHardHammer"); - mSolderingTool = aNBT.getBoolean("mSolderingTool"); - mCrowbar = aNBT.getBoolean("mCrowbar"); - } - - public GregtechMetaTileEntityMultiTank(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityMultiTank(this.mName); - } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Multitank", - "Size: 3xHx3 (Block behind controller must be air)", - "Structure must be at least 4 blocks tall, maximum 20.", - "Each casing within the structure adds 96000L storage.", - "Controller (front centered)", - "1x Input hatch (anywhere)", - "1x Output hatch (anywhere)", - "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", - "Multitank Exterior Casings for the rest (16 at least!)", - "Stored Fluid: "+fluidStored}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[68], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_STEAM_EXTRACTOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_STEAM_EXTRACTOR)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[68]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sVacuumRecipes; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - for (ItemStack tInput : tInputList) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sVacuumRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - updateSlots(); - return true; - } - } - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - Utils.LOG_WARNING("Must be hollow."); - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 19; h++) { - if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 17)) && (!addInputToMachineList(tTileEntity, 17)) && (!addOutputToMachineList(tTileEntity, 17)) && (!addEnergyInputToMachineList(tTileEntity, 17))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - if (h < 3){ - Utils.LOG_WARNING("Casing Expected."); - return false; - } - else if (h >= 3){ - //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); - } - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { - if (h < 3){ - Utils.LOG_WARNING("Wrong Meta."); - return false; - } - else if (h >= 3){ - //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); - } - } - if (h < 3){ - tAmount++; - } - else if (h >= 3){ - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ - Utils.LOG_WARNING("Found air"); - } - else { - Utils.LOG_WARNING("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); - tAmount++; - } - } - } - } - } - } - } - multiblockCasingCount = (short) tAmount; - Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); - Utils.LOG_INFO("Casings Count: "+tAmount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+getMaximumTankStorage()+"L"); - return tAmount >= 16; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityPowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityPowerSubStationController.java deleted file mode 100644 index b52495865e..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityPowerSubStationController.java +++ /dev/null @@ -1,189 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Config; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -public class GregtechMetaTileEntityPowerSubStationController extends GT_MetaTileEntity_MultiBlockBase { - - private int recipeCounter = 0; - - public GregtechMetaTileEntityPowerSubStationController(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityPowerSubStationController(String aName) { - super(aName); - } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Power Sub-Station", - "Stores quite a lot of power.", - "Size(WxHxD): 1x5x1, Controller (One above the Bottom)", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[67], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[67]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); - } - - @Override - public void onConfigLoad(GT_Config aConfig) { - super.onConfigLoad(aConfig); - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - for (int i = -2; i < 3; i++) { - for (int j = -2; j < 3; j++) { - for (int h = 0; h < 4; h++) { - - //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { - Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); - double tX = tTileEntity.getXCoord(); - double tY = tTileEntity.getYCoord(); - double tZ = tTileEntity.getZCoord(); - Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); - //return false; - }*/ - if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he - if (h == 0 && i != 0 && j != 0) {// innen boden (kantal coils) - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Block"); - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); - //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Meta"); - return false; - } - } - else if (h == 3 && i != 0 && j != 0) {// innen decke (ulv casings + input + muffler) - //if(j == 0 && i == 0) { - - if ((!addMufflerToMachineList(tTileEntity, 66))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - } - //} - - } /*else {// top air - if ((i != -2 && i != 2) && (j != -2 && j != 2) && h == 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Block"); - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); - //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Meta"); - return false; - } - } - }*/ - } else {// Outer 5x5 - if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) - if ((!addEnergyInputToMachineList(tTileEntity, 66) && (!addDynamoToMachineList(tTileEntity, 66)))) { - if ((xDir + i != 0) || (zDir + j != 0)) {//no controller - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer. "+(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName())); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer. 2"); - return false; - } - } - } - } else { - - } - } - } - } - } - Utils.LOG_INFO("Multiblock Formed."); - return true; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityPowerSubStationController(this.mName); - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastFurnace.java new file mode 100644 index 0000000000..f717bdf001 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastFurnace.java @@ -0,0 +1,214 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_AlloyBlastFurnace + extends GT_MetaTileEntity_MultiBlockBase { + private int mHeatingCapacity = 0; + + public GregtechMetaTileEntity_AlloyBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_AlloyBlastFurnace(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_AlloyBlastFurnace(this.mName); + } + + public String[] getDescription() { + return new String[]{"Controller Block for the Blast Furnace", "Size: 3x3x4 (Hollow)", "Controller (front middle at bottom)", "16x Heating Coils (two middle Layers, hollow)", "1x Input (one of bottom)", "1x Output (one of bottom)", "1x Energy Hatch (one of bottom)", "1x Maintenance Hatch (one of bottom)", "1x Muffler Hatch (top middle)", "Heat Proof Machine Casings for the rest"}; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[11], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[11]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "ElectricBlastFurnace.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBlastRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + ArrayList tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBlastRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (this.mHeatingCapacity >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots(); + return true; + } + } + return false; + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + this.mHeatingCapacity = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + if (!aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir)) { + return false; + } + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), 11); + + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); + switch (tUsedMeta) { + case 12: + this.mHeatingCapacity = 1800; + break; + case 13: + this.mHeatingCapacity = 2700; + break; + case 14: + this.mHeatingCapacity = 3600; + break; + default: + return false; + } + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 11) { + return false; + } + } + } + } + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((xDir + i != 0) || (zDir + j != 0)) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 11)) && (!addInputToMachineList(tTileEntity, 11)) && (!addOutputToMachineList(tTileEntity, 11)) && (!addEnergyInputToMachineList(tTileEntity, 11))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 11) { + return false; + } + } + } + } + } + this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); + return true; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 10; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 2; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java new file mode 100644 index 0000000000..df3742c46e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -0,0 +1,320 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.CORE.configSwitches; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks.CustomIcon; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.ArrayUtils; + +public class GregtechMetaTileEntity_IndustrialCentrifuge +extends GregtechMeta_MultiBlockBase { + private static boolean controller; + private static boolean isDisabled = false; + private static ITexture frontFace; + private static ITexture frontFaceActive; + private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static CustomIcon GT9_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + //public static double recipesComplete = 0; + + public GregtechMetaTileEntity_IndustrialCentrifuge(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + frontFaceActive = new GT_RenderedTexture(GT9_5_Active); + frontFace = new GT_RenderedTexture(GT9_5); + } + + public GregtechMetaTileEntity_IndustrialCentrifuge(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Centrifuge", + "Size: 3x3x3 (Hollow)", + "Controller (Front Center) [Orange]", + "1x Maintenance Hatch (Rear Center) [Green]", + "The rest can be placed anywhere except the Front [Red]", + "1x Input Hatch", + "1x Output Hatch", + "1x Input Bus", + "1x Output Bus", + "1x [EV] Energy Hatch (Can be higher Tier) [Blue]", + "Centrifuge Casings for the rest (16 at least)", + CORE.GT_Tooltip}; + } + + + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? frontFaceActive : frontFace : Textures.BlockIcons.CASING_BLOCKS[57]}; + } + + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialCentrifuge.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + ArrayList tInputList = getStoredInputs(); + GT_Recipe mLastRecipe; + + @Override + public boolean checkRecipe(ItemStack aStack) { + /*if (!isCorrectMachinePart(mInventory[1])) { + return false; + }*/ + + Utils.LOG_WARNING("Centrifuge Debug - 1"); + GT_Recipe.GT_Recipe_Map map = getRecipeMap(); + if (map == null) { + Utils.LOG_WARNING("Centrifuge Debug - False - No recipe map"); + return false; + } + Utils.LOG_WARNING("Centrifuge Debug - 2"); + ArrayList tInputList = getStoredInputs(); + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + Utils.LOG_WARNING("Centrifuge Debug - Tier variable: "+tTier); + ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); + ArrayList tFluidList = getStoredFluids(); + FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); + if (tInputList.size() > 0 || tFluids.length > 0) { + GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if (tRecipe != null) { + Utils.LOG_WARNING("Recipe was not invalid"); + mLastRecipe = tRecipe; + this.mEUt = 0; + this.mOutputItems = null; + this.mOutputFluids = null; + if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { + + Utils.LOG_WARNING("False: 1"); + return false; + } + + this.mMaxProgresstime = tRecipe.mDuration; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + Utils.LOG_WARNING("Centrifuge Debug - 2 - Max Progress Time: "+this.mMaxProgresstime); + if (tRecipe.mEUt <= 16) { + Utils.LOG_WARNING("Centrifuge Debug - Using < 16eu/t"); + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + Utils.LOG_WARNING("Centrifuge Debug - 3.1 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); + } else { + Utils.LOG_WARNING("Centrifuge Debug - using > 16eu/t"); + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + Utils.LOG_WARNING("Centrifuge Debug - 3.2 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + Utils.LOG_WARNING("Centrifuge Debug - 4 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); + } + } + this.mEUt *= 1; + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + Utils.LOG_WARNING("Centrifuge Debug - 5 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); + } + ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + tOut[h] = tRecipe.getOutput(h).copy(); + tOut[h].stackSize = 0; + } + FluidStack tFOut = null; + if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); + for (int f = 0; f < tOut.length; f++) { + if (tRecipe.mOutputs[f] != null && tOut[f] != null) { + for (int g = 0; g < 1; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + if (tFOut != null) { + int tSize = tFOut.amount; + tFOut.amount = tSize * 6; + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mMaxProgresstime /= 4; + if (this.mMaxProgresstime <= 0){ + this.mMaxProgresstime++; + } + Utils.LOG_WARNING("Centrifuge Debug - 6 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); + List overStacks = new ArrayList(); + for (int f = 0; f < tOut.length; f++) { + if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { + while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { + ItemStack tmp = tOut[f].copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); + overStacks.add(tmp); + } + } + } + if (overStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[overStacks.size()]; + tmp = overStacks.toArray(tmp); + tOut = ArrayUtils.addAll(tOut, tmp); + } + List tSList = new ArrayList(); + for (ItemStack tS : tOut) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOut = tSList.toArray(new ItemStack[tSList.size()]); + this.mOutputItems = tOut; + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); + Utils.LOG_WARNING("Centrifuge: True"); + return true; + } + } + Utils.LOG_WARNING("Centrifuge: Recipe was invalid."); + return false; + } + + @SuppressWarnings("static-method") + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + @SuppressWarnings("static-method") + public byte getCasingMeta() { + return 0; + } + + @SuppressWarnings("static-method") + public byte getCasingTextureIndex() { + return 0; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + if (configSwitches.disableCentrifugeFormation){ + EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(this.getBaseMetaTileEntity().getOwnerName()); + if (!player.getEntityWorld().isRemote && isDisabled == false) + PlayerUtils.messagePlayer(player, "This Multiblock is disabled via the config. [Only re-enable if you're bugtesting.]"); + isDisabled = true; + return false; + } + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + //Utils.LOG_WARNING("X:"+xDir+" Y:"+yDir+" Z:"+zDir); + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { //X-Dir + for (int j = -1; j < 2; j++) { //Z-Dir + for (int h = -1; h < 2; h++) { //Y-Dir + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + //Utils.LOG_WARNING("X:"+tTileEntity.getXCoord()+" Y:"+tTileEntity.getYCoord()+" Z:"+tTileEntity.getZCoord()); + if ((!addMaintenanceToMachineList(tTileEntity, 57)) && (!addInputToMachineList(tTileEntity, 57)) && (!addOutputToMachineList(tTileEntity, 57)) && (!addEnergyInputToMachineList(tTileEntity, 57))) { + + //Maintenance Hatch + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if (tTileEntity.getXCoord() == aBaseMetaTileEntity.getXCoord() && tTileEntity.getYCoord() == aBaseMetaTileEntity.getYCoord() && tTileEntity.getZCoord() == (aBaseMetaTileEntity.getZCoord()+2)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + Utils.LOG_WARNING("MAINT HATCH IN CORRECT PLACE"); + this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { + return false; + } + } + else { + Utils.LOG_WARNING("MAINT HATCH IN WRONG PLACE"); + } + } + + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { + return false; + } + tAmount++; + + } + } + } + } + } + return tAmount >= 16; + } + + @SuppressWarnings("static-method") + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; + } + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java new file mode 100644 index 0000000000..a19aaf26b1 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -0,0 +1,272 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; + +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_IndustrialCokeOven + extends GregtechMeta_MultiBlockBase { + private int mLevel = 0; + + public GregtechMetaTileEntity_IndustrialCokeOven(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialCokeOven(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{"Processes Logs and Coal into Charcoal and Coal Coke.", + "Controller Block for the Industrial Coke Oven", + "Size: 3x3x3 (Hollow)", + "Controller (front middle at bottom)", + "8x Heat Resistant/Proof Coils (middle Layer, hollow)", + "1x Input (one of bottom)", + "1x Output (one of bottom)", + "1x Energy Hatch (one of bottom)", + "1x Maintenance Hatch (one of bottom)", + "1x Muffler Hatch (top middle)", + "Structural Coke Oven Casings for the rest", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "CokeOven.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; + + } + + /* @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + }*/ + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (this.mLevel >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + updateSlots(); + //Utils.LOG_INFO("Coke oven: True"); + return true; + } + } + //Utils.LOG_INFO("Coke oven: False"); + return false; + } + /*public boolean checkRecipe(ItemStack aStack) { + ArrayList tInputList = getStoredInputs(); + if (!tInputList.isEmpty()) { + byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); + + int j = 0; + this.mOutputItems = new ItemStack[12 * this.mLevel]; + for (int i = 0; (i < 100) && (j < this.mOutputItems.length); i++) { + if (null != (this.mOutputItems[j] = GT_ModHandler.getSmeltingOutput((ItemStack) tInputList.get(i % tInputList.size()), true, null))) { + j++; + } + } + if (j > 0) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + this.mEUt = (-4 * (1 << tTier - 1) * (1 << tTier - 1) * this.mLevel); + this.mMaxProgresstime = Math.max(1, 512 / (1 << tTier - 1)); + } + updateSlots(); + return true; + } + return false; + }*/ + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int xr = aBaseMetaTileEntity.getXCoord(); + int yr = aBaseMetaTileEntity.getYCoord(); + int zr = aBaseMetaTileEntity.getZCoord(); + this.mLevel = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), GTID+1); + + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); + switch (tUsedMeta) { + case 2: + this.mLevel = 1; + break; + case 3: + this.mLevel = 2; + break; + default: + return false; + } + this.mOutputItems = new ItemStack[12 * this.mLevel]; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 1) { + return false; + } + } + } + } + for (int i = -1; i < 2; i++) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 1 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + for (int j = -1; j < 2; j++) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 2 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + if ((xDir + i != 0) || (zDir + j != 0)) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 3 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, GTID+1)) && (!addInputToMachineList(tTileEntity, GTID+1)) && (!addOutputToMachineList(tTileEntity, GTID+1)) && (!addEnergyInputToMachineList(tTileEntity, GTID+1))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 1) { + return false; + } + } + } + } + } + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + /* @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + }*/ + + @Override + public int getAmountOfOutputs() { + return 24; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java new file mode 100644 index 0000000000..9b16e0cee9 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java @@ -0,0 +1,258 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.ArrayUtils; + +public class GregtechMetaTileEntity_IndustrialElectrolyzer +extends GT_MetaTileEntity_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialElectrolyzer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialElectrolyzer(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{"Controller Block for the Industrial Electrolyzer", + "Size: 3x3x3 (Hollow)", + "Controller (front centered)", + "1x Input Bus (anywhere)", + "1x Output Bus (anywhere)", + "1x Input Hatch (anywhere)", + "1x Output Hatch (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "1x Muffler (anywhere)", + "Electrolyzer Casings for the rest (16 at least!)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5], new GT_RenderedTexture(aActive ? Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE : Textures.BlockIcons.STEAM_TURBINE_SIDE)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialElectrolyzer.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + ArrayList tInputList = getStoredInputs(); + GT_Recipe mLastRecipe; + + @Override + public boolean checkRecipe(ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full + ArrayList tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (7500 >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + tOut[h] = tRecipe.getOutput(h).copy(); + tOut[h].stackSize = 0; + } + FluidStack tFOut = null; + if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); + for (int f = 0; f < tOut.length; f++) { + if (tRecipe.mOutputs[f] != null && tOut[f] != null) { + for (int g = 0; g < 1; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + if (tFOut != null) { + int tSize = tFOut.amount; + tFOut.amount = tSize * 1; + } + + List overStacks = new ArrayList(); + for (int f = 0; f < tOut.length; f++) { + if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { + while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { + ItemStack tmp = tOut[f].copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); + overStacks.add(tmp); + } + } + } + if (overStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[overStacks.size()]; + tmp = overStacks.toArray(tmp); + tOut = ArrayUtils.addAll(tOut, tmp); + } + List tSList = new ArrayList(); + for (ItemStack tS : tOut) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOut = tSList.toArray(new ItemStack[tSList.size()]); + this.mOutputItems = tOut; + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); + + /* this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots();*/ + return true; + } + } + return false; + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 62)) && (!addMufflerToMachineList(tTileEntity, 62)) && (!addInputToMachineList(tTileEntity, 62)) && (!addOutputToMachineList(tTileEntity, 62)) && (!addEnergyInputToMachineList(tTileEntity, 62))) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (((tBlock != ModBlocks.blockCasingsMisc) || (tMeta != 5))) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java new file mode 100644 index 0000000000..4748fae57b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java @@ -0,0 +1,278 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMetaTileEntity_IndustrialMacerator +extends GregtechMeta_MultiBlockBase { + private static boolean controller; + + public GregtechMetaTileEntity_IndustrialMacerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialMacerator(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Maceration Stack", + "Size[WxHxL]: 3x6x3 (Hollow)", + "Controller (Center Bottom)", + "1x Input Bus (Any bottom layer casing)", + "5x Output Bus (Any casing besides bottom layer)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Maceration Stack Casings for the rest (26 at least!)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MacerationStack.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + } + + /*@Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + }*/ + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, aBaseMetaTileEntity.getYCoord() + 0.3f + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 1.2F - tRandom.nextFloat() * 1.6F, 0.0D, 0.0D, 0.0D); + } + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(201)), 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public void startProcess() { + sendLoopStart((byte) 1); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + if (tInputList.size() > 0) { + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + this.mEUt = (-tRecipe.mEUt); + this.mMaxProgresstime = Math.max(1, (tRecipe.mDuration/5)); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + sendLoopStart((byte) 20); + updateSlots(); + return true; + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + int tAmount = 0; + controller = false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 6; h++) { + if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) + { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 64)) && (!addInputToMachineList(tTileEntity, 64)) && (!addOutputToMachineList(tTileEntity, 64)) && (!addEnergyInputToMachineList(tTileEntity, 64)) && (!ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Returned False 1"); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 7) { + Utils.LOG_INFO("Returned False 2"); + return false; + } + tAmount++; + } + } + } + } + } + if (this.mOutputHatches.size() != 0 || this.mInputBusses.size() != 1 || this.mOutputBusses.size() != 5) { + Utils.LOG_INFO("Returned False 3"); + return false; + } + int height = this.getBaseMetaTileEntity().getYCoord(); + if (this.mInputBusses.get(0).getBaseMetaTileEntity().getYCoord() != height) { + Utils.LOG_INFO("height: "+height+" | Returned False 4"); + return false; + } + GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; + for (int i = 0; i < this.mOutputBusses.size(); i++) { + int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; + if (tmpHatches[hatchNumber] == null) { + tmpHatches[hatchNumber] = this.mOutputBusses.get(i); + } else { + Utils.LOG_INFO("Returned False 5"); + return false; + } + } + this.mOutputBusses.clear(); + for (int i = 0; i < tmpHatches.length; i++) { + this.mOutputBusses.add(tmpHatches[i]); + } + return tAmount >= 26; + } + + /*public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + int tAmount = 0; + controller = false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 6; h++) { + if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) + { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 64)) && (!addInputToMachineList(tTileEntity, 64)) && (!addOutputToMachineList(tTileEntity, 64)) && (!addEnergyInputToMachineList(tTileEntity, 64)) && (!ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { + return false; + } + tAmount++; + } + } + } + } + } + if (this.mOutputBusses.size() != 5 || this.mInputBusses.size() != 1) { + return false; + } + int height = this.getBaseMetaTileEntity().getYCoord(); + if (this.mInputHatches.get(0).getBaseMetaTileEntity().getYCoord() != height) { + return false; + } + GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; + for (int i = 0; i < this.mOutputBusses.size(); i++) { + int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; + if (tmpHatches[hatchNumber] == null) { + tmpHatches[hatchNumber] = this.mOutputBusses.get(i); + } else { + return false; + } + } + this.mOutputBusses.clear(); + for (int i = 0; i < tmpHatches.length; i++) { + this.mOutputBusses.add(tmpHatches[i]); + } + return tAmount >= 26; + }*/ + + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; + } + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + /*@Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + }*/ + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java new file mode 100644 index 0000000000..ee49b7fcb9 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java @@ -0,0 +1,263 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class GregtechMetaTileEntity_IndustrialSinter +extends GT_MetaTileEntity_MultiBlockBase { + + + RenderBlocks asdasd = RenderBlocks.getInstance(); + + public GregtechMetaTileEntity_IndustrialSinter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialSinter(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialSinter(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Sinter Furnace", + "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", + "2x Input Bus (side centered)", + "2x Output Bus (side centered)", + "1x Energy Hatch (top or bottom centered)", + "1x Maintenance Hatch (back centered)", + "Sinter Furnace Casings for the rest (32 at least!)", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "WireFactory.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tInputList = getStoredInputs(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + updateSlots(); + return true; + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int controllerX = aBaseMetaTileEntity.getXCoord(); + int controllerY = aBaseMetaTileEntity.getYCoord(); + int controllerZ = aBaseMetaTileEntity.getZCoord(); + + byte tSide = getBaseMetaTileEntity().getBackFacing(); + if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { + int tAirCount = 0; + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + for (byte k = -1; k < 2; k = (byte) (k + 1)) { + if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { + Utils.LOG_INFO("Found Air at: "+(controllerX+i)+" "+(controllerY+k)+" "+(controllerZ+k)); + //if (aBaseMetaTileEntity.getWorld().isRemote){ + //asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, (controllerX+i), (controllerY+k), (controllerZ+k)); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.YELLOW_GREEN); + //} + tAirCount++; + } + } + } + } + if (tAirCount != 10) { + Utils.LOG_INFO("False. Air != 10. Air == "+tAirCount); + //return false; + } + for (byte i = 2; i < 6; i = (byte) (i + 1)) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ), Color.LIME_GREEN); + IGregTechTileEntity tTileEntity; + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialSinter))) { + //Utils.LOG_INFO("False 1"); + return false; + } + } + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 5; k = (byte) (k + 1)) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.ORANGE); + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.TOMATO); + if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } + else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { + Utils.LOG_INFO("False 2"); + return false; + } + } + else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } + else { + Utils.LOG_INFO("False 3"); + return false; + } + } + } + } + } + if (this.mOutputHatches.size() != 0 || this.mInputHatches.size() != 0) { + Utils.LOG_INFO("Use Busses, Not Hatches for Input/Output."); + return false; + } + if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { + Utils.LOG_INFO("Incorrect amount of Input & Output busses."); + return false; + } + this.mMaintenanceHatches.clear(); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { + Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); + return false; + } + } + if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1) { + Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); + return false; + } + } else { + Utils.LOG_INFO("False 5"); + return false; + } + Utils.LOG_INFO("True"); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + + public byte getCasingMeta() { + return 6; + } + + + public byte getCasingTextureIndex() { + return 63; + } + + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + } + + private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { + return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java new file mode 100644 index 0000000000..27d70992cf --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java @@ -0,0 +1,246 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class GregtechMetaTileEntity_IndustrialWireMill +extends GT_MetaTileEntity_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialWireMill(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialWireMill(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Wire Factory", + "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", + "2x Input Bus (side centered)", + "2x Output Bus (side centered)", + "1x Energy Hatch (top or bottom centered)", + "1x Maintenance Hatch (back centered)", + "Wire Factory Casings for the rest (32 at least!)", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "WireFactory.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tInputList = getStoredInputs(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + updateSlots(); + return true; + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + byte tSide = getBaseMetaTileEntity().getBackFacing(); + if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { + int tAirCount = 0; + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + for (byte k = -1; k < 2; k = (byte) (k + 1)) { + if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { + tAirCount++; + } + } + } + } + if (tAirCount != 10) { + Utils.LOG_INFO("False 1"); + return false; + } + for (byte i = 2; i < 6; i = (byte) (i + 1)) { + IGregTechTileEntity tTileEntity; + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialWireMill))) { + //Utils.LOG_INFO("False 1"); + return false; + } + } + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 5; k = (byte) (k + 1)) { + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { + if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } + else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { + Utils.LOG_INFO("False 2"); + return false; + } + } + else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } + else { + Utils.LOG_INFO("False 3"); + return false; + } + } + } + } + } + if (this.mOutputHatches.size() != 0 || this.mInputHatches.size() != 0) { + Utils.LOG_INFO("Use Busses, Not Hatches for Input/Output."); + return false; + } + if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { + Utils.LOG_INFO("Incorrect amount of Input & Output busses."); + return false; + } + this.mMaintenanceHatches.clear(); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { + Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); + return false; + } + } + if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1) { + Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); + return false; + } + } else { + Utils.LOG_INFO("False 5"); + return false; + } + Utils.LOG_INFO("True"); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + + public byte getCasingMeta() { + return 6; + } + + + public byte getCasingTextureIndex() { + return 63; + } + + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + } + + private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { + return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java new file mode 100644 index 0000000000..dbb3d599a1 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java @@ -0,0 +1,380 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +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.MetaTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_IronBlastFurnace; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_IronBlastFurnace; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMetaTileEntity_IronBlastFurnace + extends MetaTileEntity { + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Top)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_Off)}; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_On)}; + public int mMaxProgresstime = 0; + public int mUpdate = 30; + public int mProgresstime = 0; + public boolean mMachine = false; + public ItemStack mOutputItem1; + public ItemStack mOutputItem2; + + public GregtechMetaTileEntity_IronBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 4); + } + + public GregtechMetaTileEntity_IronBlastFurnace(String aName) { + super(aName, 4); + } + + @Override + public String[] getDescription() { + return new String[]{"Sloooowly, Skip the Bronze age, Get some Steel!", + "Multiblock: 3x3x5 hollow with opening on top", + "40 Iron Plated Bricks required", + "----", + "Even though Iron melts hotter than bronze,", + "this machine is to help players skip looking", + "for tin and copper, which are not as common", + "as Iron is. This machine takes 5x longer than the bronze", + "blast furnace as a result.", + "----", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return aActive ? FACING_ACTIVE : FACING_FRONT; + } + return FACING_SIDE; + } + + @Override + public boolean isSteampowered() { + return false; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) { + return false; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return this.mProgresstime; + } + + @Override + public int maxProgresstime() { + return this.mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + this.mProgresstime += aProgress; + return this.mMaxProgresstime - this.mProgresstime; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mProgresstime", this.mProgresstime); + aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); + if (this.mOutputItem1 != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem1.writeToNBT(tNBT); + aNBT.setTag("mOutputItem1", tNBT); + } + if (this.mOutputItem2 != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem2.writeToNBT(tNBT); + aNBT.setTag("mOutputItem2", tNBT); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mUpdate = 30; + this.mProgresstime = aNBT.getInteger("mProgresstime"); + this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); + this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + private boolean checkMachine() { + int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 4; j++) { //This is height + for (int k = -1; k < 2; k++) { + if ((xDir + i != 0) || (j != 0) || (zDir + k != 0)) { + if ((i != 0) || (j == -1) || (k != 0)) { + if ((getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) != ModBlocks.blockCasingsMisc) || (getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) { + return false; + } + } else if ((!GT_Utility.arrayContains(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[]{Blocks.lava, Blocks.flowing_lava, null})) && (!getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { + return false; + } + } + } + } + } + return true; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 30; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if ((aBaseMetaTileEntity.isClientSide()) && + (aBaseMetaTileEntity.isActive())) { + aBaseMetaTileEntity.getWorld().spawnParticle("cloud", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, 0.0D); + } + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate-- == 0) { + this.mMachine = checkMachine(); + } + if (this.mMachine) { + if (this.mMaxProgresstime > 0) { + if (++this.mProgresstime >= this.mMaxProgresstime) { + addOutputProducts(); + this.mOutputItem1 = null; + this.mOutputItem2 = null; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + try { + // GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel"); + } catch (Exception e) { + } + } + } else if (aBaseMetaTileEntity.isAllowedToWork()) { + checkRecipe(); + } + } + aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); + if (aBaseMetaTileEntity.isActive()) { + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); + this.mUpdate = 1; + } + } else { + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); + this.mUpdate = 1; + } + } + } + } + + private void addOutputProducts() { + if (this.mOutputItem1 != null) { + if (this.mInventory[2] == null) { + this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1}); + } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { + this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize); + } + } + if (this.mOutputItem2 != null) { + if (this.mInventory[3] == null) { + this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2}); + } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { + this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize); + } + } + } + + private boolean spaceForOutput(ItemStack aStack1, ItemStack aStack2) { + if (((this.mInventory[2] == null) || (aStack1 == null) || ((this.mInventory[2].stackSize + aStack1.stackSize <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && ( + (this.mInventory[3] == null) || (aStack2 == null) || ((this.mInventory[3].stackSize + aStack2.stackSize <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { + return true; + } + return false; + } + + private boolean checkRecipe() { + if (!this.mMachine) { + return false; + } + if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = 36000; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = 4800*5; + return true; + } + if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 9); + getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = 64800*5; + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = 3600*5; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 1*3); + this.mMaxProgresstime = 2400*5; + return true; + } + if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 9); + getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = 32400*5; + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 64); + this.mMaxProgresstime = 64800*9; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 18*3); + this.mMaxProgresstime = 43200*5; + return true; + } + if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = 64800*5; + return true; + } + } + } + this.mOutputItem1 = null; + this.mOutputItem2 = null; + return false; + } + + @Override + public boolean isGivingInformation() { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex > 1; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aIndex < 2) { + } + return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); + } + + @Override + public byte getTileEntityBaseType() { + return 0; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java new file mode 100644 index 0000000000..9bd6bdb2a6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java @@ -0,0 +1,353 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; + +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.ArrayUtils; + +public class GregtechMetaTileEntity_MassFabricator extends GT_MetaTileEntity_MultiBlockBase { + + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3215; + public static boolean sRequiresUUA = false; + private int mAmplifierUsed = 0; + private int mMatterProduced = 0; + private static Block IC2Glass = Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass")); + FluidStack tempFake = FluidUtils.getFluidStack("uuamplifier", 1); + GT_Recipe fakeRecipe; + + public int getAmplifierUsed(){ + return mAmplifierUsed; + } + + public int getMatterProduced(){ + return mMatterProduced; + } + + //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); + + public GregtechMetaTileEntity_MassFabricator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_MassFabricator(String aName) { + super(aName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Matter Fabricator", + "Produces UU-Matter from UU-Amplifier", + "Size(WxHxD): 5x4x5, Controller (Bottom center)", + "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", + "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", + "1x Input Hatch (Any bottom layer casing)", + "1x Output Hatch (Any bottom layer casing)", + "1x Maintenance Hatch (Any bottom layer casing)", + "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", + "1x Energy Hatch (Any bottom layer casing)", + "24x IC2 Reinforced Glass for the walls", + "Matter Fabricator Casings for the edges & top (40 at least!)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66], + new GT_RenderedTexture(aActive ? TexturesGtBlocks.Casing_Machine_Screen_3 : TexturesGtBlocks.Casing_Machine_Screen_1)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) { + super.onConfigLoad(aConfig); + sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUM_Duration_Multiplier", sDurationMultiplier); + sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_per_UUM", sUUAperUUM); + sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Speed_Bonus", sUUASpeedBonus); + sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Requirement", sRequiresUUA); + Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, tFluidList.size()); + if (tFluids.length > 0) { + //Utils.LOG_INFO("Input fluid found"); + for(int i = 0;i 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + this.mOutputFluids = tRecipe.mFluidOutputs.clone(); + ArrayUtils.reverse(mOutputFluids); + mMatterProduced++; + mAmplifierUsed++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + return true; + } + } + else { + //Utils.LOG_INFO("Invalid Recipe"); + return false; + } + } + } + else if (tFluids.length == 0) { + //Utils.LOG_INFO("Input fluid not found"); + fakeRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tempFake}, new ItemStack[]{}); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + this.mEUt = 32; + this.mMaxProgresstime = (160*20); + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + if (fakeRecipe != null) { + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{fakeRecipe.getOutput(0)}; + this.mOutputFluids = fakeRecipe.mFluidOutputs.clone(); + ArrayUtils.reverse(mOutputFluids); + mMatterProduced++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + return true; + } + } + else { + //Utils.LOG_INFO("Invalid no input Recipe"); + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + for (int h = 0; h < 4; h++) { + + //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { + Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); + double tX = tTileEntity.getXCoord(); + double tY = tTileEntity.getYCoord(); + double tZ = tTileEntity.getZCoord(); + Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); + //return false; + }*/ + if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he + if (h == 0) {// innen boden (kantal coils) + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); + return false; + } + } else if (h == 3) {// innen decke (ulv casings + input + muffler) + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + } + } else {// innen air + if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { + Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); + return false; + } + } + } else {// Outer 5x5 + if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) + if ((!addMaintenanceToMachineList(tTileEntity, 66)) && (!addInputToMachineList(tTileEntity, 66)) && (!addOutputToMachineList(tTileEntity, 66)) && (!addEnergyInputToMachineList(tTileEntity, 66))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); + return false; + } + } + } + } else {// au�en �ber boden (ulv casings) + if (h == 1) { + + if ((i == -2 || i == 2) && (j == -2 || j == 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + return false; + } + } + + else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { + Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); + return false; + } + } + } + if (h == 2) { + if ((i == -2 || i == 2) && (j == -2 || j == 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); + return false; + } + } + + else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { + Utils.LOG_INFO("Glass Casings Missing from somewhere in the third layer."); + return false; + } + } + } + if (h == 3) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); + return false; + } + } + } + } + } + } + } + Utils.LOG_INFO("Multiblock Formed."); + return true; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MassFabricator(this.mName); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java new file mode 100644 index 0000000000..32759c4024 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java @@ -0,0 +1,284 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; + +import java.util.ArrayList; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_MultiTank + extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_MultiTank(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private long fluidStored = 0; + private short multiblockCasingCount = 0; + private short storageMultiplier = getStorageMultiplier(); + private long maximumFluidStorage = getMaximumTankStorage(); + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setInteger("mEfficiency", mEfficiency); + aNBT.setInteger("mPollution", mPollution); + aNBT.setInteger("mRuntime", mRuntime); + aNBT.setLong("mFluidStored", fluidStored); + aNBT.setShort("mStorageMultiplier", storageMultiplier); + aNBT.setLong("mMaxFluidStored", maximumFluidStorage); + aNBT.setShort("mCasingCount", multiblockCasingCount); + + if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++) + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + + aNBT.setBoolean("mWrench", mWrench); + aNBT.setBoolean("mScrewdriver", mScrewdriver); + aNBT.setBoolean("mSoftHammer", mSoftHammer); + aNBT.setBoolean("mHardHammer", mHardHammer); + aNBT.setBoolean("mSolderingTool", mSolderingTool); + aNBT.setBoolean("mCrowbar", mCrowbar); + } + + private short getStorageMultiplier(){ + int tempstorageMultiplier = (1*multiblockCasingCount); + if (tempstorageMultiplier <= 0){ + return 1; + } + return (short) tempstorageMultiplier; + } + + private long getMaximumTankStorage(){ + int multiplier = getStorageMultiplier(); + Utils.LOG_WARNING("x = "+multiplier+" * 96000"); + long tempTankStorageMax = (96000*multiplier); + Utils.LOG_WARNING("x = "+tempTankStorageMax); + if (tempTankStorageMax <= 0){ + return 96000; + } + return tempTankStorageMax; + } + + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mEUt = aNBT.getInteger("mEUt"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + if (mMaxProgresstime > 0) mRunningOnLoad = true; + mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + mEfficiency = aNBT.getInteger("mEfficiency"); + mPollution = aNBT.getInteger("mPollution"); + mRuntime = aNBT.getInteger("mRuntime"); + fluidStored = aNBT.getLong("mFluidStored"); + storageMultiplier = aNBT.getShort("mStorageMultiplier"); + maximumFluidStorage = aNBT.getLong("mMaxFluidStored"); + multiblockCasingCount = aNBT.getShort("mCasingCount"); + mOutputItems = new ItemStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + mOutputFluids = new FluidStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputFluids.length; i++) + mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + mWrench = aNBT.getBoolean("mWrench"); + mScrewdriver = aNBT.getBoolean("mScrewdriver"); + mSoftHammer = aNBT.getBoolean("mSoftHammer"); + mHardHammer = aNBT.getBoolean("mHardHammer"); + mSolderingTool = aNBT.getBoolean("mSolderingTool"); + mCrowbar = aNBT.getBoolean("mCrowbar"); + } + + public GregtechMetaTileEntity_MultiTank(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MultiTank(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Multitank", + "Size: 3xHx3 (Block behind controller must be air)", + "Structure must be at least 4 blocks tall, maximum 20.", + "Each casing within the structure adds 96000L storage.", + "Controller (front centered)", + "1x Input hatch (anywhere)", + "1x Output hatch (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "Multitank Exterior Casings for the rest (16 at least!)", + "Stored Fluid: "+fluidStored}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[68], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_STEAM_EXTRACTOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_STEAM_EXTRACTOR)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[68]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sVacuumRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tInputList = getStoredInputs(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sVacuumRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + updateSlots(); + return true; + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + Utils.LOG_WARNING("Must be hollow."); + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 19; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 17)) && (!addInputToMachineList(tTileEntity, 17)) && (!addOutputToMachineList(tTileEntity, 17)) && (!addEnergyInputToMachineList(tTileEntity, 17))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + if (h < 3){ + Utils.LOG_WARNING("Casing Expected."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { + if (h < 3){ + Utils.LOG_WARNING("Wrong Meta."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (h < 3){ + tAmount++; + } + else if (h >= 3){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ + Utils.LOG_WARNING("Found air"); + } + else { + Utils.LOG_WARNING("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); + tAmount++; + } + } + } + } + } + } + } + multiblockCasingCount = (short) tAmount; + Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + Utils.LOG_INFO("Casings Count: "+tAmount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+getMaximumTankStorage()+"L"); + return tAmount >= 16; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java new file mode 100644 index 0000000000..45635ea74d --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java @@ -0,0 +1,189 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTileEntity_MultiBlockBase { + + private int recipeCounter = 0; + + public GregtechMetaTileEntity_PowerSubStationController(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_PowerSubStationController(String aName) { + super(aName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Power Sub-Station", + "Stores quite a lot of power.", + "Size(WxHxD): 1x5x1, Controller (One above the Bottom)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[67], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[67]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) { + super.onConfigLoad(aConfig); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + for (int h = 0; h < 4; h++) { + + //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { + Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); + double tX = tTileEntity.getXCoord(); + double tY = tTileEntity.getYCoord(); + double tZ = tTileEntity.getZCoord(); + Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); + //return false; + }*/ + if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he + if (h == 0 && i != 0 && j != 0) {// innen boden (kantal coils) + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Block"); + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); + //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Meta"); + return false; + } + } + else if (h == 3 && i != 0 && j != 0) {// innen decke (ulv casings + input + muffler) + //if(j == 0 && i == 0) { + + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + } + //} + + } /*else {// top air + if ((i != -2 && i != 2) && (j != -2 && j != 2) && h == 3) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Block"); + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); + //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { + Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Meta"); + return false; + } + } + }*/ + } else {// Outer 5x5 + if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) + if ((!addEnergyInputToMachineList(tTileEntity, 66) && (!addDynamoToMachineList(tTileEntity, 66)))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer. "+(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName())); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer. 2"); + return false; + } + } + } + } else { + + } + } + } + } + } + Utils.LOG_INFO("Multiblock Formed."); + return true; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_PowerSubStationController(this.mName); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCentrifuge.java index 14ccd6a142..226e0a44e1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCentrifuge.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCentrifuge.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialCentrifuge; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialCentrifuge; public class GregtechIndustrialCentrifuge { @@ -21,7 +21,7 @@ public class GregtechIndustrialCentrifuge private static void run1() { //Industrial Centrifuge Multiblock - GregtechItemList.Industrial_Centrifuge.set(new GregtechMetaTileEntityIndustrialCentrifuge(790, "industrialcentrifuge.controller.tier.single", "Industrial Centrifuge").getStackForm(1L)); + GregtechItemList.Industrial_Centrifuge.set(new GregtechMetaTileEntity_IndustrialCentrifuge(790, "industrialcentrifuge.controller.tier.single", "Industrial Centrifuge").getStackForm(1L)); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCokeOven.java index 15e1be1e6a..fd17cb5a40 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCokeOven.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCokeOven.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialCokeOven; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialCokeOven; public class GregtechIndustrialCokeOven { @@ -21,7 +21,7 @@ public class GregtechIndustrialCokeOven private static void run1() { //Industrial Centrifuge Multiblock - GregtechItemList.Industrial_CokeOven.set(new GregtechMetaTileEntityIndustrialCokeOven(791, "industrialcokeoven.controller.tier.single", "Industrial Coke Oven").getStackForm(1L)); + GregtechItemList.Industrial_CokeOven.set(new GregtechMetaTileEntity_IndustrialCokeOven(791, "industrialcokeoven.controller.tier.single", "Industrial Coke Oven").getStackForm(1L)); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElectrolyzer.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElectrolyzer.java index e165430580..9282148bb2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElectrolyzer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElectrolyzer.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialElectrolyzer; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialElectrolyzer; public class GregtechIndustrialElectrolyzer { @@ -21,7 +21,7 @@ public class GregtechIndustrialElectrolyzer private static void run1() { //Industrial Electrolyzer Multiblock - GregtechItemList.Industrial_Electrolyzer.set(new GregtechMetaTileEntityIndustrialElectrolyzer(796, "industrialelectrolyzer.controller.tier.single", "Industrial Electrolyzer").getStackForm(1L)); + GregtechItemList.Industrial_Electrolyzer.set(new GregtechMetaTileEntity_IndustrialElectrolyzer(796, "industrialelectrolyzer.controller.tier.single", "Industrial Electrolyzer").getStackForm(1L)); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMacerator.java index 110e729f75..aaecc281c6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMacerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMacerator.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialMacerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialMacerator; public class GregtechIndustrialMacerator { @@ -21,7 +21,7 @@ public class GregtechIndustrialMacerator private static void run1() { //Industrial Electrolyzer Multiblock - GregtechItemList.Industrial_MacerationStack.set(new GregtechMetaTileEntityIndustrialMacerator(797, "industrialmacerator.controller.tier.single", "Maceration Stack Controller").getStackForm(1L)); + GregtechItemList.Industrial_MacerationStack.set(new GregtechMetaTileEntity_IndustrialMacerator(797, "industrialmacerator.controller.tier.single", "Maceration Stack Controller").getStackForm(1L)); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java index dcbc25ae88..6093d2b534 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityMassFabricator; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_MassFabricator; public class GregtechIndustrialMassFabricator { @@ -21,7 +21,7 @@ public class GregtechIndustrialMassFabricator private static void run1() { //Industrial Electrolyzer Multiblock - GregtechItemList.Industrial_MassFab.set(new GregtechMetaTileEntityMassFabricator(799, "industrialmassfab.controller.tier.single", "Matter Fabrication CPU").getStackForm(1L)); + GregtechItemList.Industrial_MassFab.set(new GregtechMetaTileEntity_MassFabricator(799, "industrialmassfab.controller.tier.single", "Matter Fabrication CPU").getStackForm(1L)); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiTank.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiTank.java index 2aa3bdbbb3..8477ba2e31 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiTank.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityMultiTank; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_MultiTank; public class GregtechIndustrialMultiTank { @@ -20,7 +20,7 @@ public class GregtechIndustrialMultiTank private static void run1() { - GregtechItemList.Industrial_MultiTank.set(new GregtechMetaTileEntityMultiTank(827, "multitank.controller.tier.single", "Gregtech Multitank").getStackForm(1L)); + GregtechItemList.Industrial_MultiTank.set(new GregtechMetaTileEntity_MultiTank(827, "multitank.controller.tier.single", "Gregtech Multitank").getStackForm(1L)); //GregtechItemList.Industrial_MultiTankDense.set(new GregtechMetaTileEntityMultiTankDense(828, "multitankdense.controller.tier.single", "Gregtech Dense Multitank").getStackForm(1L)); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialPlatePress.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialPlatePress.java index 96f26f050a..72fc342d62 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialPlatePress.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialPlatePress.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialPlatePress; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrial_PlatePress; public class GregtechIndustrialPlatePress { @@ -21,7 +21,7 @@ public class GregtechIndustrialPlatePress private static void run1() { //Industrial Centrifuge Multiblock - GregtechItemList.Industrial_PlatePress.set(new GregtechMetaTileEntityIndustrialPlatePress(792, "industrialbender.controller.tier.single", "Industrial Material Press").getStackForm(1L)); + GregtechItemList.Industrial_PlatePress.set(new GregtechMetaTileEntityIndustrial_PlatePress(792, "industrialbender.controller.tier.single", "Industrial Material Press").getStackForm(1L)); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSinter.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSinter.java index d8ce73f460..d03554224c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSinter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSinter.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialSinter; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialSinter; public class GregtechIndustrialSinter{ @@ -18,7 +18,7 @@ public class GregtechIndustrialSinter{ private static void run1() { //Industrial Electrolyzer Multiblock - GregtechItemList.Industrial_SinterFurnace.set(new GregtechMetaTileEntityIndustrialSinter(810, "industrialsinterfurnace.controller.tier.single", "Sinter Furnace").getStackForm(1L)); + GregtechItemList.Industrial_SinterFurnace.set(new GregtechMetaTileEntity_IndustrialSinter(810, "industrialsinterfurnace.controller.tier.single", "Sinter Furnace").getStackForm(1L)); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWiremill.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWiremill.java index 2d69a2c6e3..15339bd2e3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWiremill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWiremill.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialWireMill; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialWireMill; public class GregtechIndustrialWiremill { @@ -21,7 +21,7 @@ public class GregtechIndustrialWiremill private static void run1() { //Industrial Electrolyzer Multiblock - GregtechItemList.Industrial_WireFactory.set(new GregtechMetaTileEntityIndustrialWireMill(798, "industrialwiremill.controller.tier.single", "Wire Factory Controller").getStackForm(1L)); + GregtechItemList.Industrial_WireFactory.set(new GregtechMetaTileEntity_IndustrialWireMill(798, "industrialwiremill.controller.tier.single", "Wire Factory Controller").getStackForm(1L)); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java index 38768557bc..9f08fed763 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIronBlastFurnace; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IronBlastFurnace; public class GregtechIronBlastFurnace { @@ -20,6 +20,6 @@ public class GregtechIronBlastFurnace private static void run1() { - GregtechItemList.Machine_Iron_BlastFurnace.set(new GregtechMetaTileEntityIronBlastFurnace(768, "ironmachine.blastfurnace", "Iron Plated Blast Furnace").getStackForm(1L)); + GregtechItemList.Machine_Iron_BlastFurnace.set(new GregtechMetaTileEntity_IronBlastFurnace(768, "ironmachine.blastfurnace", "Iron Plated Blast Furnace").getStackForm(1L)); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java index 05ef99f79f..c38c7eb21d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java @@ -2,7 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityPowerSubStationController; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_PowerSubStationController; public class GregtechPowerSubStation { @@ -21,7 +21,7 @@ public class GregtechPowerSubStation private static void run1() { //Steam Condensors - GregtechItemList.PowerSubStation.set(new GregtechMetaTileEntityPowerSubStationController(812, "substation.01.input.single", "Power Substation Node").getStackForm(1L)); + GregtechItemList.PowerSubStation.set(new GregtechMetaTileEntity_PowerSubStationController(812, "substation.01.input.single", "Power Substation Node").getStackForm(1L)); } } -- cgit From e5e1581403e9f6e9d76e362c5e4861b4258af7cc Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Tue, 25 Oct 2016 08:10:05 +1000 Subject: + Added some more Machine Casing textures. + Added Grisium. % Tweaked the MultiPickaxes. % Did some more work on the Blast Smelter controller. $ Finished work on the Blast Smelter Recipe generation (It's not unique enough yet, apparently) > After numerous re-write attempts at this all morning, the issue remains that recipes overlap. > Recipe output logging for this is still enabled, but it currently only does Osmiridium for a test run. - Removed some useless classes. --- .classpath | 2 +- src/Java/gregtech/api/util/Recipe_GT.java | 1 + src/Java/gtPlusPlus/GTplusplus.java | 1 + src/Java/gtPlusPlus/core/item/ModItems.java | 7 +- .../core/item/tool/staballoy/StaballoyPickaxe.java | 7 +- src/Java/gtPlusPlus/core/material/ALLOY.java | 16 + src/Java/gtPlusPlus/core/util/item/UtilsItems.java | 4 + src/Java/gtPlusPlus/core/util/math/MathUtils.java | 5 + src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 2 + .../xmod/gregtech/api/enums/GregtechItemList.java | 2 +- .../interfaces/internal/IGregtech_RecipeAdder.java | 13 + .../base/GT_MTE_BasicMachine_Custom_Recipe.java | 623 ---------------- .../base/GT_MTE_CustomRecipe_BasicMachine.java | 799 --------------------- .../xmod/gregtech/api/util/GregtechRecipe_OLD.java | 781 -------------------- .../common/blocks/GregtechMetaCasingBlocks.java | 8 +- .../blocks/textures/CasingTextureHandler.java | 14 +- .../common/blocks/textures/TexturesGtBlocks.java | 20 +- .../GregtechMetaTileEntity_AlloyBlastFurnace.java | 214 ------ .../GregtechMetaTileEntity_AlloyBlastSmelter.java | 239 ++++++ .../gregtech/loaders/RecipeGen_BlastSmelter.java | 169 +++++ .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 120 ++-- .../gregtech/GregtechEnergyBuffer.java | 1 - .../MACHINE_CASING_FIREBOX_STABALLOY.png | Bin 0 -> 3128 bytes .../TileEntities/MACHINE_CASING_STABLE_GRISIUM.png | Bin 0 -> 3141 bytes .../MACHINE_CASING_STABLE_INCOLOY_020.png | Bin 0 -> 3127 bytes .../MACHINE_CASING_STABLE_INCOLOY_DS.png | Bin 0 -> 3133 bytes .../MACHINE_CASING_STABLE_INCOLOY_MA956.png | Bin 0 -> 3127 bytes .../MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE.png | Bin 0 -> 3151 bytes 28 files changed, 562 insertions(+), 2486 deletions(-) delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_BasicMachine_Custom_Recipe.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_CustomRecipe_BasicMachine.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechRecipe_OLD.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastFurnace.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FIREBOX_STABALLOY.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_STABLE_GRISIUM.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_STABLE_INCOLOY_020.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_STABLE_INCOLOY_DS.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_STABLE_INCOLOY_MA956.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/.classpath b/.classpath index ea1e3f1774..750b7e9c87 100644 --- a/.classpath +++ b/.classpath @@ -12,7 +12,7 @@ - + diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 64e3dd9a35..979a6f17e5 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -235,6 +235,7 @@ public class Recipe_GT extends GT_Recipe{ public static final Gregtech_Recipe_Map_Fuel sRocketFuels = new Gregtech_Recipe_Map_Fuel(new HashSet(10), "gt.recipe.rocketenginefuel", "Rocket Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 3000, " EU", true, true); public static final Gregtech_Recipe_Map_Fuel sGeoThermalFuels = new Gregtech_Recipe_Map_Fuel(new HashSet(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map sChemicalDehydratorRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.chemicaldehydrator", "Chemical Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAlloyBlastSmelterRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.alloyblastsmelter", "Alloy Blast Smelter", null, RES_PATH_GUI + "basicmachines/Dehydrator", 9, 1, 1, 0, 1, E, 1, E, true, true); /** * HashMap of Recipes based on their Items diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index fd8d7a634c..4bb8a12836 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -169,6 +169,7 @@ implements ActionListener dumpGtRecipeMap(Gregtech_Recipe_Map.sCokeOvenRecipes); dumpGtRecipeMap(Gregtech_Recipe_Map.sMatterFab2Recipes); } + dumpGtRecipeMap(Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes); //~ ReflectionUtils.becauseIWorkHard(); diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 1a407e1fc6..e77f457487 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -236,10 +236,13 @@ public final class ModItems { generateItemsFromMaterial(ELEMENT.ZIRCONIUM); generateItemsFromMaterial(ALLOY.ZIRCONIUM_CARBIDE); generateItemsFromMaterial(ALLOY.TANTALUM_CARBIDE); - generateItemsFromMaterial(ALLOY.NIOBIUM_CARBIDE); + generateItemsFromMaterial(ALLOY.NIOBIUM_CARBIDE); + + //Leagrisium + generateItemsFromMaterial(ALLOY.LEAGRISIUM); //Uranium-233 is a fissile isotope of uranium that is bred from thorium-232 as part of the thorium fuel cycle. - UtilsItems.generateItemsFromMaterial(ELEMENT.URANIUM233); + generateItemsFromMaterial(ELEMENT.URANIUM233); } catch (Throwable r){ Utils.LOG_INFO("Failed to Generated a Material. "+r.getMessage()); diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java index 46e727edd1..079e3cfc39 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java @@ -179,7 +179,7 @@ public class StaballoyPickaxe extends ItemPickaxe{ //Break Tool - if ((durNow-dodmg) <= (900) && itemdmg != 0){ + if ((durNow-dodmg) <= (99) && itemdmg != 0){ //TODO break tool Utils.LOG_INFO("Breaking Tool"); heldItem.stackSize = 0; @@ -315,8 +315,9 @@ public class StaballoyPickaxe extends ItemPickaxe{ @Override public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { thisPickaxe = stack; - list.add(EnumChatFormatting.GOLD+"Mines a 3x3 area in the direction you are facing."); - super.addInformation(stack, aPlayer, list, bool); + list.add(EnumChatFormatting.GRAY+"Mines a 3x3 at 100 durability per block mined."); + list.add(EnumChatFormatting.GRAY+"Durability: "+(stack.getMaxDamage()-stack.getItemDamage())+"/"+stack.getMaxDamage()); + //super.addInformation(stack, aPlayer, list, bool); } @Override diff --git a/src/Java/gtPlusPlus/core/material/ALLOY.java b/src/Java/gtPlusPlus/core/material/ALLOY.java index ea5b90259f..e2648c667e 100644 --- a/src/Java/gtPlusPlus/core/material/ALLOY.java +++ b/src/Java/gtPlusPlus/core/material/ALLOY.java @@ -495,6 +495,22 @@ public final class ALLOY { new MaterialStack(ELEMENT.CARBON, 50), new MaterialStack(ELEMENT.NIOBIUM, 50) }); + + + public static final Material LEAGRISIUM = new Material( + "Grisium", //Material Name + new short[]{53, 93, 106, 0}, //Material Colour + 9001, //Melting Point in C + 25000, //Boiling Point in C + 96, //Protons + 128, //Neutrons + true, //Uses Blast furnace? + new MaterialStack[]{ + new MaterialStack(ELEMENT.NICKEL, 25), + new MaterialStack(ELEMENT.CHROMIUM, 25), + new MaterialStack(ELEMENT.IRON, 25), + new MaterialStack(ELEMENT.TUNGSTEN, 25) + }); //Material Stacks with Percentage of required elements. } diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java index b067be1c24..dcc73860d0 100644 --- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java +++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java @@ -557,5 +557,9 @@ public class UtilsItems { return itemNames; } + + public static ItemStack getGregtechCircuit(int Meta){ + return UtilsItems.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", Meta, 0); + } } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 8fab1341d3..75d8452975 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -29,6 +29,11 @@ public class MathUtils { return randomNum; } + public static double getChanceOfXOverYRuns(double x, double y){ + double z = (1-Math.pow((1-x), y)); + return z; + } + /** * Returns a psuedo-random number between min and max, inclusive. diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 8140839cac..2ee8fea9d4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -8,6 +8,7 @@ import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.loaders.Gregtech_Blocks; import gtPlusPlus.xmod.gregtech.loaders.ProcessingToolHeadChoocher; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_BlastSmelter; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; public class HANDLER_GT { @@ -36,6 +37,7 @@ public class HANDLER_GT { GregtechConduits.run(); new MetaGeneratedGregtechTools(); new ProcessingToolHeadChoocher().run(); + RecipeGen_BlastSmelter.generateRecipes(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 6576e1c0d9..e69ab529c6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -70,7 +70,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Unused Machine Casings Casing_MacerationStack, Casing_MatterGen, Casing_MatterFab, Casing_U7, //Unused Machine Coils - Casing_Coil_U1, Casing_Coil_U2, Casing_Coil_U3, Casing_Coil_U4, + Casing_Coil_U1, Casing_Coil_U2, Casing_Coil_BlastSmelter, Casing_BlastSmelter, //Windmill Shaft Shape for Extruder Shape_Extruder_WindmillShaft, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 3b876e6d93..73e7a5d56f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -66,4 +66,17 @@ public interface IGregtech_RecipeAdder { */ public boolean addDehydratorRecipe(ItemStack[] aInput, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack[] aOutputItems, int[] aChances, int aDuration, int aEUt); + + /** + * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aChances = Output Change (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aOutput, int aChance, int aDuration, int aEUt); + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_BasicMachine_Custom_Recipe.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_BasicMachine_Custom_Recipe.java deleted file mode 100644 index c7f84f1095..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_BasicMachine_Custom_Recipe.java +++ /dev/null @@ -1,623 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; - -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.W; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; -import gregtech.api.enums.Tier; -import gregtech.api.gui.GT_Container_BasicMachine; -import gregtech.api.gui.GT_GUIContainer_BasicMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_ModHandler.RecipeBits; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.api.util.GregtechRecipe_OLD.Gregtech_Recipe_Map; - -import java.util.Random; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public class GT_MTE_BasicMachine_Custom_Recipe extends GT_MTE_CustomRecipe_BasicMachine { - private final Gregtech_Recipe_Map mRecipes; - private final int mTankCapacity, mSpecialEffect; - private final String mSound; - private final boolean mSharedTank, mRequiresFluidForFiltering; - private final byte mGUIParameterA, mGUIParameterB; - public GT_MTE_BasicMachine_Custom_Recipe(int aID, String aName, String aNameRegional, int aTier, String aDescription, Gregtech_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) { - super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new ITexture[]{new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_BOTTOM"))}); - mSharedTank = aSharedTank; - mTankCapacity = aTankCapacity; - mSpecialEffect = aSpecialEffect; - mRequiresFluidForFiltering = aRequiresFluidForFiltering; - mRecipes = aRecipes; - mSound = aSound; - mGUIParameterA = (byte) aGUIParameterA; - mGUIParameterB = (byte) aGUIParameterB; - - if (aRecipe != null) { - for (int i = 3; i < aRecipe.length; i++) { - if (aRecipe[i] == X.CIRCUIT) { - aRecipe[i] = Tier.ELECTRIC[mTier].mManagingObject; - continue; - } - if (aRecipe[i] == X.BETTER_CIRCUIT) { - aRecipe[i] = Tier.ELECTRIC[mTier].mBetterManagingObject; - continue; - } - if (aRecipe[i] == X.HULL) { - aRecipe[i] = Tier.ELECTRIC[mTier].mHullObject; - continue; - } - if (aRecipe[i] == X.WIRE) { - aRecipe[i] = Tier.ELECTRIC[mTier].mConductingObject; - continue; - } - if (aRecipe[i] == X.WIRE4) { - aRecipe[i] = Tier.ELECTRIC[mTier].mLargerConductingObject; - continue; - } - - if (aRecipe[i] == X.GLASS) { - switch (mTier) { - default: - aRecipe[i] = new ItemStack(Blocks.glass, 1, W); - break; - } - continue; - } - - if (aRecipe[i] == X.PLATE) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.plate.get(Materials.Steel); - break; - case 2: - aRecipe[i] = OrePrefixes.plate.get(Materials.Aluminium); - break; - case 3: - aRecipe[i] = OrePrefixes.plate.get(Materials.StainlessSteel); - break; - case 4: - aRecipe[i] = OrePrefixes.plate.get(Materials.Titanium); - break; - default: - aRecipe[i] = OrePrefixes.plate.get(Materials.TungstenSteel); - break; - } - continue; - } - - if (aRecipe[i] == X.PIPE) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Bronze); - break; - case 2: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Steel); - break; - case 3: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.StainlessSteel); - break; - case 4: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Titanium); - break; - default: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.TungstenSteel); - break; - } - continue; - } - - if (aRecipe[i] == X.COIL_HEATING) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Cupronickel); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Kanthal); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Nichrome); - break; - default: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.Nichrome); - break; - } - continue; - } - - if (aRecipe[i] == X.COIL_HEATING_DOUBLE) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Cupronickel); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Kanthal); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Nichrome); - break; - default: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.Nichrome); - break; - } - continue; - } - - if (aRecipe[i] == X.STICK_DISTILLATION) { - switch (mTier) { - default: - aRecipe[i] = OrePrefixes.stick.get(Materials.Blaze); - break; - } - continue; - } - - if (aRecipe[i] == X.STICK_MAGNETIC) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.stick.get(Materials.IronMagnetic); - break; - case 2: - case 3: - aRecipe[i] = OrePrefixes.stick.get(Materials.SteelMagnetic); - break; - default: - aRecipe[i] = OrePrefixes.stick.get(Materials.NeodymiumMagnetic); - break; - } - continue; - } - - if (aRecipe[i] == X.STICK_ELECTROMAGNETIC) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.stick.get(Materials.AnyIron); - break; - case 2: - case 3: - aRecipe[i] = OrePrefixes.stick.get(Materials.Steel); - break; - case 4: - aRecipe[i] = OrePrefixes.stick.get(Materials.Neodymium); - break; - default: - aRecipe[i] = OrePrefixes.stick.get(Materials.VanadiumGallium); - break; - } - continue; - } - - if (aRecipe[i] == X.COIL_ELECTRIC) { - switch (mTier) { - case 0: - aRecipe[i] = OrePrefixes.wireGt01.get(Materials.Tin); - break; - case 1: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Tin); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.AnnealedCopper); - break; - default: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.AnnealedCopper); - break; - } - continue; - } - - if (aRecipe[i] == X.ROBOT_ARM) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Robot_Arm_LV; - break; - case 2: - aRecipe[i] = ItemList.Robot_Arm_MV; - break; - case 3: - aRecipe[i] = ItemList.Robot_Arm_HV; - break; - case 4: - aRecipe[i] = ItemList.Robot_Arm_EV; - break; - case 5: - aRecipe[i] = ItemList.Robot_Arm_IV; - break; - case 6: - aRecipe[i] = ItemList.Robot_Arm_LuV; - break; - case 7: - aRecipe[i] = ItemList.Robot_Arm_ZPM; - break; - default: - aRecipe[i] = ItemList.Robot_Arm_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.PUMP) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Pump_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Pump_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Pump_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Pump_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Pump_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Pump_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Pump_ZPM; - break; - default: - aRecipe[i] = ItemList.Electric_Pump_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.ROTOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Tin); - break; - case 2: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Bronze); - break; - case 3: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Steel); - break; - case 4: - aRecipe[i] = OrePrefixes.rotor.get(Materials.StainlessSteel); - break; - case 5: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - case 6: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - case 7: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - default: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - } - continue; - } - - if (aRecipe[i] == X.MOTOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Motor_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Motor_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Motor_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Motor_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Motor_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Motor_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Motor_ZPM; - break; - default: - aRecipe[i] = ItemList.Electric_Motor_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.PISTON) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Piston_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Piston_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Piston_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Piston_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Piston_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Piston_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Piston_ZPM; - break; - default: - aRecipe[i] = ItemList.Electric_Piston_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.CONVEYOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Conveyor_Module_LV; - break; - case 2: - aRecipe[i] = ItemList.Conveyor_Module_MV; - break; - case 3: - aRecipe[i] = ItemList.Conveyor_Module_HV; - break; - case 4: - aRecipe[i] = ItemList.Conveyor_Module_EV; - break; - case 5: - aRecipe[i] = ItemList.Conveyor_Module_IV; - break; - case 6: - aRecipe[i] = ItemList.Conveyor_Module_LuV; - break; - case 7: - aRecipe[i] = ItemList.Conveyor_Module_ZPM; - break; - default: - aRecipe[i] = ItemList.Conveyor_Module_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.EMITTER) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Emitter_LV; - break; - case 2: - aRecipe[i] = ItemList.Emitter_MV; - break; - case 3: - aRecipe[i] = ItemList.Emitter_HV; - break; - case 4: - aRecipe[i] = ItemList.Emitter_EV; - break; - case 5: - aRecipe[i] = ItemList.Emitter_IV; - break; - case 6: - aRecipe[i] = ItemList.Emitter_LuV; - break; - case 7: - aRecipe[i] = ItemList.Emitter_ZPM; - break; - default: - aRecipe[i] = ItemList.Emitter_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.SENSOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Sensor_LV; - break; - case 2: - aRecipe[i] = ItemList.Sensor_MV; - break; - case 3: - aRecipe[i] = ItemList.Sensor_HV; - break; - case 4: - aRecipe[i] = ItemList.Sensor_EV; - break; - case 5: - aRecipe[i] = ItemList.Sensor_IV; - break; - case 6: - aRecipe[i] = ItemList.Sensor_LuV; - break; - case 7: - aRecipe[i] = ItemList.Sensor_ZPM; - break; - default: - aRecipe[i] = ItemList.Sensor_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.FIELD_GENERATOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Field_Generator_LV; - break; - case 2: - aRecipe[i] = ItemList.Field_Generator_MV; - break; - case 3: - aRecipe[i] = ItemList.Field_Generator_HV; - break; - case 4: - aRecipe[i] = ItemList.Field_Generator_EV; - break; - case 5: - aRecipe[i] = ItemList.Field_Generator_IV; - break; - case 6: - aRecipe[i] = ItemList.Field_Generator_LuV; - break; - case 7: - aRecipe[i] = ItemList.Field_Generator_ZPM; - break; - default: - aRecipe[i] = ItemList.Field_Generator_UV; - break; - } - continue; - } - - if (aRecipe[i] instanceof X) - throw new IllegalArgumentException("MISSING TIER MAPPING FOR: " + aRecipe[i] + " AT TIER " + mTier); - } - - if (!GT_ModHandler.addCraftingRecipe(getStackForm(1), RecipeBits.DISMANTLEABLE | RecipeBits.BUFFERED | RecipeBits.NOT_REMOVABLE | RecipeBits.REVERSIBLE, aRecipe)) { - throw new IllegalArgumentException("INVALID CRAFTING RECIPE FOR: " + getStackForm(1).getDisplayName()); - } - } - } - - public GT_MTE_BasicMachine_Custom_Recipe(String aName, int aTier, String aDescription, Gregtech_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { - super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName); - mSharedTank = aSharedTank; - mTankCapacity = aTankCapacity; - mSpecialEffect = aSpecialEffect; - mRequiresFluidForFiltering = aRequiresFluidForFiltering; - mRecipes = aRecipes; - mSound = aSound; - mGUIParameterA = (byte) aGUIParameterA; - mGUIParameterB = (byte) aGUIParameterB; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MTE_BasicMachine_Custom_Recipe(mName, mTier, mDescription, mRecipes, mInputSlotCount, mOutputItems == null ? 0 : mOutputItems.length, mTankCapacity, mAmperage, mGUIParameterA, mGUIParameterB, mTextures, mGUIName, mNEIName, mSound, mSharedTank, mRequiresFluidForFiltering, mSpecialEffect); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : "", mGUIParameterA, mGUIParameterB); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; - if (mInventory[aIndex] != null) return true; - switch (mInputSlotCount) { - case 0: return false; - case 1: return getFillableStack() == null ? !mRequiresFluidForFiltering && getRecipeList().containsInput(aStack) : null!=getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), new ItemStack[] {aStack}); - case 2: return (!mRequiresFluidForFiltering || getFillableStack() != null) && (((getInputAt(0)!=null&&getInputAt(1)!=null) || (getInputAt(0)==null&&getInputAt(1)==null?getRecipeList().containsInput(aStack):(getRecipeList().containsInput(aStack)&&null!=getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), aIndex == getInputSlot() ? new ItemStack[] {aStack, getInputAt(1)} : new ItemStack[] {getInputAt(0), aStack}))))); - default: return getRecipeList().containsInput(aStack); - } - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { - switch (mSpecialEffect) { - case 0: - break; - case 1: - if (aBaseMetaTileEntity.getFrontFacing() != 1 && aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0 && !aBaseMetaTileEntity.getOpacityAtSide((byte) 1)) { - Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F, 0.0D, 0.0D, 0.0D); - } - break; - } - } - } - - - public Gregtech_Recipe_Map getRecipeList() { - return mRecipes; - } - - @Override - public int getCapacity() { - return mTankCapacity; - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1 && GT_Utility.isStringValid(mSound)) GT_Utility.doSoundAtClient(mSound, 100, 1.0F, aX, aY, aZ); - } - - @Override - public void startProcess() { - if (GT_Utility.isStringValid(mSound)) sendLoopStart((byte) 1); - } - - @Override - public FluidStack getFillableStack() { - return mSharedTank ? getDrainableStack() : super.getFillableStack(); - } - - @Override - public FluidStack setFillableStack(FluidStack aFluid) { - return mSharedTank ? setDrainableStack(aFluid) : super.setFillableStack(aFluid); - } - - @Override - protected boolean displaysOutputFluid() { - return !mSharedTank; - } - - public static enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC;} -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_CustomRecipe_BasicMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_CustomRecipe_BasicMachine.java deleted file mode 100644 index 521b23a42e..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_CustomRecipe_BasicMachine.java +++ /dev/null @@ -1,799 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_Container_BasicMachine; -import gregtech.api.gui.GT_GUIContainer_BasicMachine; -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.objects.GT_RenderedTexture; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.api.util.GregtechRecipe_OLD; -import gtPlusPlus.xmod.gregtech.api.util.GregtechRecipe_OLD.Gregtech_Recipe_Map; - -import java.util.Arrays; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public abstract class GT_MTE_CustomRecipe_BasicMachine extends GT_MetaTileEntity_BasicTank { - /** - * return values for checkRecipe() - */ - protected static final int - DID_NOT_FIND_RECIPE = 0, - FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, - FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; - private static final int OTHER_SLOT_COUNT = 4; - public final ItemStack[] mOutputItems; - public final int mInputSlotCount, mAmperage; - public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; - public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; - public FluidStack mOutputFluid; - public String mGUIName = "", mNEIName = ""; - private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - /** - * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered - */ - protected GregtechRecipe_OLD mLastRecipe = null; - private FluidStack mFluidOut; - - /** - * @param aOverlays 0 = SideFacingActive - * 1 = SideFacingInactive - * 2 = FrontFacingActive - * 3 = FrontFacingInactive - * 4 = TopFacingActive - * 5 = TopFacingInactive - * 6 = BottomFacingActive - * 7 = BottomFacingInactive - * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- - * 8 = BottomFacingPipeActive - * 9 = BottomFacingPipeInactive - * 10 = TopFacingPipeActive - * 11 = TopFacingPipeInactive - * 12 = SideFacingPipeActive - * 13 = SideFacingPipeInactive - */ - public GT_MTE_CustomRecipe_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); - mInputSlotCount = Math.max(0, aInputSlotCount); - mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; - mAmperage = aAmperage; - mGUIName = aGUIName; - mNEIName = aNEIName; - } - - public GT_MTE_CustomRecipe_BasicMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { - super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); - mInputSlotCount = Math.max(0, aInputSlotCount); - mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; - mAmperage = aAmperage; - mGUIName = aGUIName; - mNEIName = aNEIName; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[14][17][]; - aTextures = Arrays.copyOf(aTextures, 14); - - for (int i = 0; i < aTextures.length; i++) - if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { - if (rTextures[i][c + 1] == null) - rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; - } - - for (byte c = -1; c < 16; c++) { - if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); - if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); - if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); - if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); - if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); - if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); - if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); - if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); - if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); - if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); - if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); - if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); - if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); - if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return mMainFacing > 1 || aFacing > 1; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) { - return aSide != mMainFacing; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return false; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); - } - - @Override - public boolean isLiquidOutput(byte aSide) { - return aSide != mMainFacing; - } - - @Override - public long getMinimumStoredEU() { - return V[mTier] * 16; - } - - @Override - public long maxEUStore() { - return V[mTier] * 64; - } - - @Override - public long maxEUInput() { - return V[mTier]; - } - - @Override - public long maxSteamStore() { - return maxEUStore(); - } - - @Override - public long maxAmperesIn() { - return (mEUt * 2) / V[mTier] + 1; - } - - @Override - public int getInputSlot() { - return OTHER_SLOT_COUNT; - } - - @Override - public int getOutputSlot() { - return OTHER_SLOT_COUNT + mInputSlotCount; - } - - @Override - public int getStackDisplaySlot() { - return 2; - } - - @Override - public int rechargerSlotStartIndex() { - return 1; - } - - @Override - public int dechargerSlotStartIndex() { - return 1; - } - - @Override - public int rechargerSlotCount() { - return mCharge ? 1 : 0; - } - - @Override - public int dechargerSlotCount() { - return mDecharge ? 1 : 0; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public int getProgresstime() { - return mProgresstime; - } - - @Override - public int maxProgresstime() { - return mMaxProgresstime; - } - - @Override - public int increaseProgress(int aProgress) { - mProgresstime += aProgress; - return mMaxProgresstime - mProgresstime; - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); - } - - @Override - public boolean isFluidChangingAllowed() { - return true; - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return true; - } - - @Override - public FluidStack getDisplayedFluid() { - return displaysOutputFluid() ? getDrainableStack() : null; - } - - @Override - public FluidStack getDrainableStack() { - return mFluidOut; - } - - @Override - public FluidStack setDrainableStack(FluidStack aFluid) { - mFluidOut = aFluid; - return mFluidOut; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); - } - - @Override - public void initDefaultModes(NBTTagCompound aNBT) { - mMainFacing = -1; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mFluidTransfer", mFluidTransfer); - aNBT.setBoolean("mItemTransfer", mItemTransfer); - aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); - aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); - aNBT.setInteger("mEUt", mEUt); - aNBT.setInteger("mMainFacing", mMainFacing); - aNBT.setInteger("mProgresstime", mProgresstime); - aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); - aNBT.setTag("GT.CraftingComponents", mRecipeStuff); - if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); - if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); - - for (int i = 0; i < mOutputItems.length; i++) - if (mOutputItems[i] != null) - aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); - mItemTransfer = aNBT.getBoolean("mItemTransfer"); - mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); - mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); - mEUt = aNBT.getInteger("mEUt"); - mMainFacing = aNBT.getInteger("mMainFacing"); - mProgresstime = aNBT.getInteger("mProgresstime"); - mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); - mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); - - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (aBaseMetaTileEntity.isServerSide()) { - mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; - mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; - - doDisplayThings(); - - boolean tSucceeded = false; - - if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { - aBaseMetaTileEntity.setActive(true); - if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { - if (++mProgresstime >= mMaxProgresstime) { - for (int i = 0; i < mOutputItems.length; i++) - for (int j = 0; j < mOutputItems.length; j++) - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) - break; - if (mOutputFluid != null) - if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); - else if (mOutputFluid.isFluidEqual(getDrainableStack())) - getDrainableStack().amount += mOutputFluid.amount; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; - mOutputFluid = null; - mEUt = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mStuttering = false; - tSucceeded = true; - endProcess(); - } - if (mProgresstime > 5) mStuttering = false; - } else { - if (!mStuttering) { - stutterProcess(); - if (canHaveInsufficientEnergy()) mProgresstime = -100; - mStuttering = true; - } - } - } else { - aBaseMetaTileEntity.setActive(false); - } - - boolean tRemovedOutputFluid = false; - - if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { - IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); - if (tTank != null) { - FluidStack tDrained = drain(1000, false); - if (tDrained != null) { - int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); - if (tFilledAmount > 0) - tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); - } - } - if (getDrainableStack() == null) tRemovedOutputFluid = true; - } - - if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { - TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); - } - } - - if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; - else mOutputBlocked++; - - if (allowToCheckRecipe()) { - if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { - if (checkRecipe() == 2) { - if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; - for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; - for (int i = 0; i < mOutputItems.length; i++) { - mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); - if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) - mOutputItems[i].stackSize = 64; - mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); - } - if (mFluid != null && mFluid.amount <= 0) mFluid = null; - mMaxProgresstime = Math.max(1, mMaxProgresstime); - if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { - mEUt = mMaxProgresstime = 1; - } - startProcess(); - } else { - mMaxProgresstime = 0; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; - mOutputFluid = null; - } - } - } else { - if (!mStuttering) { - stutterProcess(); - mStuttering = true; - } - } - } - } - - protected void doDisplayThings() { - if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { - mMainFacing = getBaseMetaTileEntity().getFrontFacing(); - } - if (mMainFacing >= 2 && !mHasBeenUpdated) { - mHasBeenUpdated = true; - getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); - } - - if (displaysInputFluid()) { - int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; - if (getFillableStack() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) - mInventory[tDisplayStackSlot] = null; - } else { - mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); - } - } - } - - protected boolean hasEnoughEnergyToCheckRecipe() { - return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); - } - - protected boolean drainEnergyForProcess(long aEUt) { - return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); - } - - protected void calculateOverclockedNess(GregtechRecipe_OLD tRecipe) { - calculateOverclockedNess(tRecipe.mEUt, tRecipe.mDuration); - } - - protected void calculateOverclockedNess(int aEUt, int aDuration) { - if (aEUt <= 16) { - mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); - mMaxProgresstime = aDuration / (1 << (mTier - 1)); - } else { - mEUt = aEUt; - mMaxProgresstime = aDuration; - while (mEUt <= V[mTier - 1] * mAmperage) { - mEUt *= 4; - mMaxProgresstime /= 2; - } - } - } - - protected ItemStack getSpecialSlot() { - return mInventory[3]; - } - - protected ItemStack getOutputAt(int aIndex) { - return mInventory[getOutputSlot() + aIndex]; - } - - protected ItemStack[] getAllOutputs() { - ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; - for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); - return rOutputs; - } - - protected boolean canOutput(GregtechRecipe_OLD tRecipe) { - return tRecipe != null && (tRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(tRecipe.getFluidOutput(0)) && canOutput(tRecipe.mOutputs)); - } - - protected boolean canOutput(ItemStack... aOutputs) { - if (aOutputs == null) return true; - ItemStack[] tOutputSlots = getAllOutputs(); - for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) - if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { - mOutputBlocked++; - return false; - } - return true; - } - - protected boolean canOutput(FluidStack aOutput) { - return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); - } - - protected ItemStack getInputAt(int aIndex) { - return mInventory[getInputSlot() + aIndex]; - } - - protected ItemStack[] getAllInputs() { - ItemStack[] rInputs = new ItemStack[mInputSlotCount]; - for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); - return rInputs; - } - - protected boolean isOutputEmpty() { - boolean rIsEmpty = true; - for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; - return rIsEmpty; - } - - protected boolean displaysInputFluid() { - return true; - } - - protected boolean displaysOutputFluid() { - return true; - } - - @Override - public void onValueUpdate(byte aValue) { - mMainFacing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) mMainFacing; - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - super.doSound(aIndex, aX, aY, aZ); - if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); - } - - public boolean doesAutoOutput() { - return mItemTransfer; - } - - public boolean doesAutoOutputFluids() { - return mFluidTransfer; - } - - public boolean allowToCheckRecipe() { - return true; - } - - public boolean showPipeFacing() { - return true; - } - - /** - * Called whenever the Machine successfully started a Process, useful for Sound Effects - */ - public void startProcess() { - // - } - - /** - * Called whenever the Machine successfully finished a Process, useful for Sound Effects - */ - public void endProcess() { - // - } - - /** - * Called whenever the Machine aborted a Process, useful for Sound Effects - */ - public void abortProcess() { - // - } - - /** - * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects - */ - public void stutterProcess() { - if (useStandardStutterSound()) sendSound((byte) 8); - } - - /** - * If this Machine can have the Insufficient Energy Line Problem - */ - public boolean canHaveInsufficientEnergy() { - return true; - } - - public boolean useStandardStutterSound() { - return true; - } - - @Override - public String[] getInfoData() { - return new String[]{ - mRecipeStuff.toString(), - mNEIName, - "Progress:", (mProgresstime / 20) + " secs", - (mMaxProgresstime / 20) + " secs", - "Stored Energy:", - getBaseMetaTileEntity().getStoredEU() + "EU", - getBaseMetaTileEntity().getEUCapacity() + "EU"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { - mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); - } - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) - return false; - for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) - if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; - return true; - } - - /** - * @return the Recipe List which is used for this Machine, this is a useful Default Handler - */ - public Gregtech_Recipe_Map getRecipeList() { - return null; - } - - /** - * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case - *

- * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. - *

- * Funny how Eclipse marks the word Enum as not correctly spelled. - * - * @return see constants above - */ - public int checkRecipe() { - Gregtech_Recipe_Map tMap = getRecipeList(); - if (tMap == null) return DID_NOT_FIND_RECIPE; - GregtechRecipe_OLD tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); - if (tRecipe == null) return DID_NOT_FIND_RECIPE; - if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; - if (!canOutput(tRecipe)) { - mOutputBlocked++; - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - } - if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - - for (int i = 0; i < mOutputItems.length; i++) - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) - mOutputItems[i] = tRecipe.getOutput(i); - mOutputFluid = tRecipe.getFluidOutput(0); - calculateOverclockedNess(tRecipe); - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; - } - - public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechRecipe_OLD.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechRecipe_OLD.java deleted file mode 100644 index 60583ed27b..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechRecipe_OLD.java +++ /dev/null @@ -1,781 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.util; - -import static gregtech.api.enums.GT_Values.E; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; -import static gregtech.api.enums.GT_Values.W; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; -import gregtech.api.objects.GT_FluidStack; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.UtilsItems; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * This File contains the functions used for Recipes. Please do not include this File AT ALL in your Moddownload as it ruins compatibility - * This is just the Core of my Recipe System, if you just want to GET the Recipes I add, then you can access this File. - * Do NOT add Recipes using the Constructors inside this Class, The GregTech_API File calls the correct Functions for these Constructors. - *

- * I know this File causes some Errors, because of missing Main Functions, but if you just need to compile Stuff, then remove said erroreous Functions. - */ -public class GregtechRecipe_OLD { - - public static volatile int VERSION = 508; - /** - * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps. - */ - public ItemStack[] mInputs, mOutputs; - /** - * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps. - */ - public FluidStack[] mFluidInputs, mFluidOutputs; - /** - * If you changed the amount of Array-Items inside the Output Array then the length of this Array must be larger or equal to the Output Array. A chance of 10000 equals 100% - */ - public int[] mChances; - /** - * An Item that needs to be inside the Special Slot, like for example the Copy Slot inside the Printer. This is only useful for Fake Recipes in NEI, since findRecipe() and containsInput() don't give a shit about this Field. Lists are also possible. - */ - public Object mSpecialItems; - public int mDuration, mEUt, mSpecialValue; - /** - * Use this to just disable a specific Recipe, but the Configuration enables that already for every single Recipe. - */ - public boolean mEnabled = true; - /** - * If this Recipe is hidden from NEI - */ - public boolean mHidden = false; - /** - * If this Recipe is Fake and therefore doesn't get found by the findRecipe Function (It is still in the HashMaps, so that containsInput does return T on those fake Inputs) - */ - public boolean mFakeRecipe = false; - /** - * If this Recipe can be stored inside a Machine in order to make Recipe searching more Efficient by trying the previously used Recipe first. In case you have a Recipe Map overriding things and returning one time use Recipes, you have to set this to F. - */ - public boolean mCanBeBuffered = true; - /** - * If this Recipe needs the Output Slots to be completely empty. Needed in case you have randomised Outputs - */ - public boolean mNeedsEmptyOutput = false; - private GregtechRecipe_OLD(GregtechRecipe_OLD aRecipe) { - mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs); - mOutputs = GT_Utility.copyStackArray((Object[]) aRecipe.mOutputs); - mSpecialItems = aRecipe.mSpecialItems; - mChances = aRecipe.mChances; - mFluidInputs = GT_Utility.copyFluidArray(aRecipe.mFluidInputs); - mFluidOutputs = GT_Utility.copyFluidArray(aRecipe.mFluidOutputs); - mDuration = aRecipe.mDuration; - mSpecialValue = aRecipe.mSpecialValue; - mEUt = aRecipe.mEUt; - mNeedsEmptyOutput = aRecipe.mNeedsEmptyOutput; - mCanBeBuffered = aRecipe.mCanBeBuffered; - mFakeRecipe = aRecipe.mFakeRecipe; - mEnabled = aRecipe.mEnabled; - mHidden = aRecipe.mHidden; - } - protected GregtechRecipe_OLD(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (aInputs == null) aInputs = new ItemStack[0]; - if (aOutputs == null) aOutputs = new ItemStack[0]; - if (aFluidInputs == null) aFluidInputs = new FluidStack[0]; - if (aFluidOutputs == null) aFluidOutputs = new FluidStack[0]; - if (aChances == null) aChances = new int[aOutputs.length]; - if (aChances.length < aOutputs.length) aChances = Arrays.copyOf(aChances, aOutputs.length); - - aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]); - aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]); - aFluidInputs = GT_Utility.getArrayListWithoutNulls(aFluidInputs).toArray(new FluidStack[0]); - aFluidOutputs = GT_Utility.getArrayListWithoutNulls(aFluidOutputs).toArray(new FluidStack[0]); - - GT_OreDictUnificator.setStackArray(true, aInputs); - GT_OreDictUnificator.setStackArray(true, aOutputs); - - for (ItemStack tStack : aOutputs) GT_Utility.updateItemStack(tStack); - - for (int i = 0; i < aChances.length; i++) if (aChances[i] <= 0) aChances[i] = 10000; - for (int i = 0; i < aFluidInputs.length; i++) aFluidInputs[i] = new GT_FluidStack(aFluidInputs[i]); - for (int i = 0; i < aFluidOutputs.length; i++) aFluidOutputs[i] = new GT_FluidStack(aFluidOutputs[i]); - - for (int i = 0; i < aInputs.length; i++) - if (aInputs[i] != null && Items.feather.getDamage(aInputs[i]) != W) - for (int j = 0; j < aOutputs.length; j++) { - if (GT_Utility.areStacksEqual(aInputs[i], aOutputs[j])) { - if (aInputs[i].stackSize >= aOutputs[j].stackSize) { - aInputs[i].stackSize -= aOutputs[j].stackSize; - aOutputs[j] = null; - } else { - aOutputs[j].stackSize -= aInputs[i].stackSize; - } - } - } - - if (aOptimize && aDuration >= 32) { - ArrayList tList = new ArrayList(); - tList.addAll(Arrays.asList(aInputs)); - tList.addAll(Arrays.asList(aOutputs)); - for (int i = 0; i < tList.size(); i++) if (tList.get(i) == null) tList.remove(i--); - - for (byte i = (byte) Math.min(64, aDuration / 16); i > 1; i--) - if (aDuration / i >= 16) { - boolean temp = true; - for (int j = 0, k = tList.size(); temp && j < k; j++) - if (tList.get(j).stackSize % i != 0) temp = false; - for (int j = 0; temp && j < aFluidInputs.length; j++) - if (aFluidInputs[j].amount % i != 0) temp = false; - for (int j = 0; temp && j < aFluidOutputs.length; j++) - if (aFluidOutputs[j].amount % i != 0) temp = false; - if (temp) { - for (int j = 0, k = tList.size(); j < k; j++) tList.get(j).stackSize /= i; - for (int j = 0; j < aFluidInputs.length; j++) aFluidInputs[j].amount /= i; - for (int j = 0; j < aFluidOutputs.length; j++) aFluidOutputs[j].amount /= i; - aDuration /= i; - } - } - } - - mInputs = aInputs; - mOutputs = aOutputs; - mSpecialItems = aSpecialItems; - mChances = aChances; - mFluidInputs = aFluidInputs; - mFluidOutputs = aFluidOutputs; - mDuration = aDuration; - mSpecialValue = aSpecialValue; - mEUt = aEUt; - - // checkCellBalance(); - - Utils.LOG_SPECIFIC_WARNING(this.getClass().getName()+" | [GregtechRecipe_OLD]", "Created new recipe instance for "+UtilsItems.getArrayStackNames(aInputs), 167); - } - - public GregtechRecipe_OLD(ItemStack aInput1, ItemStack aOutput1, int aFuelValue, int aType) { - this(aInput1, aOutput1, null, null, null, aFuelValue, aType); - } - - // aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000! - public GregtechRecipe_OLD(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aSpecialValue, int aType) { - this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, 0, 0, Math.max(1, aSpecialValue)); - - Utils.LOG_INFO("Switch case method for adding fuels"); - if (mInputs.length > 0 && aSpecialValue > 0) { - switch (aType) { - // Diesel Generator - case 0: - Utils.LOG_INFO("Added fuel "+aInput1.getDisplayName()+" is ROCKET FUEL - continuing"); - Gregtech_Recipe_Map.sRocketFuels.addRecipe(this); - break; - // Gas Turbine - case 1: - Gregtech_Recipe_Map.sGeoThermalFuels.addRecipe(this); - break; - // Thermal Generator - case 2: - //Gregtech_Recipe_Map.sHotFuels.addRecipe(this); - break; - // Plasma Generator - case 4: - //Gregtech_Recipe_Map.sPlasmaFuels.addRecipe(this); - break; - // Magic Generator - case 5: - //Gregtech_Recipe_Map.sMagicFuels.addRecipe(this); - break; - // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator - default: - //Gregtech_Recipe_Map.sDenseLiquidFuels.addRecipe(this); - break; - } - } - } - - //Custom Recipe Handlers - public GregtechRecipe_OLD(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutput, int aDuration, int aEUt) { - this(true, new ItemStack[]{aInput}, aOutput.clone(), null, null, new FluidStack[]{aFluid}, null, aDuration, aEUt, 0); - if (mInputs.length > 0 && mOutputs[0] != null) { - Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(this); - } - } - - /*public GregtechRecipe_OLD(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutput, int aDuration, int aEUt) { - this(true, new ItemStack[]{aInput}, aOutput.clone(), null, null, new FluidStack[]{aFluid}, null, aDuration, aEUt, 0); - if (mInputs.length > 0 && mOutputs[0] != null) { - Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(this); - } - }*/ - - - public static void reInit() { - GT_Log.out.println("GT_Mod: Re-Unificating Recipes."); - for (Gregtech_Recipe_Map tMapEntry : Gregtech_Recipe_Map.sMappings) tMapEntry.reInit(); - } - - public ItemStack getRepresentativeInput(int aIndex) { - if (aIndex < 0 || aIndex >= mInputs.length) return null; - return GT_Utility.copy(mInputs[aIndex]); - } - - public ItemStack getOutput(int aIndex) { - if (aIndex < 0 || aIndex >= mOutputs.length) return null; - return GT_Utility.copy(mOutputs[aIndex]); - } - - public int getOutputChance(int aIndex) { - if (aIndex < 0 || aIndex >= mChances.length) return 10000; - return mChances[aIndex]; - } - - public FluidStack getRepresentativeFluidInput(int aIndex) { - if (aIndex < 0 || aIndex >= mFluidInputs.length || mFluidInputs[aIndex] == null) return null; - return mFluidInputs[aIndex].copy(); - } - - public FluidStack getFluidOutput(int aIndex) { - if (aIndex < 0 || aIndex >= mFluidOutputs.length || mFluidOutputs[aIndex] == null) return null; - return mFluidOutputs[aIndex].copy(); - } - - public GregtechRecipe_OLD copy() { - return new GregtechRecipe_OLD(this); - } - - public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, FluidStack[] aFluidInputs, ItemStack... aInputs) { - return isRecipeInputEqual(aDecreaseStacksizeBySuccess, false, aFluidInputs, aInputs); - } - - public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) { - if (mFluidInputs.length > 0 && aFluidInputs == null) return false; - for (FluidStack tFluid : mFluidInputs) - if (tFluid != null) { - boolean temp = true; - for (FluidStack aFluid : aFluidInputs) - if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || aFluid.amount >= tFluid.amount)) { - temp = false; - break; - } - if (temp) return false; - } - - if (mInputs.length > 0 && aInputs == null) return false; - - for (ItemStack tStack : mInputs) - if (tStack != null) { - boolean temp = true; - for (ItemStack aStack : aInputs) - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || aStack.stackSize >= tStack.stackSize)) { - temp = false; - break; - } - if (temp) return false; - } - - if (aDecreaseStacksizeBySuccess) { - if (aFluidInputs != null) { - for (FluidStack tFluid : mFluidInputs) - if (tFluid != null) { - for (FluidStack aFluid : aFluidInputs) - if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || aFluid.amount >= tFluid.amount)) { - aFluid.amount -= tFluid.amount; - break; - } - } - } - - if (aInputs != null) { - for (ItemStack tStack : mInputs) - if (tStack != null) { - for (ItemStack aStack : aInputs) - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || aStack.stackSize >= tStack.stackSize)) { - aStack.stackSize -= tStack.stackSize; - break; - } - } - } - } - - return true; - } - - public static class Gregtech_Recipe_Map { - /** - * Contains all Recipe Maps - */ - public static final Collection sMappings = new ArrayList(); - //public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCokeOvenRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.cokeoven", "Coke Oven", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMatterFab2Recipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.matterfab2", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, E, 1, E, true, true); - //public static final Gregtech_Recipe_Map sMatterFabRecipes = new Gregtech_Recipe_Map(new HashSet(200), "gt.recipe.matterfab", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 3, 1, 1, 1, E, 1, E, true, true); - public static final Gregtech_Recipe_Map_Fuel sRocketFuels = new Gregtech_Recipe_Map_Fuel(new HashSet(10), "gt.recipe.rocketenginefuel", "Rocket Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 3000, " EU", true, true); - public static final Gregtech_Recipe_Map_Fuel sGeoThermalFuels = new Gregtech_Recipe_Map_Fuel(new HashSet(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final Gregtech_Recipe_Map sChemicalDehydratorRecipes = new Gregtech_Recipe_Map(new HashSet(200), "gt.recipe.chemicaldehydrator", "Chemical Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 1, 1, 0, 0, 1, E, 1, E, true, true); - - /** - * HashMap of Recipes based on their Items - */ - public final Map> mRecipeItemMap = new HashMap>(); - /** - * HashMap of Recipes based on their Fluids - */ - public final Map> mRecipeFluidMap = new HashMap>(); - /** - * The List of all Recipes - */ - public final Collection mRecipeList; - /** - * String used as an unlocalised Name. - */ - public final String mUnlocalizedName; - /** - * String used in NEI for the Recipe Lists. If null it will use the unlocalised Name instead - */ - public final String mNEIName; - /** - * GUI used for NEI Display. Usually the GUI of the Machine itself - */ - public final String mNEIGUIPath; - public final String mNEISpecialValuePre, mNEISpecialValuePost; - public final int mUsualInputCount, mUsualOutputCount, mNEISpecialValueMultiplier, mMinimalInputItems, mMinimalInputFluids, mAmperage; - public final boolean mNEIAllowed, mShowVoltageAmperageInNEI; - - /** - * Initialises a new type of Recipe Handler. - * - * @param aRecipeList a List you specify as Recipe List. Usually just an ArrayList with a pre-initialised Size. - * @param aUnlocalizedName the unlocalised Name of this Recipe Handler, used mainly for NEI. - * @param aLocalName the displayed Name inside the NEI Recipe GUI. - * @param aNEIGUIPath the displayed GUI Texture, usually just a Machine GUI. Auto-Attaches ".png" if forgotten. - * @param aUsualInputCount the usual amount of Input Slots this Recipe Class has. - * @param aUsualOutputCount the usual amount of Output Slots this Recipe Class has. - * @param aNEISpecialValuePre the String in front of the Special Value in NEI. - * @param aNEISpecialValueMultiplier the Value the Special Value is getting Multiplied with before displaying - * @param aNEISpecialValuePost the String after the Special Value. Usually for a Unit or something. - * @param aNEIAllowed if NEI is allowed to display this Recipe Handler in general. - */ - public Gregtech_Recipe_Map(Collection aRecipeList, - String aUnlocalizedName, String aLocalName, String aNEIName, - String aNEIGUIPath, int aUsualInputCount, - int aUsualOutputCount, int aMinimalInputItems, - int aMinimalInputFluids, int aAmperage, - String aNEISpecialValuePre, int aNEISpecialValueMultiplier, - String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, - boolean aNEIAllowed) { - sMappings.add(this); - mNEIAllowed = aNEIAllowed; - mShowVoltageAmperageInNEI = aShowVoltageAmperageInNEI; - mRecipeList = aRecipeList; - mNEIName = aNEIName == null ? aUnlocalizedName : aNEIName; - mNEIGUIPath = aNEIGUIPath.endsWith(".png") ? aNEIGUIPath : aNEIGUIPath + ".png"; - mNEISpecialValuePre = aNEISpecialValuePre; - mNEISpecialValueMultiplier = aNEISpecialValueMultiplier; - mNEISpecialValuePost = aNEISpecialValuePost; - mAmperage = aAmperage; - mUsualInputCount = aUsualInputCount; - mUsualOutputCount = aUsualOutputCount; - mMinimalInputItems = aMinimalInputItems; - mMinimalInputFluids = aMinimalInputFluids; - GregTech_API.sFluidMappings.add(mRecipeFluidMap); - GregTech_API.sItemStackMappings.add(mRecipeItemMap); - GT_LanguageManager.addStringLocalization(mUnlocalizedName = aUnlocalizedName, aLocalName); - } - - public GregtechRecipe_OLD addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GregtechRecipe_OLD(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); - } - - public GregtechRecipe_OLD addRecipe(int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GregtechRecipe_OLD(false, null, null, null, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue), false, false, false); - } - - public GregtechRecipe_OLD addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GregtechRecipe_OLD(aOptimize, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); - } - - public GregtechRecipe_OLD addRecipe(boolean aOptimize, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GregtechRecipe_OLD(aOptimize, null, null, null, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); - } - - /*public GregtechRecipe_OLD addRecipe(boolean aOptimize, FluidStack aInput1, FluidStack aOutput1, ItemStack[] bInput1, ItemStack[] bOutput1, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GregtechRecipe_OLD(aOptimize, aInput1, aOutput1, bInput1,bOutput1, aDuration, aEUt, aSpecialValue)); - - }*/ - - public GregtechRecipe_OLD addRecipe(GregtechRecipe_OLD aRecipe) { - Utils.LOG_INFO("Adding Recipe Method 1"); - return addRecipe(aRecipe, true, false, false); - } - - protected GregtechRecipe_OLD addRecipe(GregtechRecipe_OLD aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) { - Utils.LOG_INFO("Adding Recipe Method 2 - This Checks if hidden, fake or if duplicate recipes exists, I think."); - aRecipe.mHidden = aHidden; - aRecipe.mFakeRecipe = aFakeRecipe; - Utils.LOG_INFO("Logging some data about this method: GregtechRecipe_OLD["+aRecipe.toString()+"] | aCheckForCollisions["+aCheckForCollisions+"] | aFakeRecipe["+aFakeRecipe+"] | aHidden["+aHidden+"]"); - Utils.LOG_INFO("Logging some data about this method: mMinimalInputFluids["+mMinimalInputFluids+"] | mMinimalInputItems["+mMinimalInputItems+"] | aRecipe.mFluidInputs.length["+aRecipe.mFluidInputs.length+"] | aRecipe.mInputs.length["+aRecipe.mInputs.length+"]"); - if (aRecipe.mFluidInputs.length < mMinimalInputFluids && aRecipe.mInputs.length < mMinimalInputItems){ - Utils.LOG_INFO("Step 2 failed"); - return null;} - - Utils.LOG_INFO("Logging some data about this method: aCheckForCollisions["+aCheckForCollisions+"] | findRecipe != null ["+(findRecipe(null, false, Long.MAX_VALUE, aRecipe.mFluidInputs, aRecipe.mInputs) != null)+"]"); - if (aCheckForCollisions && findRecipe(null, false, Long.MAX_VALUE, aRecipe.mFluidInputs, aRecipe.mInputs) != null){ - Utils.LOG_INFO("Step 2 failed - 2"); - return null; - } - return add(aRecipe); - } - - - - /** - * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes - */ - public GregtechRecipe_OLD addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addFakeRecipe(aCheckForCollisions, new GregtechRecipe_OLD(false, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); - } - - /** - * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes - */ - public GregtechRecipe_OLD addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addFakeRecipe(aCheckForCollisions, new GregtechRecipe_OLD(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); - } - - /** - * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes - */ - public GregtechRecipe_OLD addFakeRecipe(boolean aCheckForCollisions, GregtechRecipe_OLD aRecipe) { - return addRecipe(aRecipe, aCheckForCollisions, true, false); - } - - public GregtechRecipe_OLD add(GregtechRecipe_OLD aRecipe) { - Utils.LOG_INFO("Adding Recipe Method 3"); - mRecipeList.add(aRecipe); - for (FluidStack aFluid : aRecipe.mFluidInputs) - if (aFluid != null) { - Utils.LOG_INFO("Fluid is valid - getting some kind of fluid instance to add to the recipe hashmap."); - Collection tList = mRecipeFluidMap.get(aFluid.getFluid()); - if (tList == null) mRecipeFluidMap.put(aFluid.getFluid(), tList = new HashSet(1)); - tList.add(aRecipe); - } - return addToItemMap(aRecipe); - } - - public void reInit() { - Map> tMap = mRecipeItemMap; - if (tMap != null) tMap.clear(); - for (GregtechRecipe_OLD tRecipe : mRecipeList) { - GT_OreDictUnificator.setStackArray(true, tRecipe.mInputs); - GT_OreDictUnificator.setStackArray(true, tRecipe.mOutputs); - if (tMap != null) addToItemMap(tRecipe); - } - } - - /** - * @return if this Item is a valid Input for any for the Recipes - */ - public boolean containsInput(ItemStack aStack) { - return aStack != null && (mRecipeItemMap.containsKey(new GT_ItemStack(aStack)) || mRecipeItemMap.containsKey(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack)))); - } - - /** - * @return if this Fluid is a valid Input for any for the Recipes - */ - public boolean containsInput(FluidStack aFluid) { - return aFluid != null && containsInput(aFluid.getFluid()); - } - - /** - * @return if this Fluid is a valid Input for any for the Recipes - */ - public boolean containsInput(Fluid aFluid) { - return aFluid != null && mRecipeFluidMap.containsKey(aFluid); - } - - public GregtechRecipe_OLD findRecipe(IHasWorldObjectAndCoords aTileEntity, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) { - return findRecipe(aTileEntity, null, aNotUnificated, aVoltage, aFluids, null, aInputs); - } - - public GregtechRecipe_OLD findRecipe(IHasWorldObjectAndCoords aTileEntity, GregtechRecipe_OLD aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) { - return findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, null, aInputs); - } - - /** - * finds a Recipe matching the aFluid and ItemStack Inputs. - * - * @param aTileEntity an Object representing the current coordinates of the executing Block/Entity/Whatever. This may be null, especially during Startup. - * @param aRecipe in case this is != null it will try to use this Recipe first when looking things up. - * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs - * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage - * @param aFluids the Fluid Inputs - * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. - * @param aInputs the Item Inputs - * @return the Recipe it has found or null for no matching Recipe - */ - public GregtechRecipe_OLD findRecipe(IHasWorldObjectAndCoords aTileEntity, GregtechRecipe_OLD aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - // No Recipes? Well, nothing to be found then. - if (mRecipeList.isEmpty()) return null; - - // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes. - // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes. - if (GregTech_API.sPostloadFinished) { - if (mMinimalInputFluids > 0) { - if (aFluids == null) return null; - int tAmount = 0; - for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; - if (tAmount < mMinimalInputFluids) return null; - } - if (mMinimalInputItems > 0) { - if (aInputs == null) return null; - int tAmount = 0; - for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; - if (tAmount < mMinimalInputItems) return null; - } - } - - // Unification happens here in case the Input isn't already unificated. - if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); - - // Check the Recipe which has been used last time in order to not have to search for it again, if possible. - if (aRecipe != null) - if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; - - // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. - if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) - if (tStack != null) { - Collection - tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); - if (tRecipes != null) for (GregtechRecipe_OLD tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack))); - if (tRecipes != null) for (GregtechRecipe_OLD tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - - // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too. - if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) - if (aFluid != null) { - Collection - tRecipes = mRecipeFluidMap.get(aFluid.getFluid()); - if (tRecipes != null) for (GregtechRecipe_OLD tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - - // And nothing has been found. - return null; - } - - protected GregtechRecipe_OLD addToItemMap(GregtechRecipe_OLD aRecipe) { - Utils.LOG_INFO("Adding Recipe Method 4"); - for (ItemStack aStack : aRecipe.mInputs) - if (aStack != null) { - Utils.LOG_INFO("Method 4 - Manipulating "+aStack.getDisplayName()); - GT_ItemStack tStack = new GT_ItemStack(aStack); - Utils.LOG_INFO("Method 4 - Made gt stack of item "+tStack.toStack().getDisplayName()); - Collection tList = mRecipeItemMap.get(tStack); - if (tList != null){ - Utils.LOG_INFO("Method 4 - Gt Recipe Hashmap: "+tList.toString()); - } - if (tList == null){ - Utils.LOG_INFO("Method 4 - brrr list was NUll"); - mRecipeItemMap.put(tStack, tList = new HashSet(1)); - Utils.LOG_INFO("Method 4 - Attemping backup method for Gt Recipe Hashmap:"); - - while (tList.iterator().hasNext()){ - Utils.LOG_INFO(tList.iterator().next().toString()); - } - - } - tList.add(aRecipe); - Utils.LOG_INFO("Method 4 - Added recipe to map? I think."); - } - return aRecipe; - } - - public GregtechRecipe_OLD findRecipe(IGregTechTileEntity baseMetaTileEntity, GregtechRecipe_OLD aRecipe, boolean aNotUnificated, - long aVoltage, FluidStack[] aFluids, FluidStack[] fluidStacks) { - - ItemStack aInputs[] = null; - // No Recipes? Well, nothing to be found then. - if (mRecipeList.isEmpty()) return null; - - // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes. - // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes. - if (GregTech_API.sPostloadFinished) { - if (mMinimalInputFluids > 0) { - if (aFluids == null) return null; - int tAmount = 0; - for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; - if (tAmount < mMinimalInputFluids) return null; - } - if (mMinimalInputItems > 0) { - if (aInputs == null) return null; - int tAmount = 0; - for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; - if (tAmount < mMinimalInputItems) return null; - } - } - - // Unification happens here in case the Input isn't already unificated. - if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); - - // Check the Recipe which has been used last time in order to not have to search for it again, if possible. - if (aRecipe != null) - if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; - - // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. - if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) - if (tStack != null) { - Collection - tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); - if (tRecipes != null) for (GregtechRecipe_OLD tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack))); - if (tRecipes != null) for (GregtechRecipe_OLD tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - - // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too. - if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) - if (aFluid != null) { - Collection - tRecipes = mRecipeFluidMap.get(aFluid.getFluid()); - if (tRecipes != null) for (GregtechRecipe_OLD tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - - // And nothing has been found. - return null; - } - } - - // ----------------------------------------------------------------------------------------------------------------- - // Here are a few Classes I use for Special Cases in some Machines without having to write a separate Machine Class. - // ----------------------------------------------------------------------------------------------------------------- - - /** - * Abstract Class for general Recipe Handling of non GT Recipes - */ - public static abstract class GT_Recipe_Map_NonGTRecipes extends Gregtech_Recipe_Map { - public GT_Recipe_Map_NonGTRecipes(Collection aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); - } - - @Override - public boolean containsInput(ItemStack aStack) { - return false; - } - - @Override - public boolean containsInput(FluidStack aFluid) { - return false; - } - - @Override - public boolean containsInput(Fluid aFluid) { - return false; - } - - @Override - public GregtechRecipe_OLD addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return null; - } - - @Override - public GregtechRecipe_OLD addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return null; - } - - @Override - public GregtechRecipe_OLD addRecipe(GregtechRecipe_OLD aRecipe) { - return null; - } - - @Override - public GregtechRecipe_OLD addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return null; - } - - @Override - public GregtechRecipe_OLD addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return null; - } - - @Override - public GregtechRecipe_OLD addFakeRecipe(boolean aCheckForCollisions, GregtechRecipe_OLD aRecipe) { - return null; - } - - @Override - public GregtechRecipe_OLD add(GregtechRecipe_OLD aRecipe) { - return null; - } - - @Override - public void reInit() {/**/} - - @Override - protected GregtechRecipe_OLD addToItemMap(GregtechRecipe_OLD aRecipe) { - return null; - } - } - - /** - * Just a Recipe Map with Utility specifically for Fuels. - */ - public static class Gregtech_Recipe_Map_Fuel extends Gregtech_Recipe_Map { - public Gregtech_Recipe_Map_Fuel(Collection aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); - } - - public GregtechRecipe_OLD addFuel(ItemStack aInput, ItemStack aOutput, int aFuelValueInEU) { - Utils.LOG_INFO("Adding Fuel using method 1"); - return addFuel(aInput, aOutput, null, null, 10000, aFuelValueInEU); - } - - public GregtechRecipe_OLD addFuel(ItemStack aInput, ItemStack aOutput, int aChance, int aFuelValueInEU) { - Utils.LOG_INFO("Adding Fuel using method 2"); - return addFuel(aInput, aOutput, null, null, aChance, aFuelValueInEU); - } - - public GregtechRecipe_OLD addFuel(FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) { - Utils.LOG_INFO("Adding Fuel using method 3"); - return addFuel(null, null, aFluidInput, aFluidOutput, 10000, aFuelValueInEU); - } - - public GregtechRecipe_OLD addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) { - Utils.LOG_INFO("Adding Fuel using method 4"); - return addFuel(aInput, aOutput, aFluidInput, aFluidOutput, 10000, aFuelValueInEU); - } - - public GregtechRecipe_OLD addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aChance, int aFuelValueInEU) { - Utils.LOG_INFO("Adding Fuel using method 5"); - return addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput}, null, new int[]{aChance}, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, 0, 0, aFuelValueInEU); - } - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java index 601d403f2d..c7d6dcbbba 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java @@ -38,8 +38,8 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Multitank Exterior Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Hastelloy-N Reactor Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Zeron-100 Reactor Shielding"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Unused Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Unused Coil Block"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Blast Smelter Heat Containment Coil "); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Blast Smelter Casing Block"); GregtechItemList.Casing_Centrifuge1.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_CokeOven.set(new ItemStack(this, 1, 1)); GregtechItemList.Casing_CokeOven_Coil1.set(new ItemStack(this, 1, 2)); @@ -54,8 +54,8 @@ extends GregtechMetaCasingBlocksAbstract { GregtechItemList.Casing_MultitankExterior.set(new ItemStack(this, 1, 11)); GregtechItemList.Casing_Reactor_I.set(new ItemStack(this, 1, 12)); GregtechItemList.Casing_Reactor_II.set(new ItemStack(this, 1, 13)); - GregtechItemList.Casing_Coil_U3.set(new ItemStack(this, 1, 14)); - GregtechItemList.Casing_Coil_U4.set(new ItemStack(this, 1, 15)); + GregtechItemList.Casing_Coil_BlastSmelter.set(new ItemStack(this, 1, 14)); + GregtechItemList.Casing_BlastSmelter.set(new ItemStack(this, 1, 15)); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java index c5b8985396..4b8fff1cc3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java @@ -6,11 +6,11 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; public class CasingTextureHandler { - + //private static final TexturesGregtech59 gregtech59 = new TexturesGregtech59(); //private static final TexturesGregtech58 gregtech58 = new TexturesGregtech58(); private static final TexturesCentrifugeMultiblock gregtechX = new TexturesCentrifugeMultiblock(); - + public static IIcon getIcon(int aSide, int aMeta) { //Texture ID's. case 0 == ID[57] if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { @@ -19,7 +19,7 @@ public class CasingTextureHandler { return TexturesGtBlocks.Casing_Material_MaragingSteel.getIcon(); //Coke Oven Frame case 1: - return TexturesGtBlocks.Casing_Material_Staballoy61.getIcon(); + return TexturesGtBlocks.Casing_Material_Tantalloy61.getIcon(); //Coke Oven Casing Tier 1 case 2: return Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon(); @@ -56,6 +56,10 @@ public class CasingTextureHandler { //Reactor Casing II case 13: return TexturesGtBlocks.Casing_Material_Zeron100.getIcon(); + case 14: + return TexturesGtBlocks.Casing_Staballoy_Firebox.getIcon(); + case 15: + return TexturesGtBlocks.Casing_Material_Grisium.getIcon(); default: return Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon(); @@ -64,8 +68,8 @@ public class CasingTextureHandler { } return Textures.BlockIcons.MACHINE_CASING_GEARBOX_TUNGSTENSTEEL.getIcon(); } - - + + public static IIcon handleCasingsGT(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide, GregtechMetaCasingBlocks thisBlock) { /*if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ return gregtech59.handleCasingsGT59(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java index e82355ae8c..cc7e548021 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java @@ -73,8 +73,8 @@ public class TexturesGtBlocks { public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; //Material Casings - private static final CustomIcon Internal_Casing_Staballoy61 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TANTALLOY61"); - public static final CustomIcon Casing_Material_Staballoy61 = Internal_Casing_Staballoy61; + private static final CustomIcon Internal_Casing_Tantalloy61 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TANTALLOY61"); + public static final CustomIcon Casing_Material_Tantalloy61 = Internal_Casing_Tantalloy61; private static final CustomIcon Internal_Casing_MaragingSteel = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_MARAGINGSTEEL"); public static final CustomIcon Casing_Material_MaragingSteel = Internal_Casing_MaragingSteel; private static final CustomIcon Internal_Casing_Stellite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_STELLITE"); @@ -87,6 +87,22 @@ public class TexturesGtBlocks { public static final CustomIcon Casing_Material_Zeron100 = Internal_Casing_Zeron100; private static final CustomIcon Internal_Casing_Potin = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_POTIN"); public static final CustomIcon Casing_Material_Potin = Internal_Casing_Potin; + + private static final CustomIcon Internal_Casing_Grisium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_GRISIUM"); + public static final CustomIcon Casing_Material_Grisium = Internal_Casing_Grisium; + private static final CustomIcon Internal_Casing_Incoloy020 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_020"); + public static final CustomIcon Casing_Material_Incoloy020 = Internal_Casing_Incoloy020; + private static final CustomIcon Internal_Casing_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_DS"); + public static final CustomIcon Casing_Material_IncoloyDS = Internal_Casing_IncoloyDS; + private static final CustomIcon Internal_Casing_IncoloyMA956 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_MA956"); + public static final CustomIcon Casing_Material_IncoloyMA956 = Internal_Casing_IncoloyMA956; + private static final CustomIcon Internal_Casing_ZirconiumCarbide = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE"); + public static final CustomIcon Casing_Material_ZirconiumCarbide = Internal_Casing_ZirconiumCarbide; + + //Material Machine/Firebox Casings + private static final CustomIcon Internal_Casing_Staballoy_Firebox = new CustomIcon("TileEntities/MACHINE_CASING_FIREBOX_STABALLOY"); + public static final CustomIcon Casing_Staballoy_Firebox = Internal_Casing_Staballoy_Firebox; + //Misc Casings private static final CustomIcon Internal_Casing_Machine_Redstone_Off = new CustomIcon("TileEntities/cover_redstone_conductor"); public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastFurnace.java deleted file mode 100644 index f717bdf001..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastFurnace.java +++ /dev/null @@ -1,214 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; - -import java.util.ArrayList; -import java.util.Arrays; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -public class GregtechMetaTileEntity_AlloyBlastFurnace - extends GT_MetaTileEntity_MultiBlockBase { - private int mHeatingCapacity = 0; - - public GregtechMetaTileEntity_AlloyBlastFurnace(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_AlloyBlastFurnace(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_AlloyBlastFurnace(this.mName); - } - - public String[] getDescription() { - return new String[]{"Controller Block for the Blast Furnace", "Size: 3x3x4 (Hollow)", "Controller (front middle at bottom)", "16x Heating Coils (two middle Layers, hollow)", "1x Input (one of bottom)", "1x Output (one of bottom)", "1x Energy Hatch (one of bottom)", "1x Maintenance Hatch (one of bottom)", "1x Muffler Hatch (top middle)", "Heat Proof Machine Casings for the rest"}; - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[11], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[11]}; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "ElectricBlastFurnace.png"); - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBlastRecipes; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { - if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - ArrayList tFluidList = getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 0) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBlastRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if ((tRecipe != null) && (this.mHeatingCapacity >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - updateSlots(); - return true; - } - } - return false; - } - - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - - this.mHeatingCapacity = 0; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - return false; - } - if (!aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir)) { - return false; - } - addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), 11); - - byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); - switch (tUsedMeta) { - case 12: - this.mHeatingCapacity = 1800; - break; - case 13: - this.mHeatingCapacity = 2700; - break; - case 14: - this.mHeatingCapacity = 3600; - break; - default: - return false; - } - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if ((i != 0) || (j != 0)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != tUsedMeta) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != GregTech_API.sBlockCasings1) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 11) { - return false; - } - } - } - } - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if ((xDir + i != 0) || (zDir + j != 0)) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 11)) && (!addInputToMachineList(tTileEntity, 11)) && (!addOutputToMachineList(tTileEntity, 11)) && (!addEnergyInputToMachineList(tTileEntity, 11))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 11) { - return false; - } - } - } - } - } - this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); - return true; - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerTick(ItemStack aStack) { - return 10; - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - public int getAmountOfOutputs() { - return 2; - } - - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java new file mode 100644 index 0000000000..b6b66f17b4 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -0,0 +1,239 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; + +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_AlloyBlastSmelter + extends GT_MetaTileEntity_MultiBlockBase { + private int mHeatingCapacity = 0; + + public GregtechMetaTileEntity_AlloyBlastSmelter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_AlloyBlastSmelter(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Alloy Blast Smelter", //Outputs 144mb fluid for every inputStack.stackSize; Time to use those hot metals. + "Size: 3x3x4 (Hollow)", + "Controller (front middle at bottom)", + "16x Heating Coils (two middle Layers, hollow)", + "1x Input bus (one of bottom)", + "1x Output Hatch (one of bottom)", + "1x Energy Hatch (one of bottom)", + "1x Maintenance Hatch (one of bottom)", + "1x Muffler Hatch (top middle)", + "Heat Proof Machine Casings for the rest"}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[72], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[72]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "ElectricBlastFurnace.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBlastRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (this.mHeatingCapacity >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots(); + return true; + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + this.mHeatingCapacity = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + if (!aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir)) { + return false; + } + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), 11); + + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); + switch (tUsedMeta) { + case 12: + this.mHeatingCapacity = 1800; + break; + case 13: + this.mHeatingCapacity = 2700; + break; + case 14: + this.mHeatingCapacity = 3600; + break; + default: + return false; + } + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 11) { + return false; + } + } + } + } + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((xDir + i != 0) || (zDir + j != 0)) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 11)) && (!addInputToMachineList(tTileEntity, 11)) && (!addOutputToMachineList(tTileEntity, 11)) && (!addEnergyInputToMachineList(tTileEntity, 11))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 11) { + return false; + } + } + } + } + } + this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 10; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java new file mode 100644 index 0000000000..875375cc12 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java @@ -0,0 +1,169 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.objects.MaterialStack; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.ItemStack; + +public class RecipeGen_BlastSmelter { + + public static void generateRecipes(){ + + Materials[] GregMaterials = Materials.values(); + + for (Materials M : GregMaterials){ + + if (!M.equals(Materials.Osmiridium)){ + + } + else { + + //Add a Blast Smelting Recipe, Let's go! + ItemStack tStack; + if ((null != (tStack = GT_OreDictUnificator.get(OrePrefixes.ingot, M.mSmeltInto, 1L))) && (!M.contains(SubTag.NO_SMELTING) && (M.contains(SubTag.METAL)))) { + + //Prepare some Variables + ItemStack[] components; + MaterialStack[] tMaterial; + short counter=0; + int inputStackCount=0; + int fluidAmount=0; + boolean doTest = false; + + //This Bad boy here is what dictates unique recipes. Fuck life, right? + ItemStack circuitGT = UtilsItems.getGregtechCircuit(0); + + + //Set a duration + int duration = 0; + if (M.mBlastFurnaceTemp > 100){ + duration = (int) Math.max(M.getMass() / 30L, 1L) * M.mBlastFurnaceTemp; + } + else { + duration = (int) Math.max(M.getMass() / 30L, 1L) * 200; + } + + + //Make a simple one Material Materialstack[] and log it for validity. + tMaterial = new MaterialStack[]{new MaterialStack(M, 1)}; + circuitGT = UtilsItems.getGregtechCircuit(1); + ItemStack[] tItemStackTest = new ItemStack[]{circuitGT, UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+M, 1)}; + inputStackCount = 1; + fluidAmount = 144*inputStackCount; + Utils.LOG_INFO("Adding an Alloy Blast Smelter Recipe for "+M+". Gives "+fluidAmount+"L of molten metal."); + Utils.LOG_INFO("tMaterial.length: "+tMaterial.length+"."); + for (int das=0;das 1){ + MaterialStack[] tempStack = new MaterialStack[mMaterialListSize]; + circuitGT = UtilsItems.getGregtechCircuit(mMaterialListSize); + //Just double checking + if (tempStack.length > 1){ + + //Builds me a MaterialStack[] from the MaterialList of M. + int ooo=0; + for (MaterialStack xMaterial : M.mMaterialList){ + Utils.LOG_INFO("FOUND: "+xMaterial.mMaterial); + Utils.LOG_INFO("ADDING: "+xMaterial.mMaterial); + tempStack[ooo] = M.mMaterialList.get(ooo); + ooo++; + } + + //Builds me an ItemStack[] of the materials. - Without a circuit - this gets a good count for the 144L fluid multiplier + components = new ItemStack[tempStack.length]; + for (MaterialStack aOutputPart : tempStack){ + if (aOutputPart != null){ + Utils.LOG_INFO("Finding dust: "+aOutputPart.mMaterial); + ItemStack rStack = UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+aOutputPart.mMaterial, (int) aOutputPart.mAmount); + if (rStack != null){ + Utils.LOG_INFO("Found dust: "+aOutputPart.mMaterial); + components[counter] = rStack; + inputStackCount = inputStackCount+rStack.stackSize; + } + } + counter++; + } + + ItemStack[] components_NoCircuit = components; + + + //Builds me an ItemStack[] of the materials. - With a circuit + components = new ItemStack[components_NoCircuit.length+1]; + for (int fr=0;fr 1){ - if (aInput[1] != null){ - Utils.LOG_INFO("Recipe requires input: "+aInput[1].getDisplayName()+" x"+aInput[1].stackSize); + if (aInput[0] != null){ + Utils.LOG_INFO("Recipe requires input: "+aInput[0].getDisplayName()+" x"+aInput[0].stackSize); + } + if (aInput.length > 1){ + if (aInput[1] != null){ + Utils.LOG_INFO("Recipe requires input: "+aInput[1].getDisplayName()+" x"+aInput[1].stackSize); + } + } + if (aFluidInput != null){ + Utils.LOG_INFO("Recipe requires input: "+aFluidInput.getFluid().getName()+" "+aFluidInput.amount+"mbst"); + } + if (((aInput[0] == null) && (aFluidInput == null)) || ((aOutputItems == null) && (aFluidOutput == null))) { + return false; + } + if ((aOutputItems != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aOutputItems[0], aDuration)) <= 0)) { + return false; + } + if (aOutputItems != null){ + Utils.LOG_INFO("Recipe will output: "+UtilsItems.getArrayStackNames(aOutputItems)); + } + if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { + return false; + } + if (aFluidOutput != null){ + Utils.LOG_INFO("Recipe will output: "+aFluidOutput.getFluid().getName()); } - } - if (aFluidInput != null){ - Utils.LOG_INFO("Recipe requires input: "+aFluidInput.getFluid().getName()+" "+aFluidInput.amount+"mbst"); - } - if (((aInput[0] == null) && (aFluidInput == null)) || ((aOutputItems == null) && (aFluidOutput == null))) { - return false; - } - if ((aOutputItems != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aOutputItems[0], aDuration)) <= 0)) { - return false; - } - if (aOutputItems != null){ - Utils.LOG_INFO("Recipe will output: "+UtilsItems.getArrayStackNames(aOutputItems)); - } - if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - return false; - } - if (aFluidOutput != null){ - Utils.LOG_INFO("Recipe will output: "+aFluidOutput.getFluid().getName()); - } - if (aInput.length == 1){ - Utils.LOG_INFO("Dehydrator recipe only has a single input item."); - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); + if (aInput.length == 1){ + Utils.LOG_INFO("Dehydrator recipe only has a single input item."); + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); - } - else { - Utils.LOG_INFO("Dehydrator recipe has two input items."); - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); + } + else { + Utils.LOG_INFO("Dehydrator recipe has two input items."); + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); - } + } - return true; + return true; }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");return false;} } @@ -233,12 +234,31 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { + @Override + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aOutput, int aChance, int aDuration, int aEUt) { + if ((aInput == null) || (aOutput == null)) { + return false; + } + + + if (aOutput.isFluidEqual(Materials.PhasedGold.getMolten(1))) { + aOutput = Materials.VibrantAlloy.getMolten(aOutput.amount); + } + if (aOutput.isFluidEqual(Materials.PhasedIron.getMolten(1))) { + aOutput = Materials.PulsatingIron.getMolten(aOutput.amount); + } + if ((aDuration = GregTech_API.sRecipeFile.get("blastsmelter", aOutput.getFluid().getName(), aDuration)) <= 0) { + Utils.LOG_INFO("Recipe did not register."); + return false; + } - - - - - - + for (int das=0;das Date: Wed, 26 Oct 2016 06:53:09 +1000 Subject: + Enabled the Alloy Blast Smelter. --- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 7 ++++--- .../xmod/gregtech/api/enums/GregtechItemList.java | 2 +- .../gregtech/GregtechIndustrialBlastSmelter.java | 24 ++++++++++++++++++++++ .../gregtech/GregtechIndustrialSinter.java | 24 ---------------------- 4 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialBlastSmelter.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSinter.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index c57275edce..7f7ab96ee7 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -23,9 +23,11 @@ import gtPlusPlus.core.recipe.ShapedRecipeObject; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; +import gtPlusPlus.xmod.gregtech.registration.gregtech.Gregtech4Content; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechDehydrator; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechEnergyBuffer; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechGeothermalThermalGenerator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialBlastSmelter; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCentrifuge; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCokeOven; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialElectrolyzer; @@ -42,7 +44,6 @@ import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSolarGenerators; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSteamCondenser; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSuperConductionPoint; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTieredFluidTanks; -import gtPlusPlus.xmod.gregtech.registration.gregtech.Gregtech4Content; import java.util.LinkedList; import java.util.Queue; @@ -85,14 +86,14 @@ public class COMPAT_HANDLER { GregtechIndustrialMacerator.run(); GregtechIndustrialWiremill.run(); GregtechIndustrialMassFabricator.run(); - //GregtechIndustrialSinter.run(); + GregtechIndustrialBlastSmelter.run(); GregtechSolarGenerators.run(); GregtechPowerSubStation.run(); GregtechDehydrator.run(); GregtechTieredFluidTanks.run(); GregtechIndustrialMultiTank.run(); - Gregtech4Content.run(); GregtechGeothermalThermalGenerator.run(); + Gregtech4Content.run(); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index e69ab529c6..dbf2e9f877 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -100,7 +100,7 @@ public enum GregtechItemList implements GregtechItemContainer { Food_Baked_Raisin_Bread, //For sintering TODO - Industrial_SinterFurnace, + Industrial_AlloyBlastSmelter, //Block that enables uplink to a superconductor network SuperConductorInputNode, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialBlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialBlastSmelter.java new file mode 100644 index 0000000000..0e08c4b135 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialBlastSmelter.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_AlloyBlastSmelter; + +public class GregtechIndustrialBlastSmelter{ + + public static void run() + { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech){ + Utils.LOG_INFO("Gregtech5u Content | Registering Industrial Blast Smelter Multiblock."); + run1(); + } + + } + + private static void run1() + { + //Industrial Electrolyzer Multiblock + GregtechItemList.Industrial_AlloyBlastSmelter.set(new GregtechMetaTileEntity_AlloyBlastSmelter(810, "industrialsalloyamelter.controller.tier.single", "Blast Smelter").getStackForm(1L)); + + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSinter.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSinter.java deleted file mode 100644 index d03554224c..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSinter.java +++ /dev/null @@ -1,24 +0,0 @@ -package gtPlusPlus.xmod.gregtech.registration.gregtech; - -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialSinter; - -public class GregtechIndustrialSinter{ - - public static void run() - { - if (gtPlusPlus.core.lib.LoadedMods.Gregtech){ - Utils.LOG_INFO("Gregtech5u Content | Registering Industrial Sinter Furnace Multiblock."); - run1(); - } - - } - - private static void run1() - { - //Industrial Electrolyzer Multiblock - GregtechItemList.Industrial_SinterFurnace.set(new GregtechMetaTileEntity_IndustrialSinter(810, "industrialsinterfurnace.controller.tier.single", "Sinter Furnace").getStackForm(1L)); - - } -} \ No newline at end of file -- cgit From c1056d7887df48322f388d912ef71b0086338908 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Fri, 28 Oct 2016 00:25:10 +1000 Subject: $ Hopefully fixed the output slots in the Maceration stack overflowing. $ Fixed the Alloy Blast Furnace doing the wrong things when processing recipes. (Recipes just for circuits to molten metal) % Refactored a heap of Textures. --- src/Java/gtPlusPlus/GTplusplus.java | 4 +- .../implementations/GregtechMetaEnergyBuffer.java | 18 +-- .../blocks/textures/CasingTextureHandler.java | 20 +-- .../textures/TexturesCentrifugeMultiblock.java | 2 +- .../common/blocks/textures/TexturesGtBlock.java | 165 +++++++++++++++++++++ .../common/blocks/textures/TexturesGtBlocks.java | 165 --------------------- .../GT_MetaTileEntity_TesseractGenerator.java | 4 +- .../GT_MetaTileEntity_TesseractTerminal.java | 4 +- .../GregtechMetaTileEntityGeothermalGenerator.java | 6 +- .../GregtechMetaTileEntityRocketFuelGenerator.java | 26 ++-- .../GregtechMetaTileEntity_AlloyBlastSmelter.java | 6 +- ...regtechMetaTileEntity_IndustrialCentrifuge.java | 2 +- ...GregtechMetaTileEntity_IndustrialMacerator.java | 31 +++- .../GregtechMetaTileEntity_IronBlastFurnace.java | 8 +- .../GregtechMetaTileEntity_MassFabricator.java | 4 +- 15 files changed, 245 insertions(+), 220 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 353044e6ee..11c5c5a1c8 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -25,7 +25,7 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; import java.awt.event.ActionEvent; @@ -126,7 +126,7 @@ implements ActionListener Utils.LOG_WARNING("Processing texture: "+TexturesGtTools.SKOOKUM_CHOOCHER.getTextureFile().getResourcePath()); //Blocks - Utils.LOG_WARNING("Processing texture: "+TexturesGtBlocks.Casing_Machine_Dimensional.getTextureFile().getResourcePath()); + Utils.LOG_WARNING("Processing texture: "+TexturesGtBlock.Casing_Machine_Dimensional.getTextureFile().getResourcePath()); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java index 30634620c5..4f4f3f931f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java @@ -15,7 +15,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import ic2.api.item.IElectricItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -80,22 +80,22 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { public ITexture[] getBack(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; } public ITexture[] getBottom(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; } public ITexture[] getTop(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Screen_Logo)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; } public ITexture[] getSides(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; } @@ -105,22 +105,22 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; } public ITexture[] getBottomActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; } public ITexture[] getTopActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Screen_Logo)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; } public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Dimensional_Orange)}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; } /*@Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java index 7e1c79aae3..8bd32d7d8b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java @@ -16,10 +16,10 @@ public class CasingTextureHandler { switch (aMeta) { //Centrifuge case 0: - return TexturesGtBlocks.Casing_Material_MaragingSteel.getIcon(); + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); //Coke Oven Frame case 1: - return TexturesGtBlocks.Casing_Material_Tantalloy61.getIcon(); + return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); //Coke Oven Casing Tier 1 case 2: return Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon(); @@ -31,35 +31,35 @@ public class CasingTextureHandler { return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); //Electrolyzer Casings case 5: - return TexturesGtBlocks.Casing_Material_Potin.getIcon(); + return TexturesGtBlock.Casing_Material_Potin.getIcon(); //Broken Blue Fusion Casings case 6: return Textures.BlockIcons.MACHINE_CASING_FUSION.getIcon(); //Maceration Stack Casings case 7: - return TexturesGtBlocks.Casing_Material_Tumbaga.getIcon(); + return TexturesGtBlock.Casing_Material_Tumbaga.getIcon(); //Broken Pink Fusion Casings case 8: return Textures.BlockIcons.MACHINE_CASING_FUSION_2.getIcon(); //Matter Fabricator Casings case 9: - return TexturesGtBlocks.Casing_Machine_Dimensional_Adv.getIcon(); + return TexturesGtBlock.Casing_Machine_Dimensional_Adv.getIcon(); //Iron Blast Fuance Textures case 10: - return TexturesGtBlocks.Casing_Machine_Simple_Top.getIcon(); + return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); //Multitank Exterior Casing case 11: return Textures.BlockIcons.MACHINE_CASING_GRATE.getIcon(); //Reactor Casing I case 12: - return TexturesGtBlocks.Casing_Material_Stellite.getIcon(); + return TexturesGtBlock.Casing_Material_Stellite.getIcon(); //Reactor Casing II case 13: - return TexturesGtBlocks.Casing_Material_Zeron100.getIcon(); + return TexturesGtBlock.Casing_Material_Zeron100.getIcon(); case 14: - return TexturesGtBlocks.Casing_Staballoy_Firebox.getIcon(); + return TexturesGtBlock.Casing_Staballoy_Firebox.getIcon(); case 15: - return TexturesGtBlocks.Casing_Material_ZirconiumCarbide.getIcon(); + return TexturesGtBlock.Casing_Material_ZirconiumCarbide.getIcon(); default: return Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java index f466c2e972..c23824913e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java @@ -4,7 +4,7 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialCentrifuge; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java new file mode 100644 index 0000000000..04a7fdceed --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -0,0 +1,165 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +public class TexturesGtBlock { + + /* + * Handles Custom Textures. + */ + + public static class CustomIcon implements IIconContainer, Runnable { + protected IIcon mIcon; + protected String mIconName; + + public CustomIcon(String aIconName) { + mIconName = aIconName; + Utils.LOG_WARNING("Constructing a Custom Texture. " + mIconName); + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + mIcon = GregTech_API.sBlockIcons.registerIcon(CORE.MODID + ":" + mIconName); + Utils.LOG_WARNING("FIND ME _ Processing texture: "+this.getTextureFile().getResourcePath()); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + } + + + /* + * Add Some Custom Textures below. + * I am not sure whether or not I need to declare them as such, but better to be safe than sorry. + * Right? + */ + + + + //Machine Casings + //Simple + private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); + public static final CustomIcon Casing_Machine_Simple_Top = Internal_Casing_Machine_Simple_Top; + private static final CustomIcon Internal_Casing_Machine_Simple_Bottom = new CustomIcon("TileEntities/machine_bottom"); + public static final CustomIcon Casing_Machine_Simple_Bottom = Internal_Casing_Machine_Simple_Bottom; + //Advanced and Ultra + private static final CustomIcon Internal_Casing_Machine_Advanced = new CustomIcon("TileEntities/high_adv_machine"); + public static final CustomIcon Casing_Machine_Advanced = Internal_Casing_Machine_Advanced; + private static final CustomIcon Internal_Casing_Machine_Ultra = new CustomIcon("TileEntities/adv_machine_lesu"); + public static final CustomIcon Casing_Machine_Ultra = Internal_Casing_Machine_Ultra; + //Dimensional - Non Overlay + private static final CustomIcon Internal_Casing_Machine_Dimensional = new CustomIcon("TileEntities/adv_machine_dimensional"); + public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; + private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = new CustomIcon("TileEntities/high_adv_machine_dimensional"); + public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; + + //Material Casings + private static final CustomIcon Internal_Casing_Tantalloy61 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TANTALLOY61"); + public static final CustomIcon Casing_Material_Tantalloy61 = Internal_Casing_Tantalloy61; + private static final CustomIcon Internal_Casing_MaragingSteel = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_MARAGINGSTEEL"); + public static final CustomIcon Casing_Material_MaragingSteel = Internal_Casing_MaragingSteel; + private static final CustomIcon Internal_Casing_Stellite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_STELLITE"); + public static final CustomIcon Casing_Material_Stellite = Internal_Casing_Stellite; + private static final CustomIcon Internal_Casing_Talonite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TALONITE"); + public static final CustomIcon Casing_Material_Talonite = Internal_Casing_Talonite; + private static final CustomIcon Internal_Casing_Tumbaga = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TUMBAGA"); + public static final CustomIcon Casing_Material_Tumbaga = Internal_Casing_Tumbaga; + private static final CustomIcon Internal_Casing_Zeron100 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZERON100"); + public static final CustomIcon Casing_Material_Zeron100 = Internal_Casing_Zeron100; + private static final CustomIcon Internal_Casing_Potin = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_POTIN"); + public static final CustomIcon Casing_Material_Potin = Internal_Casing_Potin; + + private static final CustomIcon Internal_Casing_Grisium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_GRISIUM"); + public static final CustomIcon Casing_Material_Grisium = Internal_Casing_Grisium; + private static final CustomIcon Internal_Casing_Incoloy020 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_020"); + public static final CustomIcon Casing_Material_Incoloy020 = Internal_Casing_Incoloy020; + private static final CustomIcon Internal_Casing_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_DS"); + public static final CustomIcon Casing_Material_IncoloyDS = Internal_Casing_IncoloyDS; + private static final CustomIcon Internal_Casing_IncoloyMA956 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_MA956"); + public static final CustomIcon Casing_Material_IncoloyMA956 = Internal_Casing_IncoloyMA956; + private static final CustomIcon Internal_Casing_ZirconiumCarbide = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE"); + public static final CustomIcon Casing_Material_ZirconiumCarbide = Internal_Casing_ZirconiumCarbide; + + //Material Machine/Firebox Casings + private static final CustomIcon Internal_Casing_Staballoy_Firebox = new CustomIcon("TileEntities/MACHINE_CASING_FIREBOX_STABALLOY"); + public static final CustomIcon Casing_Staballoy_Firebox = Internal_Casing_Staballoy_Firebox; + + //Misc Casings + private static final CustomIcon Internal_Casing_Machine_Redstone_Off = new CustomIcon("TileEntities/cover_redstone_conductor"); + public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; + private static final CustomIcon Internal_Casing_Machine_Redstone_On = new CustomIcon("TileEntities/cover_redstone_emitter"); + public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; + + //Overlays + //Fan Textures + private static final CustomIcon Internal_Overlay_Machine_Vent = new CustomIcon("TileEntities/machine_top_vent_rotating"); + public static final CustomIcon Overlay_Machine_Vent = Internal_Overlay_Machine_Vent; + private static final CustomIcon Internal_Overlay_Machine_Vent_Fast = new CustomIcon("TileEntities/machine_top_vent_rotating_fast"); + public static final CustomIcon Overlay_Machine_Vent_Fast = Internal_Overlay_Machine_Vent_Fast; + private static final CustomIcon Internal_Overlay_Machine_Vent_Adv = new CustomIcon("TileEntities/adv_machine_vent_rotating"); + public static final CustomIcon Overlay_Machine_Vent_Adv = Internal_Overlay_Machine_Vent_Adv; + //Speaker Texture + private static final CustomIcon Internal_Overlay_Machine_Sound = new CustomIcon("TileEntities/audio_out"); + public static final CustomIcon Overlay_Machine_Sound = Internal_Overlay_Machine_Sound; + private static final CustomIcon Internal_Overlay_Machine_Sound_Active = new CustomIcon("TileEntities/audio_out_active"); + public static final CustomIcon Overlay_Machine_Sound_Active = Internal_Overlay_Machine_Sound_Active; + //Diesel Engines + private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical = new CustomIcon("TileEntities/machine_top_dieselmotor"); + public static final CustomIcon Overlay_Machine_Diesel_Vertical = Internal_Overlay_Machine_Diesel_Vertical; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal = new CustomIcon("TileEntities/machine_top_dieselmotor2"); + public static final CustomIcon Overlay_Machine_Diesel_Horizontal = Internal_Overlay_Machine_Diesel_Horizontal; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical_Active = new CustomIcon("TileEntities/machine_top_dieselmotor_active"); + public static final CustomIcon Overlay_Machine_Diesel_Vertical_Active = Internal_Overlay_Machine_Diesel_Vertical_Active; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal_Active = new CustomIcon("TileEntities/machine_top_dieselmotor2_active"); + public static final CustomIcon Overlay_Machine_Diesel_Horizontal_Active = Internal_Overlay_Machine_Diesel_Horizontal_Active; + //Computer Screens + private static final CustomIcon Internal_Casing_Machine_Screen_1 = new CustomIcon("TileEntities/adv_machine_screen_random1"); + public static final CustomIcon Casing_Machine_Screen_1 = Internal_Casing_Machine_Screen_1; + private static final CustomIcon Internal_Casing_Machine_Screen_2 = new CustomIcon("TileEntities/adv_machine_screen_random2"); + public static final CustomIcon Casing_Machine_Screen_2 = Internal_Casing_Machine_Screen_2; + private static final CustomIcon Internal_Casing_Machine_Screen_3 = new CustomIcon("TileEntities/adv_machine_screen_random3"); + public static final CustomIcon Casing_Machine_Screen_3 = Internal_Casing_Machine_Screen_3; + private static final CustomIcon Internal_Casing_Machine_Screen_Frequency = new CustomIcon("TileEntities/adv_machine_screen_frequency"); + public static final CustomIcon Casing_Machine_Screen_Frequency = Internal_Casing_Machine_Screen_Frequency; + private static final CustomIcon Internal_Overlay_Machine_Screen_Logo = new CustomIcon("TileEntities/adv_machine_screen_logo"); + public static final CustomIcon Overlay_Machine_Screen_Logo = Internal_Overlay_Machine_Screen_Logo; + //Crafting Overlays + private static final CustomIcon Internal_Overlay_Crafting_Bronze = new CustomIcon("TileEntities/bronze_top_crafting"); + public static final CustomIcon Overlay_Crafting_Bronze = Internal_Overlay_Crafting_Bronze; + private static final CustomIcon Internal_Overlay_Crafting_Steel = new CustomIcon("TileEntities/cover_crafting"); + public static final CustomIcon Overlay_Crafting_Steel = Internal_Overlay_Crafting_Steel; + //Dimensional + private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); + public static final CustomIcon Overlay_Machine_Dimensional_Blue = Internal_Overlay_Machine_Dimensional_Blue; + private static final CustomIcon Internal_Overlay_Machine_Dimensional_Orange = new CustomIcon("TileEntities/adv_machine_dimensional_cover_orange"); + public static final CustomIcon Overlay_Machine_Dimensional_Orange = Internal_Overlay_Machine_Dimensional_Orange; + //Icons + private static final CustomIcon Internal_Overlay_MatterFab = new CustomIcon("TileEntities/adv_machine_matterfab"); + public static final CustomIcon Overlay_MatterFab = Internal_Overlay_MatterFab; + private static final CustomIcon Internal_Overlay_MatterFab_Active = new CustomIcon("TileEntities/adv_machine_matterfab_active"); + public static final CustomIcon Overlay_MatterFab_Active = Internal_Overlay_MatterFab_Active; + private static final CustomIcon Internal_Overlay_Oil = new CustomIcon("TileEntities/adv_machine_oil"); + public static final CustomIcon Overlay_Oil = Internal_Overlay_Oil; + private static final CustomIcon Internal_Overlay_UU_Matter = new CustomIcon("TileEntities/adv_machine_uum"); + public static final CustomIcon Overlay_UU_Matter = Internal_Overlay_UU_Matter; + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java deleted file mode 100644 index cc7e548021..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlocks.java +++ /dev/null @@ -1,165 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.blocks.textures; - -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.IIconContainer; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; - -public class TexturesGtBlocks { - - /* - * Handles Custom Textures. - */ - - public static class CustomIcon implements IIconContainer, Runnable { - protected IIcon mIcon; - protected String mIconName; - - public CustomIcon(String aIconName) { - mIconName = aIconName; - Utils.LOG_WARNING("Constructing a Custom Texture. " + mIconName); - GregTech_API.sGTBlockIconload.add(this); - } - - @Override - public IIcon getIcon() { - return mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return null; - } - - @Override - public void run() { - mIcon = GregTech_API.sBlockIcons.registerIcon(CORE.MODID + ":" + mIconName); - Utils.LOG_WARNING("FIND ME _ Processing texture: "+this.getTextureFile().getResourcePath()); - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationBlocksTexture; - } - } - - - /* - * Add Some Custom Textures below. - * I am not sure whether or not I need to declare them as such, but better to be safe than sorry. - * Right? - */ - - - - //Machine Casings - //Simple - private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); - public static final CustomIcon Casing_Machine_Simple_Top = Internal_Casing_Machine_Simple_Top; - private static final CustomIcon Internal_Casing_Machine_Simple_Bottom = new CustomIcon("TileEntities/machine_bottom"); - public static final CustomIcon Casing_Machine_Simple_Bottom = Internal_Casing_Machine_Simple_Bottom; - //Advanced and Ultra - private static final CustomIcon Internal_Casing_Machine_Advanced = new CustomIcon("TileEntities/high_adv_machine"); - public static final CustomIcon Casing_Machine_Advanced = Internal_Casing_Machine_Advanced; - private static final CustomIcon Internal_Casing_Machine_Ultra = new CustomIcon("TileEntities/adv_machine_lesu"); - public static final CustomIcon Casing_Machine_Ultra = Internal_Casing_Machine_Ultra; - //Dimensional - Non Overlay - private static final CustomIcon Internal_Casing_Machine_Dimensional = new CustomIcon("TileEntities/adv_machine_dimensional"); - public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; - private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = new CustomIcon("TileEntities/high_adv_machine_dimensional"); - public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; - - //Material Casings - private static final CustomIcon Internal_Casing_Tantalloy61 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TANTALLOY61"); - public static final CustomIcon Casing_Material_Tantalloy61 = Internal_Casing_Tantalloy61; - private static final CustomIcon Internal_Casing_MaragingSteel = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_MARAGINGSTEEL"); - public static final CustomIcon Casing_Material_MaragingSteel = Internal_Casing_MaragingSteel; - private static final CustomIcon Internal_Casing_Stellite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_STELLITE"); - public static final CustomIcon Casing_Material_Stellite = Internal_Casing_Stellite; - private static final CustomIcon Internal_Casing_Talonite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TALONITE"); - public static final CustomIcon Casing_Material_Talonite = Internal_Casing_Talonite; - private static final CustomIcon Internal_Casing_Tumbaga = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TUMBAGA"); - public static final CustomIcon Casing_Material_Tumbaga = Internal_Casing_Tumbaga; - private static final CustomIcon Internal_Casing_Zeron100 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZERON100"); - public static final CustomIcon Casing_Material_Zeron100 = Internal_Casing_Zeron100; - private static final CustomIcon Internal_Casing_Potin = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_POTIN"); - public static final CustomIcon Casing_Material_Potin = Internal_Casing_Potin; - - private static final CustomIcon Internal_Casing_Grisium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_GRISIUM"); - public static final CustomIcon Casing_Material_Grisium = Internal_Casing_Grisium; - private static final CustomIcon Internal_Casing_Incoloy020 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_020"); - public static final CustomIcon Casing_Material_Incoloy020 = Internal_Casing_Incoloy020; - private static final CustomIcon Internal_Casing_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_DS"); - public static final CustomIcon Casing_Material_IncoloyDS = Internal_Casing_IncoloyDS; - private static final CustomIcon Internal_Casing_IncoloyMA956 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_MA956"); - public static final CustomIcon Casing_Material_IncoloyMA956 = Internal_Casing_IncoloyMA956; - private static final CustomIcon Internal_Casing_ZirconiumCarbide = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE"); - public static final CustomIcon Casing_Material_ZirconiumCarbide = Internal_Casing_ZirconiumCarbide; - - //Material Machine/Firebox Casings - private static final CustomIcon Internal_Casing_Staballoy_Firebox = new CustomIcon("TileEntities/MACHINE_CASING_FIREBOX_STABALLOY"); - public static final CustomIcon Casing_Staballoy_Firebox = Internal_Casing_Staballoy_Firebox; - - //Misc Casings - private static final CustomIcon Internal_Casing_Machine_Redstone_Off = new CustomIcon("TileEntities/cover_redstone_conductor"); - public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; - private static final CustomIcon Internal_Casing_Machine_Redstone_On = new CustomIcon("TileEntities/cover_redstone_emitter"); - public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; - - //Overlays - //Fan Textures - private static final CustomIcon Internal_Overlay_Machine_Vent = new CustomIcon("TileEntities/machine_top_vent_rotating"); - public static final CustomIcon Overlay_Machine_Vent = Internal_Overlay_Machine_Vent; - private static final CustomIcon Internal_Overlay_Machine_Vent_Fast = new CustomIcon("TileEntities/machine_top_vent_rotating_fast"); - public static final CustomIcon Overlay_Machine_Vent_Fast = Internal_Overlay_Machine_Vent_Fast; - private static final CustomIcon Internal_Overlay_Machine_Vent_Adv = new CustomIcon("TileEntities/adv_machine_vent_rotating"); - public static final CustomIcon Overlay_Machine_Vent_Adv = Internal_Overlay_Machine_Vent_Adv; - //Speaker Texture - private static final CustomIcon Internal_Overlay_Machine_Sound = new CustomIcon("TileEntities/audio_out"); - public static final CustomIcon Overlay_Machine_Sound = Internal_Overlay_Machine_Sound; - private static final CustomIcon Internal_Overlay_Machine_Sound_Active = new CustomIcon("TileEntities/audio_out_active"); - public static final CustomIcon Overlay_Machine_Sound_Active = Internal_Overlay_Machine_Sound_Active; - //Diesel Engines - private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical = new CustomIcon("TileEntities/machine_top_dieselmotor"); - public static final CustomIcon Overlay_Machine_Diesel_Vertical = Internal_Overlay_Machine_Diesel_Vertical; - private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal = new CustomIcon("TileEntities/machine_top_dieselmotor2"); - public static final CustomIcon Overlay_Machine_Diesel_Horizontal = Internal_Overlay_Machine_Diesel_Horizontal; - private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical_Active = new CustomIcon("TileEntities/machine_top_dieselmotor_active"); - public static final CustomIcon Overlay_Machine_Diesel_Vertical_Active = Internal_Overlay_Machine_Diesel_Vertical_Active; - private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal_Active = new CustomIcon("TileEntities/machine_top_dieselmotor2_active"); - public static final CustomIcon Overlay_Machine_Diesel_Horizontal_Active = Internal_Overlay_Machine_Diesel_Horizontal_Active; - //Computer Screens - private static final CustomIcon Internal_Casing_Machine_Screen_1 = new CustomIcon("TileEntities/adv_machine_screen_random1"); - public static final CustomIcon Casing_Machine_Screen_1 = Internal_Casing_Machine_Screen_1; - private static final CustomIcon Internal_Casing_Machine_Screen_2 = new CustomIcon("TileEntities/adv_machine_screen_random2"); - public static final CustomIcon Casing_Machine_Screen_2 = Internal_Casing_Machine_Screen_2; - private static final CustomIcon Internal_Casing_Machine_Screen_3 = new CustomIcon("TileEntities/adv_machine_screen_random3"); - public static final CustomIcon Casing_Machine_Screen_3 = Internal_Casing_Machine_Screen_3; - private static final CustomIcon Internal_Casing_Machine_Screen_Frequency = new CustomIcon("TileEntities/adv_machine_screen_frequency"); - public static final CustomIcon Casing_Machine_Screen_Frequency = Internal_Casing_Machine_Screen_Frequency; - private static final CustomIcon Internal_Overlay_Machine_Screen_Logo = new CustomIcon("TileEntities/adv_machine_screen_logo"); - public static final CustomIcon Overlay_Machine_Screen_Logo = Internal_Overlay_Machine_Screen_Logo; - //Crafting Overlays - private static final CustomIcon Internal_Overlay_Crafting_Bronze = new CustomIcon("TileEntities/bronze_top_crafting"); - public static final CustomIcon Overlay_Crafting_Bronze = Internal_Overlay_Crafting_Bronze; - private static final CustomIcon Internal_Overlay_Crafting_Steel = new CustomIcon("TileEntities/cover_crafting"); - public static final CustomIcon Overlay_Crafting_Steel = Internal_Overlay_Crafting_Steel; - //Dimensional - private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); - public static final CustomIcon Overlay_Machine_Dimensional_Blue = Internal_Overlay_Machine_Dimensional_Blue; - private static final CustomIcon Internal_Overlay_Machine_Dimensional_Orange = new CustomIcon("TileEntities/adv_machine_dimensional_cover_orange"); - public static final CustomIcon Overlay_Machine_Dimensional_Orange = Internal_Overlay_Machine_Dimensional_Orange; - //Icons - private static final CustomIcon Internal_Overlay_MatterFab = new CustomIcon("TileEntities/adv_machine_matterfab"); - public static final CustomIcon Overlay_MatterFab = Internal_Overlay_MatterFab; - private static final CustomIcon Internal_Overlay_MatterFab_Active = new CustomIcon("TileEntities/adv_machine_matterfab_active"); - public static final CustomIcon Overlay_MatterFab_Active = Internal_Overlay_MatterFab_Active; - private static final CustomIcon Internal_Overlay_Oil = new CustomIcon("TileEntities/adv_machine_oil"); - public static final CustomIcon Overlay_Oil = Internal_Overlay_Oil; - private static final CustomIcon Internal_Overlay_UU_Matter = new CustomIcon("TileEntities/adv_machine_uum"); - public static final CustomIcon Overlay_UU_Matter = Internal_Overlay_UU_Matter; - -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java index 42f5e67396..0338871482 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java @@ -13,7 +13,7 @@ import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; @@ -566,7 +566,7 @@ extends GT_MetaTileEntity_BasicTank @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide == aFacing ? new ITexture[]{ new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Dimensional), new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Screen_Frequency)} : new ITexture[]{new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Dimensional), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; + return aSide == aFacing ? new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency)} : new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java index 3a2260d086..aa8ddad326 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java @@ -11,7 +11,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -491,7 +491,7 @@ extends GT_MetaTileEntity_BasicTank @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide == aFacing ? new ITexture[]{new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Dimensional), new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Screen_Frequency)} : new ITexture[]{new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Dimensional), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; + return aSide == aFacing ? new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency)} : new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; } //To-Do? diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java index b68fb7155c..b45cf93bff 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java @@ -11,7 +11,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenera import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.registry.GameRegistry; @@ -82,7 +82,7 @@ extends GT_MetaTileEntity_BasicGenerator @Override public ITexture[] getBack(byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Diesel_Vertical)}; + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical)}; } @Override @@ -107,7 +107,7 @@ extends GT_MetaTileEntity_BasicGenerator @Override public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Diesel_Vertical_Active)}; + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical_Active)}; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index f3bff0c2f4..3cb641db0a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -11,7 +11,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.registry.GameRegistry; @@ -70,17 +70,17 @@ public class GregtechMetaTileEntityRocketFuelGenerator private GT_RenderedTexture getCasingTexture(){ if (this.mTier <= 4){ - return new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Top); + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); } else if (this.mTier == 5){ - return new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Advanced); + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); } else if (this.mTier >= 6){ - return new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Ultra); + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); } - return new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Top); + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); } @@ -91,22 +91,22 @@ public class GregtechMetaTileEntityRocketFuelGenerator @Override public ITexture[] getBack(byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Vent)}; + return new ITexture[]{super.getBack(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent)}; } @Override public ITexture[] getBottom(byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } @Override public ITexture[] getTop(byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_Off)}; + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; } @Override public ITexture[] getSides(byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Diesel_Horizontal)}; + return new ITexture[]{super.getSides(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal)}; } @Override @@ -116,21 +116,21 @@ public class GregtechMetaTileEntityRocketFuelGenerator @Override public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Vent_Fast)}; + return new ITexture[]{super.getBackActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast)}; } @Override public ITexture[] getBottomActive(byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Bottom)}; + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; } @Override public ITexture[] getTopActive(byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_On)}; + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; } @Override public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlocks.Overlay_Machine_Diesel_Horizontal_Active)}; + return new ITexture[]{super.getSidesActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active)}; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java index 61661b324b..bb7327857a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -112,12 +112,12 @@ public class GregtechMetaTileEntity_AlloyBlastSmelter } } FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 0) { - Utils.LOG_INFO("Found some Valid Inputs."); + if (tInputList.size() > 1) { long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); if ((tRecipe != null) && (this.mHeatingCapacity >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + Utils.LOG_WARNING("Found some Valid Inputs."); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; if (tRecipe.mEUt <= 16) { @@ -140,7 +140,7 @@ public class GregtechMetaTileEntity_AlloyBlastSmelter return true; } } - Utils.LOG_INFO("Failed to find some Valid Inputs."); + Utils.LOG_WARNING("Failed to find some Valid Inputs."); return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java index df3742c46e..8dccc8aed6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -17,7 +17,7 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import java.util.ArrayList; import java.util.List; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java index 4748fae57b..6c67d6c2af 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java @@ -14,6 +14,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import java.util.ArrayList; import java.util.Arrays; @@ -58,7 +59,7 @@ extends GregtechMeta_MultiBlockBase { @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_MatterFab_Active : TexturesGtBlock.Overlay_MatterFab)}; } return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64]}; } @@ -107,6 +108,7 @@ extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(ItemStack aStack) { + Utils.LOG_INFO("Starting Maceration Stack.1"); ArrayList tInputList = getStoredInputs(); for (int i = 0; i < tInputList.size() - 1; i++) { for (int j = i + 1; j < tInputList.size(); j++) { @@ -120,8 +122,27 @@ extends GregtechMeta_MultiBlockBase { } } } + Utils.LOG_INFO("Starting Maceration Stack.2"); ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - if (tInputList.size() > 0) { + + boolean mOutputHatch1, mOutputHatch2, mOutputHatch3, mOutputHatch4, mOutputHatch5 = false; + mOutputHatch1 = (this.mOutputBusses.get(0).mInventory.length<=this.mOutputBusses.get(0).getSizeInventory()) ? true : false; + mOutputHatch2 = (this.mOutputBusses.get(1).mInventory.length<=this.mOutputBusses.get(1).getSizeInventory()) ? true : false; + mOutputHatch3 = (this.mOutputBusses.get(2).mInventory.length<=this.mOutputBusses.get(2).getSizeInventory()) ? true : false; + mOutputHatch4 = (this.mOutputBusses.get(3).mInventory.length<=this.mOutputBusses.get(3).getSizeInventory()) ? true : false; + mOutputHatch5 = (this.mOutputBusses.get(4).mInventory.length<=this.mOutputBusses.get(4).getSizeInventory()) ? true : false; + + Utils.LOG_INFO("Starting Maceration Stack.4"); + int validHatches=0; + validHatches = mOutputHatch1 ? validHatches+1 : validHatches; + validHatches = mOutputHatch2 ? validHatches+1 : validHatches; + validHatches = mOutputHatch3 ? validHatches+1 : validHatches; + validHatches = mOutputHatch4 ? validHatches+1 : validHatches; + validHatches = mOutputHatch5 ? validHatches+1 : validHatches; + + Utils.LOG_INFO("Valid Output Hatches: "+validHatches); + + if (tInputList.size() > 0 && validHatches >= 1) { GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); @@ -129,7 +150,11 @@ extends GregtechMeta_MultiBlockBase { this.mEUt = (-tRecipe.mEUt); this.mMaxProgresstime = Math.max(1, (tRecipe.mDuration/5)); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + ItemStack[] outputs = new ItemStack[mOutputItems.length]; + for (int i = 0; i < mOutputItems.length; i++) + if (getBaseMetaTileEntity().getRandomNumber(7500) < tRecipe.getOutputChance(i)) + outputs[i] = tRecipe.getOutput(i); + this.mOutputItems = outputs; sendLoopStart((byte) 20); updateSlots(); return true; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java index dbb3d599a1..aa7aecc8c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java @@ -14,7 +14,7 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_IronBlastFurnace; import gtPlusPlus.xmod.gregtech.api.gui.GUI_IronBlastFurnace; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; @@ -25,9 +25,9 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_IronBlastFurnace extends MetaTileEntity { - private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Simple_Top)}; - private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_Off)}; - private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlocks.Casing_Machine_Redstone_On)}; + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; public int mMaxProgresstime = 0; public int mUpdate = 30; public int mProgresstime = 0; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java index f474effec5..13e80d1ca0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java @@ -18,7 +18,7 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import java.util.ArrayList; import java.util.Arrays; @@ -83,7 +83,7 @@ public class GregtechMetaTileEntity_MassFabricator extends GT_MetaTileEntity_Mul public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66], - new GT_RenderedTexture(aActive ? TexturesGtBlocks.Casing_Machine_Screen_3 : TexturesGtBlocks.Casing_Machine_Screen_1)}; + new GT_RenderedTexture(aActive ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1)}; } return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; } -- cgit From 4cc26594cd7d0d317db95b5174c96b1302e41eb9 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Fri, 28 Oct 2016 03:16:18 +1000 Subject: - Reverted Rocket Engines to single fuels. @leagris % Will re-use dual fluid generator code later. --- .../GregtechDoubleFuelGeneratorBase.java | 407 +++++++++++++ .../GregtechRocketFuelGeneratorBase.java | 630 ++++++++------------- ...gtechMetaTileEntityDoubleFuelGeneratorBase.java | 136 +++++ .../GregtechMetaTileEntityRocketFuelGenerator.java | 2 +- 4 files changed, 792 insertions(+), 383 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java new file mode 100644 index 0000000000..49f9fb1344 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java @@ -0,0 +1,407 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators; + +import static gregtech.api.enums.GT_Values.V; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; + +import java.util.Collection; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GregtechDoubleFuelGeneratorBase extends GT_MetaTileEntity_DeluxeTank { + + private boolean useFuel = false; + + public GregtechDoubleFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 4, aDescription, aTextures); + } + + public GregtechDoubleFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = getFront(i); + rTextures[1][i + 1] = getBack(i); + rTextures[2][i + 1] = getBottom(i); + rTextures[3][i + 1] = getTop(i); + rTextures[4][i + 1] = getSides(i); + rTextures[5][i + 1] = getFrontActive(i); + rTextures[6][i + 1] = getBackActive(i); + rTextures[7][i + 1] = getBottomActive(i); + rTextures[8][i + 1] = getTopActive(i); + rTextures[9][i + 1] = getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + @Override + public String[] getDescription() { + return new String[]{mDescription, "Fuel Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip}; + } + + + /* @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + }*/ + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + Utils.LOG_WARNING("Entity is Client side, simply returning true"); + return true; + } + Utils.LOG_WARNING("Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true"); + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBack(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTop(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSides(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(byte aColor) { + return getFront(aColor); + } + + public ITexture[] getBackActive(byte aColor) { + return getBack(aColor); + } + + public ITexture[] getBottomActive(byte aColor) { + return getBottom(aColor); + } + + public ITexture[] getTopActive(byte aColor) { + return getTop(aColor); + } + + public ITexture[] getSidesActive(byte aColor) { + return getSides(aColor); + } + + @Override + public boolean isFacingValid(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0; + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[mTier] * 115 + getMinimumStoredEU()); + } + + @Override + public boolean doesFillContainers() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean doesEmptyContainers() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeFilled() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeEmptied() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFuelValue(aFluid) > 0; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) { + if (mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { + mInventory[getStackDisplaySlot()] = null; + } else { + if (mInventory[getStackDisplaySlot()] == null) + mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + } + } else { + if (mFluid != null && mFluid2 != null){ + int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); + int tFuelValue2 = getFuelValue(mFluid2), tConsumed2 = consumedFluidPerOperation(mFluid2); + if ((tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed)/* && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)*/) { + + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName()); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName()); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); + long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + long tFluidAmountToUse2 = Math.min(mFluid2.amount / tConsumed2, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2); + + if (tFluidAmountToUse <= 0){ + /*if ((mFluid.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse = 1; + }*/ + + if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ + tFluidAmountToUse = 1; + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse - Updated: "+tFluidAmountToUse); + Utils.LOG_WARNING("========================================================="); + } + } + + if (tFluidAmountToUse2 <= 0){ + /*if ((mFluid2.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse2 = 1; + }*/ + if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ + tFluidAmountToUse2 = 1; + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse2 - Updated: "+tFluidAmountToUse2); + Utils.LOG_WARNING("========================================================="); + } + } + + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse: "+tFluidAmountToUse); + Utils.LOG_WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid.amount / tConsumed: "+("fluidAmount:"+mFluid.amount)+(" tConsumed:"+tConsumed)+" | "+(mFluid.amount / tConsumed)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue: "+(tFuelValue)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue)); + */ + + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); + Utils.LOG_WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "+("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"+tConsumed2)+" | "+(mFluid2.amount / tConsumed2)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2)); + */ + if ((tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) && (tFluidAmountToUse2 > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse2 * tFuelValue2, true))){ + + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName()); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName()); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); + + if (useFuel){ + mFluid.amount -= tFluidAmountToUse * tConsumed; + mFluid2.amount -= tFluidAmountToUse2 * tConsumed2; + useFuel = false; + } + else { + useFuel = true; + } + + } + else { + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0"); + Utils.LOG_WARNING("tFluidAmountToUse1: "+tFluidAmountToUse); + Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); + } + } + else { + /*Utils.LOG_WARNING("(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)"); + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); */ + } + } + else { + Utils.LOG_WARNING("One mFluid is null"); + if (mFluid != null) + Utils.LOG_WARNING("mFluid1 is not null"); + if (mFluid2 != null) + Utils.LOG_WARNING("mFluid2 is not null"); + } + } + if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { + int tFuelValue = getFuelValue(mInventory[getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); + } + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null || getRecipes() == null) return 0; + FluidStack tLiquid; + Collection tRecipeList = getRecipes().mRecipeList; + if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) + if (aLiquid.isFluidEqual(tLiquid)) + return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); + return 0; + } + + public int getFuelValue(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); + return 0; + } + + public ItemStack getEmptyContainer(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); + return GT_Utility.getContainerItem(aStack, true); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return -100; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java index 7d0e43c5e2..ce4042148e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -4,12 +4,11 @@ import static gregtech.api.enums.GT_Values.V; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; import java.util.Collection; @@ -18,390 +17,257 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_DeluxeTank { - +public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank { + private boolean useFuel = false; + + public GregtechRocketFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + } + + public GregtechRocketFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = getFront(i); + rTextures[1][i + 1] = getBack(i); + rTextures[2][i + 1] = getBottom(i); + rTextures[3][i + 1] = getTop(i); + rTextures[4][i + 1] = getSides(i); + rTextures[5][i + 1] = getFrontActive(i); + rTextures[6][i + 1] = getBackActive(i); + rTextures[7][i + 1] = getBottomActive(i); + rTextures[8][i + 1] = getTopActive(i); + rTextures[9][i + 1] = getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + @Override + public String[] getDescription() { + return new String[]{mDescription, "Fuel Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip}; + } + - public GregtechRocketFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 4, aDescription, aTextures); - } - - public GregtechRocketFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 4, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = getFront(i); - rTextures[1][i + 1] = getBack(i); - rTextures[2][i + 1] = getBottom(i); - rTextures[3][i + 1] = getTop(i); - rTextures[4][i + 1] = getSides(i); - rTextures[5][i + 1] = getFrontActive(i); - rTextures[6][i + 1] = getBackActive(i); - rTextures[7][i + 1] = getBottomActive(i); - rTextures[8][i + 1] = getTopActive(i); - rTextures[9][i + 1] = getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - @Override - public String[] getDescription() { - return new String[]{mDescription, "Fuel Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip}; - } - - - /* @Override + @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; aBaseMetaTileEntity.openGUI(aPlayer); return true; - }*/ - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()){ - Utils.LOG_WARNING("Entity is Client side, simply returning true"); - return true; - } - Utils.LOG_WARNING("Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true"); - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - public ITexture[] getFront(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBack(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottom(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTop(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getSides(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getFrontActive(byte aColor) { - return getFront(aColor); - } - - public ITexture[] getBackActive(byte aColor) { - return getBack(aColor); - } - - public ITexture[] getBottomActive(byte aColor) { - return getBottom(aColor); - } - - public ITexture[] getTopActive(byte aColor) { - return getTop(aColor); - } - - public ITexture[] getSidesActive(byte aColor) { - return getSides(aColor); - } - - @Override - public boolean isFacingValid(byte aSide) { - return aSide > 1; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex < 2; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public long maxEUOutput() { - return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0; - } - - @Override - public long maxEUStore() { - return Math.max(getEUVar(), V[mTier] * 115 + getMinimumStoredEU()); - } - - @Override - public boolean doesFillContainers() { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean doesEmptyContainers() { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean canTankBeFilled() { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean canTankBeEmptied() { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return getFuelValue(aFluid) > 0; - } - - @Override - public long getMinimumStoredEU() { - return 512; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) { - if (mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { - mInventory[getStackDisplaySlot()] = null; - } else { - if (mInventory[getStackDisplaySlot()] == null) - mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); - } - } else { - if (mFluid != null && mFluid2 != null){ - int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); - int tFuelValue2 = getFuelValue(mFluid2), tConsumed2 = consumedFluidPerOperation(mFluid2); - if ((tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed)/* && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)*/) { - - Utils.LOG_WARNING("tFuelValue: "+tFuelValue); - Utils.LOG_WARNING("tConsumed: "+tConsumed); - Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName()); - Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); - Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); - - Utils.LOG_WARNING("========================================================="); - - Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); - Utils.LOG_WARNING("tConsumed2: "+tConsumed2); - Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName()); - Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); - Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); - long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - long tFluidAmountToUse2 = Math.min(mFluid2.amount / tConsumed2, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2); - - if (tFluidAmountToUse <= 0){ - /*if ((mFluid.amount / tConsumed) == getCapacity()){ - tFluidAmountToUse = 1; - }*/ - - if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ - tFluidAmountToUse = 1; - Utils.LOG_WARNING("========================================================="); - Utils.LOG_WARNING("tFluidAmountToUse - Updated: "+tFluidAmountToUse); - Utils.LOG_WARNING("========================================================="); - } - } - - if (tFluidAmountToUse2 <= 0){ - /*if ((mFluid2.amount / tConsumed) == getCapacity()){ - tFluidAmountToUse2 = 1; - }*/ - if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ - tFluidAmountToUse2 = 1; - Utils.LOG_WARNING("========================================================="); - Utils.LOG_WARNING("tFluidAmountToUse2 - Updated: "+tFluidAmountToUse2); - Utils.LOG_WARNING("========================================================="); - } - } - - Utils.LOG_WARNING("========================================================="); - Utils.LOG_WARNING("tFluidAmountToUse: "+tFluidAmountToUse); - Utils.LOG_WARNING("========================================================="); - - /*Utils.LOG_WARNING("mFluid.amount / tConsumed: "+("fluidAmount:"+mFluid.amount)+(" tConsumed:"+tConsumed)+" | "+(mFluid.amount / tConsumed)); - Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); - Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); - Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); - Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); - Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); - Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); - Utils.LOG_WARNING("tFuelValue: "+(tFuelValue)); - Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue)); - */ - - Utils.LOG_WARNING("========================================================="); - Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); - Utils.LOG_WARNING("========================================================="); - - /*Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "+("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"+tConsumed2)+" | "+(mFluid2.amount / tConsumed2)); - Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); - Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); - Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); - Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); - Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); - Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); - Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2)); - Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2)); - */ - if ((tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) && (tFluidAmountToUse2 > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse2 * tFuelValue2, true))){ - - Utils.LOG_WARNING("tFuelValue: "+tFuelValue); - Utils.LOG_WARNING("tConsumed: "+tConsumed); - Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName()); - Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); - Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); - - Utils.LOG_WARNING("========================================================="); - - Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); - Utils.LOG_WARNING("tConsumed2: "+tConsumed2); - Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName()); - Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); - Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); - - if (useFuel){ - mFluid.amount -= tFluidAmountToUse * tConsumed; - mFluid2.amount -= tFluidAmountToUse2 * tConsumed2; - useFuel = false; - } - else { - useFuel = true; - } - - } - else { - Utils.LOG_WARNING("========================================================="); - Utils.LOG_WARNING("Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0"); - Utils.LOG_WARNING("tFluidAmountToUse1: "+tFluidAmountToUse); - Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); - } - } - else { - /*Utils.LOG_WARNING("(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)"); - Utils.LOG_WARNING("tFuelValue: "+tFuelValue); - Utils.LOG_WARNING("tConsumed: "+tConsumed); - Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); - Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); - - Utils.LOG_WARNING("========================================================="); - - Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); - Utils.LOG_WARNING("tConsumed2: "+tConsumed2); - Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); - Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); */ - } - } - else { - Utils.LOG_WARNING("One mFluid is null"); - if (mFluid != null) - Utils.LOG_WARNING("mFluid1 is not null"); - if (mFluid2 != null) - Utils.LOG_WARNING("mFluid2 is not null"); - } - } - if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { - int tFuelValue = getFuelValue(mInventory[getInputSlot()]); - if (tFuelValue > 0) { - ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } - } - - if (aBaseMetaTileEntity.isServerSide()) - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); - } - - public abstract GT_Recipe_Map getRecipes(); - - public abstract int getEfficiency(); - - public int consumedFluidPerOperation(FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid == null || getRecipes() == null) return 0; - FluidStack tLiquid; - Collection tRecipeList = getRecipes().mRecipeList; - if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) - if (aLiquid.isFluidEqual(tLiquid)) - return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); - return 0; - } - - public int getFuelValue(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; - GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); - return 0; - } - - public ItemStack getEmptyContainer(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; - GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); - return GT_Utility.getContainerItem(aStack, true); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); - } - - @Override - public int getCapacity() { - return 32000; - } - - @Override - public int getTankPressure() { - return -100; - } + } + + public ITexture[] getFront(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBack(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTop(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSides(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(byte aColor) { + return getFront(aColor); + } + + public ITexture[] getBackActive(byte aColor) { + return getBack(aColor); + } + + public ITexture[] getBottomActive(byte aColor) { + return getBottom(aColor); + } + + public ITexture[] getTopActive(byte aColor) { + return getTop(aColor); + } + + public ITexture[] getSidesActive(byte aColor) { + return getSides(aColor); + } + + @Override + public boolean isFacingValid(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0; + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[mTier] * 80 + getMinimumStoredEU()); + } + + @Override + public boolean doesFillContainers() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean doesEmptyContainers() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeFilled() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeEmptied() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFuelValue(aFluid) > 0; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) { + if (mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { + mInventory[getStackDisplaySlot()] = null; + } else { + if (mInventory[getStackDisplaySlot()] == null) + mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + } + } else { + int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); + if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) { + long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ + if (useFuel){ + mFluid.amount -= tFluidAmountToUse * tConsumed; + useFuel = false; + } + else { + useFuel = true; + } + } + } + } + if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { + int tFuelValue = getFuelValue(mInventory[getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); + } + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null || getRecipes() == null) return 0; + FluidStack tLiquid; + Collection tRecipeList = getRecipes().mRecipeList; + if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) + if (aLiquid.isFluidEqual(tLiquid)) + return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); + return 0; + } + + public int getFuelValue(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); + return 0; + } + + public ItemStack getEmptyContainer(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); + return GT_Utility.getContainerItem(aStack, true); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return -100; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java new file mode 100644 index 0000000000..65a2892710 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java @@ -0,0 +1,136 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +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_Recipe; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; + +public class GregtechMetaTileEntityDoubleFuelGeneratorBase + extends GregtechRocketFuelGeneratorBase { + + public int mEfficiency; + + public GregtechMetaTileEntityDoubleFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires two liquid Fuels. Fuel A is Fastburn, Fuel B is slowburn.", new ITexture[0]); + onConfigLoad(); + } + + public GregtechMetaTileEntityDoubleFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityDoubleFuelGeneratorBase(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + + @Override + public int getCapacity() { + return 32000; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, (100 - this.mTier * 8)); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(ItemStack aStack) { + int rValue = Math.max(GT_ModHandler.getFuelCanValue(aStack) * 6 / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + private GT_RenderedTexture getCasingTexture(){ + if (this.mTier <= 4){ + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + else if (this.mTier == 5){ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + else if (this.mTier >= 6){ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent)}; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal)}; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast)}; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active)}; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index 3cb641db0a..59e4a1b875 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -21,7 +21,7 @@ public class GregtechMetaTileEntityRocketFuelGenerator public int mEfficiency; public GregtechMetaTileEntityRocketFuelGenerator(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires two liquid Fuels. Fuel A is Fastburn, Fuel B is slowburn.", new ITexture[0]); + super(aID, aName, aNameRegional, aTier, "Requires liquid Fuels.", new ITexture[0]); onConfigLoad(); } -- cgit From 10974e7952ad9853c63bcbbb5a83952f97b2bbb1 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sat, 29 Oct 2016 18:49:50 +1000 Subject: $ Fixed output overflow on most multi-blocks. --- .../base/GregtechMeta_MultiBlockBase.java | 43 +++++++++++++ ...regtechMetaTileEntityIndustrial_PlatePress.java | 21 +++---- .../GregtechMetaTileEntity_IndustrialCokeOven.java | 8 ++- ...gtechMetaTileEntity_IndustrialElectrolyzer.java | 22 +++---- ...GregtechMetaTileEntity_IndustrialMacerator.java | 73 +--------------------- .../GregtechMetaTileEntity_IndustrialWireMill.java | 21 +++---- .../GregtechMetaTileEntity_MassFabricator.java | 14 +---- 7 files changed, 80 insertions(+), 122 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 59f98b8767..a6121f783d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -22,9 +22,11 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -824,5 +826,46 @@ public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity { // } + public int getValidOutputSlots(GT_Recipe.GT_Recipe_Map sRecipeMap, ItemStack[] sInputs){ + ArrayList tInputList = getStoredInputs(); + GT_Recipe tRecipe = sRecipeMap.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, sInputs); + ArrayList> rList = new ArrayList>(); + int tTotalHatches=0; + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { + int hatchUsedSlotCount = 0; + if (isValidMetaTileEntity(tHatch)) { + tTotalHatches++; + for (int i=0; i(tHatch, hatchUsedSlotCount)); + } + } + boolean[] mValidOutputSlots = new boolean[tTotalHatches]; + int arrayPos=0; + for (Pair IE : rList) { + GT_MetaTileEntity_Hatch_OutputBus vTE = IE.getKey(); + int vUsedSlots = IE.getValue(); + if (vUsedSlots == 0){mValidOutputSlots[arrayPos] = true;} + else if (vUsedSlots < vTE.getSizeInventory()){ + int outputItemCount = tRecipe.mOutputs.length; + if (vUsedSlots < vTE.getSizeInventory()-outputItemCount){mValidOutputSlots[arrayPos] = true;} + else if (vUsedSlots >= vTE.getSizeInventory()-outputItemCount){ + if (vUsedSlots > vTE.getSizeInventory()-outputItemCount){if (arrayPos == tTotalHatches){return 0;} /*Change to Hatch total*/ } + } + } + //Hatch is full + if (vUsedSlots == vTE.getSizeInventory()){ + mValidOutputSlots[arrayPos] = false; + if (arrayPos == tTotalHatches){return 0;} // Change to Hatch Total + } + arrayPos++; + } + int tValidOutputSlots = 0; + for (int cr=0;cr= 1) {return tValidOutputSlots;} + return 0; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrial_PlatePress.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrial_PlatePress.java index b0828776ed..d576d159ed 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrial_PlatePress.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrial_PlatePress.java @@ -6,13 +6,14 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import java.util.ArrayList; import java.util.Arrays; @@ -24,7 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntityIndustrial_PlatePress -extends GT_MetaTileEntity_MultiBlockBase { +extends GregtechMeta_MultiBlockBase { public GregtechMetaTileEntityIndustrial_PlatePress(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -70,11 +71,6 @@ extends GT_MetaTileEntity_MultiBlockBase { return GT_Recipe.GT_Recipe_Map.sBenderRecipes; } - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - @Override public boolean isFacingValid(byte aFacing) { return aFacing > 1; @@ -111,7 +107,11 @@ extends GT_MetaTileEntity_MultiBlockBase { } } FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 0) { + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBenderRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); @@ -187,11 +187,6 @@ extends GT_MetaTileEntity_MultiBlockBase { return 0; } - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - @Override public int getAmountOfOutputs() { return 1; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java index a19aaf26b1..c2e2df7a8f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -11,6 +11,7 @@ import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; @@ -115,7 +116,12 @@ public class GregtechMetaTileEntity_IndustrialCokeOven } } FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 0) { + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java index 9b16e0cee9..1680006afd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java @@ -6,13 +6,14 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import java.util.ArrayList; import java.util.Arrays; @@ -27,7 +28,7 @@ import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; public class GregtechMetaTileEntity_IndustrialElectrolyzer -extends GT_MetaTileEntity_MultiBlockBase { +extends GregtechMeta_MultiBlockBase { public GregtechMetaTileEntity_IndustrialElectrolyzer(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -75,11 +76,6 @@ extends GT_MetaTileEntity_MultiBlockBase { return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; } - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - @Override public boolean isFacingValid(byte aFacing) { return aFacing > 1; @@ -119,7 +115,12 @@ extends GT_MetaTileEntity_MultiBlockBase { } } FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 0) { + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); @@ -241,11 +242,6 @@ extends GT_MetaTileEntity_MultiBlockBase { return 0; } - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - @Override public int getAmountOfOutputs() { return 1; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java index c80c416120..68b2f647ee 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java @@ -12,7 +12,6 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -136,80 +135,12 @@ extends GregtechMeta_MultiBlockBase { //Make a recipe instance for the rest of the method. GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); - //Count free slots in output hatches - return if the 4/5 hatch is full - ArrayList> rList = new ArrayList>(); - for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { - int hatchUsedSlotCount = 0; - if (isValidMetaTileEntity(tHatch)) { - //Loop slots in this hatch - for (int i=0; i(tHatch, hatchUsedSlotCount)); - } - } - - //Temp Vars. - boolean[] mValidOutputSlots = new boolean[5]; - int arrayPos=0; - - for (Pair IE : rList) { - //Temp Vars. - GT_MetaTileEntity_Hatch_OutputBus vTE = IE.getKey(); - int vUsedSlots = IE.getValue(); - //Hatch is empty - if (vUsedSlots == 0){ - mValidOutputSlots[arrayPos] = true; - } - //Hatch contains at least one item - else if (vUsedSlots < vTE.getSizeInventory()){ - //Temp variable for counting amount of output items - int outputItemCount = tRecipe.mOutputs.length; - //Hatch has more slots free than output count - if (vUsedSlots < vTE.getSizeInventory()-outputItemCount){ - mValidOutputSlots[arrayPos] = true; - } - //Hatch has output count free - else if (vUsedSlots >= vTE.getSizeInventory()-outputItemCount){ - //Not enough output slots - if (vUsedSlots > vTE.getSizeInventory()-outputItemCount){ - if (arrayPos == 4){ - Utils.LOG_INFO("Not Enough Output slots in top hatch"); - return false; - } - } - } - } - - //Hatch is full - if (vUsedSlots == vTE.getSizeInventory()){ - Utils.LOG_INFO("Not Enough Output slots in hatch - "+arrayPos+" - [0-4] - 0 = Bottom | 4 = Top"); - mValidOutputSlots[arrayPos] = false; - if (arrayPos == 4){ - Utils.LOG_INFO("Not Enough Output slots in top hatch"); - return false; - } - } - //Count up a position in the boolean array. - arrayPos++; - } - int tValidOutputSlots = 0; - for (int cr=0;cr 0 && tValidOutputSlots > 1) { + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { Utils.LOG_WARNING("Valid Recipe found - size "+tRecipe.mOutputs.length); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java index 27d70992cf..ca300ba277 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java @@ -6,7 +6,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -14,6 +13,7 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import java.util.ArrayList; @@ -22,7 +22,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; public class GregtechMetaTileEntity_IndustrialWireMill -extends GT_MetaTileEntity_MultiBlockBase { +extends GregtechMeta_MultiBlockBase { public GregtechMetaTileEntity_IndustrialWireMill(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -68,11 +68,6 @@ extends GT_MetaTileEntity_MultiBlockBase { return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; } - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - @Override public boolean isFacingValid(byte aFacing) { return aFacing > 1; @@ -87,6 +82,12 @@ extends GT_MetaTileEntity_MultiBlockBase { GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); if (tRecipe != null) { + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), new ItemStack[]{tInput}); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; @@ -109,6 +110,7 @@ extends GT_MetaTileEntity_MultiBlockBase { updateSlots(); return true; } + } } } return false; @@ -207,11 +209,6 @@ extends GT_MetaTileEntity_MultiBlockBase { return 0; } - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - @Override public int getAmountOfOutputs() { return 1; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java index 13e80d1ca0..7f8db893c0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java @@ -6,7 +6,6 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Recipe; @@ -18,6 +17,7 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import java.util.ArrayList; @@ -31,7 +31,7 @@ import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; -public class GregtechMetaTileEntity_MassFabricator extends GT_MetaTileEntity_MultiBlockBase { +public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlockBase { public static int sUUAperUUM = 1; public static int sUUASpeedBonus = 4; @@ -315,11 +315,6 @@ public class GregtechMetaTileEntity_MassFabricator extends GT_MetaTileEntity_Mul return true; } - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - @Override public int getMaxEfficiency(ItemStack aStack) { return 10000; @@ -330,11 +325,6 @@ public class GregtechMetaTileEntity_MassFabricator extends GT_MetaTileEntity_Mul return 0; } - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - @Override public int getAmountOfOutputs() { return 1; -- cgit