From 279e29333ea4b06bb6be052fc3ffde792aaa4b0e Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 22 Dec 2021 05:11:18 +0000 Subject: Re-added XL Turbines. Added Xl Gas/Plasma Turbines. --- .../GT_MetaTileEntity_Hatch_Turbine.java | 36 ++++++++++++++-------- .../base/GregtechMeta_MultiBlockBase.java | 2 +- 2 files changed, 24 insertions(+), 14 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java index a9cd179214..3ece45cf78 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java @@ -1,11 +1,9 @@ -/* package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import gregtech.api.GregTech_API; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; @@ -21,10 +19,10 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.turbine.LargeTurbineTextu import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.GregtechMetaTileEntity_LargerTurbineBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +@SuppressWarnings("deprecation") public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { public boolean mHasController = false; @@ -72,6 +70,22 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { public boolean isValidSlot(int aIndex) { return false; } + + public boolean hasTurbine() { + return GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(this.mInventory[0]); + } + + public boolean canWork() { + return hasTurbine(); + } + + public boolean insertTurbine(ItemStack aTurbine) { + if (GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(aTurbine)) { + this.mInventory[0] = aTurbine; + return true; + } + return false; + } @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -89,6 +103,7 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Controller Active? "+this.isControllerActive()); } PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Is Active? "+this.getBaseMetaTileEntity().isActive()); + PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Has Turbine inserted? "+this.hasTurbine()); return true; } @@ -180,10 +195,10 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { public boolean isControllerActive() { GregtechMetaTileEntity_LargerTurbineBase x = getController(); if (x != null) { - Logger.INFO("Checking Status of Controller."); + //Logger.INFO("Checking Status of Controller."); return x.isMachineRunning(); } - Logger.INFO("Status of Controller failed, controller is null."); + //Logger.INFO("Status of Controller failed, controller is null."); return false; } @@ -239,7 +254,7 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { private ITexture getFrontFacingTurbineTexture() { if (!mHasController) { - return this.getBaseMetaTileEntity().isActive() ? new GT_RenderedTexture(LargeTurbineTextureHandler.frontFaceHPActive_4) : new GT_RenderedTexture(LargeTurbineTextureHandler.frontFace_4 ); + return this.getBaseMetaTileEntity().isActive() ? new GT_RenderedTexture(LargeTurbineTextureHandler.OVERLAY_LP_TURBINE_ACTIVE[4] ) : new GT_RenderedTexture(LargeTurbineTextureHandler.OVERLAY_LP_TURBINE[4] ); } else { if (usingAnimations()) { @@ -272,8 +287,7 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { // TODO Auto-generated method stub return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); } @@ -309,8 +323,4 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { this.getBaseMetaTileEntity().setActive(b); } - - - - -}*/ +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 356f96f7cc..825a55632d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1452,7 +1452,7 @@ public abstract class GregtechMeta_MultiBlockBase Date: Wed, 22 Dec 2021 21:20:31 +0000 Subject: Finished work on XL turbines. Cleaned up scanner output for all multiblocks. Update Sifter tooltip to reflect 4 output bus requirement. --- .../api/gui/hatches/CONTAINER_1by1_Turbine.java | 15 +- .../GT_MetaTileEntity_Hatch_Turbine.java | 204 +++++-- .../base/GregtechMeta_MultiBlockBase.java | 155 +++-- .../turbine/LargeTurbineTextureHandler.java | 2 +- .../GregtechMetaTileEntity_IndustrialSifter.java | 2 +- .../turbines/GT_MTE_LargeTurbine_Gas.java | 47 +- .../turbines/GT_MTE_LargeTurbine_Plasma.java | 22 +- .../turbines/GT_MTE_LargeTurbine_SHSteam.java | 16 +- .../turbines/GT_MTE_LargeTurbine_Steam.java | 20 +- .../GregtechMetaTileEntity_LargerTurbineBase.java | 635 +++++++++++++++------ src/main/resources/assets/gregtech/lang/en_US.lang | 1 + 11 files changed, 765 insertions(+), 354 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java index e6203823b6..606880d6e9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches; import gregtech.api.gui.GT_Container_1by1; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.GregtechMetaTileEntity_LargerTurbineBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; @@ -36,12 +37,7 @@ public class CONTAINER_1by1_Turbine extends GT_Container_1by1 { } @Override public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { - if (itemstack.getItemDamage() >= 170 && itemstack.getItemDamage() <= 176) { - return true; - } - } - return false; + return GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(itemstack); } @Override public int getSlotStackLimit() { @@ -52,9 +48,10 @@ public class CONTAINER_1by1_Turbine extends GT_Container_1by1 { return false; } @Override - public void putStack(ItemStack p_75215_1_) { - // TODO Auto-generated method stub - super.putStack(p_75215_1_); + public void putStack(ItemStack aStack) { + if (isItemValid(aStack)) { + this.inventory.setInventorySlotContents(0, aStack); + } } } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java index 3ece45cf78..a4040c1c5e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java @@ -1,16 +1,21 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_1by1_Turbine; import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_1by1_Turbine; @@ -28,6 +33,7 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { public boolean mHasController = false; public boolean mUsingAnimation = true; private String mControllerLocation; + public int mEUt = 0; public GT_MetaTileEntity_Hatch_Turbine(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 16, "Turbine Rotor holder for XL Turbines"); @@ -40,6 +46,18 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Turbine(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 1, aDescription[0], aTextures); } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + "Right Click with a soldering iron to reset controller link", + "Right Click with a wrench to remove turbine", + "Right Click with a screwdriver for technical information", + "Sneak + Right Click with a wrench to rotate", + "Sneak + Right Click with a screwdriver to disable animations", + CORE.GT_Tooltip}; + } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { @@ -51,6 +69,14 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { return new ITexture[]{aBaseTexture, getFrontFacingTurbineTexture()}; } + public int getEU() { + return this.mEUt; + } + + public void setEU(int aEU) { + this.mEUt = aEU; + } + @Override public boolean isSimpleMachine() { return true; @@ -70,15 +96,24 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { public boolean isValidSlot(int aIndex) { return false; } - + public boolean hasTurbine() { - return GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(this.mInventory[0]); + ItemStack aStack = this.mInventory[0]; + boolean aIsValid = GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(aStack); + return aIsValid; } - + + public ItemStack getTurbine() { + if (hasTurbine()) { + return this.mInventory[0]; + } + return null; + } + public boolean canWork() { return hasTurbine(); } - + public boolean insertTurbine(ItemStack aTurbine) { if (GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(aTurbine)) { this.mInventory[0] = aTurbine; @@ -94,33 +129,23 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - //aBaseMetaTileEntity.openGUI(aPlayer); - PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Using Animations? "+usingAnimations()); - PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Has Controller? "+this.mHasController); - if (mHasController) { - PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Controller Location: "+BlockPos.generateBlockPos(mControllerLocation).getLocationString()); - PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Controller Active? "+this.isControllerActive()); + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + else { + aBaseMetaTileEntity.openGUI(aPlayer); } - PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Is Active? "+this.getBaseMetaTileEntity().isActive()); - PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Has Turbine inserted? "+this.hasTurbine()); return true; } @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - default: - return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); - } + return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - default: - return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Rotor Hatch"); - } + return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Rotor Hatch"); } @Override @@ -137,6 +162,20 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { public int getInventoryStackLimit() { return 1; } + + public void damageTurbine(int aEUt, int damageFactorLow, float damageFactorHigh) { + if (hasTurbine() && MathUtils.randInt(0, 1) == 0) { + ItemStack aTurbine = getTurbine(); + ((GT_MetaGenerated_Tool) aTurbine.getItem()).doDamage(aTurbine, (long)getDamageToComponent(aTurbine) * (long) Math.min(aEUt / damageFactorLow, Math.pow(aEUt, damageFactorHigh))); + if (aTurbine.stackSize == 0) { + aTurbine = null; + } + } + } + + private final int getDamageToComponent(ItemStack aStack) { + return 1; + } @Override public void saveNBTData(NBTTagCompound aNBT) { @@ -152,22 +191,6 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { mUsingAnimation = aNBT.getBoolean("mUsingAnimation"); } - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - this.mUsingAnimation = Utils.invertBoolean(mUsingAnimation); - if (this.mUsingAnimation) { - PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture."); - } - PlayerUtils.messagePlayer(aPlayer, "Has Controller: "+this.mHasController); - if (mHasController) { - PlayerUtils.messagePlayer(aPlayer, "Controller Location: "+this.mControllerLocation); - } - } - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); @@ -195,8 +218,8 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { public boolean isControllerActive() { GregtechMetaTileEntity_LargerTurbineBase x = getController(); if (x != null) { - //Logger.INFO("Checking Status of Controller."); - return x.isMachineRunning(); + //Logger.INFO("Checking Status of Controller. Running? "+(x.mEUt > 0)); + return x.mEUt > 0; } //Logger.INFO("Status of Controller failed, controller is null."); return false; @@ -286,41 +309,98 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { return false; } + public void setActive(boolean b) { + this.getBaseMetaTileEntity().setActive(b); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return false; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) { + PlayerUtils.messagePlayer(aPlayer, "Using Animations? "+usingAnimations()); + PlayerUtils.messagePlayer(aPlayer, "Has Controller? "+this.mHasController); + if (mHasController) { + PlayerUtils.messagePlayer(aPlayer, "Controller Location: "+BlockPos.generateBlockPos(mControllerLocation).getLocationString()); + PlayerUtils.messagePlayer(aPlayer, "Controller Active? "+this.isControllerActive()); + } + PlayerUtils.messagePlayer(aPlayer, "Active? "+this.getBaseMetaTileEntity().isActive()); + PlayerUtils.messagePlayer(aPlayer, "Has Turbine inserted? "+this.hasTurbine()); + if (this.hasTurbine()) { + Materials aMat = GT_MetaGenerated_Tool.getPrimaryMaterial(getTurbine()); + String aSize = GregtechMetaTileEntity_LargerTurbineBase.getTurbineSizeString(GregtechMetaTileEntity_LargerTurbineBase.getTurbineSize(getTurbine())); + PlayerUtils.messagePlayer(aPlayer, "Using: "+aMat.mLocalizedName+" "+aSize); + } + } + else { + this.mUsingAnimation = Utils.invertBoolean(mUsingAnimation); + if (this.mUsingAnimation) { + PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture."); + } + } + } + @Override public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - // TODO Auto-generated method stub + if (this.getBaseMetaTileEntity().isServerSide() && !aPlayer.isSneaking()) { + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null) { + if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { + return onToolClick(tCurrentItem, aPlayer, aWrenchingSide); + } + } + } return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { - //Do Super - boolean aSuper = super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); - // Do Things + public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (this.getBaseMetaTileEntity().isServerSide()) { ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null) { - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) { - if (mControllerLocation != null && mControllerLocation.length() > 0) { - if (setController(BlockPos.generateBlockPos(mControllerLocation))) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - String tChat = "Trying to Reset linked Controller"; - IGregTechTileEntity g = this.getBaseMetaTileEntity(); - GT_Utility.sendChatToPlayer(aPlayer, tChat); - GT_Utility.sendSoundToPlayers(g.getWorld(), GregTech_API.sSoundList.get(101), 1.0F, -1, - g.getXCoord(), g.getYCoord(), g.getZCoord()); - } - } + if (tCurrentItem != null) { + if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { + return onToolClick(tCurrentItem, aPlayer, aWrenchingSide); + } + } + } + return false; + } + + public boolean onToolClick(ItemStack tCurrentItem, EntityPlayer aPlayer, byte aSide) { + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { + boolean aHasTurbine = this.hasTurbine(); + if (aPlayer.inventory.getFirstEmptyStack() >= 0 && aHasTurbine) { + if (PlayerUtils.isCreative(aPlayer) || GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + aPlayer.inventory.addItemStackToInventory((this.getTurbine())); + this.mInventory[0] = null; + GT_Utility.sendChatToPlayer(aPlayer, "Removed turbine with wrench."); + return true; + } + } + else { + GT_Utility.sendChatToPlayer(aPlayer, aHasTurbine ? "Cannot remove turbine, no free inventory space." : "No turbine to remove."); + } + } + else if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { + if (mControllerLocation != null && mControllerLocation.length() > 0) { + if (setController(BlockPos.generateBlockPos(mControllerLocation))) { + if (PlayerUtils.isCreative(aPlayer) || GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + String tChat = "Trying to Reset linked Controller"; + IGregTechTileEntity g = this.getBaseMetaTileEntity(); + GT_Utility.sendChatToPlayer(aPlayer, tChat); + GT_Utility.sendSoundToPlayers(g.getWorld(), GregTech_API.sSoundList.get(101), 1.0F, -1, g.getXCoord(), g.getYCoord(), g.getZCoord()); + return true; } } } } - return aSuper; + return false; } - public void setActive(boolean b) { - this.getBaseMetaTileEntity().setActive(b); - } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 825a55632d..42fdc246b4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -191,81 +191,100 @@ public abstract class GregtechMeta_MultiBlockBase mInfo = new ArrayList(); - if (!this.getMetaName().equals("")) { - mInfo.add(this.getMetaName()); - } - - String[] extra = getExtraInfoData(); - - if (extra == null) { - extra = new String[0]; - } - if (extra.length > 0) { - for (String s : extra) { - mInfo.add(s); + try { + if (!this.getMetaName().equals("")) { + mInfo.add(this.getMetaName()); } - } - - long seconds = (this.mTotalRunTime/20); - int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); - int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); - long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); - long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); - long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); - - int mPollutionReduction = getPollutionReductionForAllMufflers(); - long storedEnergy = getStoredEnergyInAllEnergyHatches(); - long maxEnergy = getMaxEnergyStorageOfAllEnergyHatches(); - int tTier = this.getControlCoreTier(); - mInfo.add(getMachineTooltip()); + String[] extra = getExtraInfoData(); + if (extra == null) { + extra = new String[0]; + } + if (extra.length > 0) { + for (String s : extra) { + mInfo.add(s); + } + } - //Lets borrow the GTNH handling - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ - EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ - EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s"); + long seconds = (this.mTotalRunTime/20); + int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); + int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); + long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); + long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+": "+ - EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU"); + mInfo.add(getMachineTooltip()); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+": "+ - EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t"); + //Lets borrow the GTNH handling - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+": "+ - EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET+ " EU/t(*2A) "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ - EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(getMaxInputVoltage())]+ EnumChatFormatting.RESET); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ + EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ + EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s"); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.problems")+": "+ - EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ - " "+StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ - EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); + if (!this.mAllEnergyHatches.isEmpty()) { + long storedEnergy = getStoredEnergyInAllEnergyHatches(); + long maxEnergy = getMaxEnergyStorageOfAllEnergyHatches(); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+": "+ + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+": "+ + EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET+ " EU/t(*2A) "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ + EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(getMaxInputVoltage())]+ EnumChatFormatting.RESET); + } + if (!this.mAllDynamoHatches.isEmpty()) { + long storedEnergy = getStoredEnergyInAllDynamoHatches(); + long maxEnergy = getMaxEnergyStorageOfAllDynamoHatches(); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+" In Dynamos: "+ + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU"); + } - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + this.getPollutionPerTick(null)*20+ EnumChatFormatting.RESET+"/sec"); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %"); + if (-mEUt > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+": "+ + EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t"); + } + else { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.generation")+": "+ + EnumChatFormatting.GREEN + Integer.toString(mEUt) + EnumChatFormatting.RESET + " EU/t"); + } + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.problems")+": "+ + EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ + " "+StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ + EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); - mInfo.add(StatCollector.translateToLocal("GTPP.CC.machinetier")+": "+ - EnumChatFormatting.GREEN+tTier+EnumChatFormatting.RESET); + if (this.getPollutionPerSecond(null) > 0) { + int mPollutionReduction = getPollutionReductionForAllMufflers(); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + this.getPollutionPerSecond(null)+ EnumChatFormatting.RESET+"/sec"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %"); + } - mInfo.add(StatCollector.translateToLocal("GTPP.CC.discount")+": "+ - EnumChatFormatting.GREEN+(getEuDiscountForParallelism())+EnumChatFormatting.RESET + "%"); + if (this.mControlCoreBus.size() > 0) { + int tTier = this.getControlCoreTier(); + mInfo.add(StatCollector.translateToLocal("GTPP.CC.machinetier")+": "+ + EnumChatFormatting.GREEN+tTier+EnumChatFormatting.RESET); + } - mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(getMaxParallelRecipes())+EnumChatFormatting.RESET); + mInfo.add(StatCollector.translateToLocal("GTPP.CC.discount")+": "+ + EnumChatFormatting.GREEN+(getEuDiscountForParallelism())+EnumChatFormatting.RESET + "%"); + mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(getMaxParallelRecipes())+EnumChatFormatting.RESET); - mInfo.add("Total Time Since Built: " + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks)+EnumChatFormatting.RESET+" Weeks, " + EnumChatFormatting.DARK_GREEN+ Integer.toString(days) +EnumChatFormatting.RESET+ " Days, "); - mInfo.add(EnumChatFormatting.DARK_GREEN + Long.toString(hours) +EnumChatFormatting.RESET + " Hours, " + EnumChatFormatting.DARK_GREEN+ Long.toString(minutes) +EnumChatFormatting.RESET+ " Minutes, " + EnumChatFormatting.DARK_GREEN+ Long.toString(second) +EnumChatFormatting.RESET+ " Seconds."); - mInfo.add("Total Time in ticks: " + EnumChatFormatting.DARK_GREEN + Long.toString(this.mTotalRunTime)); + mInfo.add("Total Time Since Built: " + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks)+EnumChatFormatting.RESET+" Weeks, " + EnumChatFormatting.DARK_GREEN+ Integer.toString(days) +EnumChatFormatting.RESET+ " Days, "); + mInfo.add(EnumChatFormatting.DARK_GREEN + Long.toString(hours) +EnumChatFormatting.RESET + " Hours, " + EnumChatFormatting.DARK_GREEN+ Long.toString(minutes) +EnumChatFormatting.RESET+ " Minutes, " + EnumChatFormatting.DARK_GREEN+ Long.toString(second) +EnumChatFormatting.RESET+ " Seconds."); + mInfo.add("Total Time in ticks: " + EnumChatFormatting.DARK_GREEN + Long.toString(this.mTotalRunTime)); - String[] mInfo2 = new String[mInfo.size()]; - mInfo.toArray(mInfo2); - return mInfo2; + String[] mInfo2 = mInfo.toArray(new String[mInfo.size()]); + return mInfo2; + } + catch (Throwable t) { + t.printStackTrace(); + } + return new String[] {}; } @@ -282,7 +301,7 @@ public abstract class GregtechMeta_MultiBlockBase mTurbineRotorHatches = new ArrayList(); + public GregtechMetaTileEntity_LargerTurbineBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); frontFace = getTextureFrontFace(); @@ -70,37 +75,43 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM frontFace = getTextureFrontFace(); frontFaceActive = getTextureFrontFaceActive(); } - + protected abstract ITexture getTextureFrontFace(); - + protected abstract ITexture getTextureFrontFaceActive(); - + protected abstract String getTurbineType(); - + protected abstract String getCasingName(); + protected abstract boolean requiresOutputHatch(); + @Override protected final GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the XL "+getTurbineType()+" Turbine") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 9, false) - .addController("Top Middle") - .addCasingInfo(getCasingName(), 64) - .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1) - .addInputBus("Any 4 dot hint", 4) - .addInputHatch("Any 4 dot hint", 4) - .addOutputHatch("Any 4 dot hint", 4) - .addDynamoHatch("Any 4 dot hint", 4) - .addMaintenanceHatch("Any 4 dot hint", 4) - .addMufflerHatch("Any 7 dot hint x4", 7) - .toolTipFinisher(CORE.GT_Tooltip_Builder); + .addInfo("Controller Block for the XL "+getTurbineType()+" Turbine") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 9, 3, false) + .addController("Top Middle") + .addCasingInfo(getCasingName(), 360) + .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1) + .addInputBus("Any 4 dot hint (min 1)", 4) + .addInputHatch("Any 4 dot hint(min 1)", 4); + if (requiresOutputHatch()) { + tt.addOutputHatch("Any 4 dot hint(min 1)", 4); + } + tt.addDynamoHatch("Any 4 dot hint(min 1)", 4) + .addMaintenanceHatch("Any 4 dot hint(min 1)", 4); + if (requiresMufflers()) { + tt.addMufflerHatch("Any 7 dot hint (x4)", 7); + } + tt.toolTipFinisher(CORE.GT_Tooltip_Builder); return tt; } - + private static final String STRUCTURE_PIECE_MAIN = "main"; private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue>() { @Override @@ -121,12 +132,18 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, {"ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc"}, {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, - })) - .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) + })) + + .addElement('c', lazy(t -> onElementPass(x -> ++x.mCasing, ofBlock(t.getCasingBlock(), t.getCasingMeta())))) .addElement('s', lazy(t -> ofBlock(t.getCasingBlock(), t.getTurbineShaftMeta()))) .addElement('t', lazy(t -> ofHatchAdder(GregtechMetaTileEntity_LargerTurbineBase::addTurbineHatch, t.getCasingTextureIndex(), 1))) - .addElement('h', lazy(t -> ofHatchAdderOptional(GregtechMetaTileEntity_LargerTurbineBase::addGenericHatch, t.getCasingTextureIndex(), 4, t.getCasingBlock(), t.getCasingMeta()))) - .addElement('m', lazy(t -> ofHatchAdderOptional(GregtechMetaTileEntity_LargerTurbineBase::addMuffler, t.getCasingTextureIndex(), 7, t.getCasingBlock(), t.getCasingMeta()))) + .addElement('h', lazy(t -> ofChain( + ofHatchAdder(GregtechMetaTileEntity_LargerTurbineBase::addGenericHatch, t.getCasingTextureIndex(), 4), + onElementPass(x -> ++x.mCasing, ofBlock(t.getCasingBlock(), t.getCasingMeta())) + ))) + .addElement('m', lazy(t -> ofChain( + ofHatchAdder(GregtechMetaTileEntity_LargerTurbineBase::addMuffler, t.getCasingTextureIndex(), 7), + onElementPass(x -> ++x.mCasing, ofBlock(t.getCasingBlock(), t.getCasingMeta()))))) .build(); } }; @@ -136,25 +153,36 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM return STRUCTURE_DEFINITION.get(getClass()); } + private boolean requiresMufflers() { + return getPollutionPerSecond(null) > 0; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { this.mDynamoHatches.clear(); this.mTurbineRotorHatches.clear(); this.mMaintenanceHatches.clear(); - this.mMufflerHatches.clear(); + if (requiresMufflers()) { + this.mMufflerHatches.clear(); + } this.mInputBusses.clear(); this.mInputHatches.clear(); - this.mOutputHatches.clear(); - + if (requiresOutputHatch()) { + this.mOutputHatches.clear(); + } + mCasing = 0; + boolean aStructure = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); + boolean aCasingCount = mCasing >= 360; log("Structure Check: "+aStructure); - if (mTurbineRotorHatches.size() != 12 || + if (!aCasingCount || + mTurbineRotorHatches.size() != 12 || mMaintenanceHatches.size() != 1 || mDynamoHatches.size() < 1 || - mMufflerHatches.size() != 4 || + (requiresMufflers() && mMufflerHatches.size() != 4) || mInputBusses.size() < 1 || mInputHatches.size() < 1 || - mOutputHatches.size() < 1 + (requiresOutputHatch() && mOutputHatches.size() < 1) ) { log("Bad Hatches - Turbine Housings: "+mTurbineRotorHatches.size()+ ", Maint: "+mMaintenanceHatches.size()+ @@ -163,11 +191,11 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM ", Input Buses: "+mInputBusses.size()+ ", Input Hatches: "+mInputHatches.size()+ ", Output Hatches: "+mOutputHatches.size()+ - ", "); + ", Casing Count: "+aCasingCount+" | Found: "+mCasing); return false; } - log("Built "+this.getLocalName()); - return aStructure; + log("Built "+this.getLocalName()+" with "+mCasing+"/360 casings."); + return aCasingCount && aStructure; } @Override @@ -189,8 +217,9 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM GT_MetaTileEntity_Hatch_Turbine aTurbineHatch = (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity; IGregTechTileEntity g = this.getBaseMetaTileEntity(); if (aTurbineHatch.setController(new BlockPos(g.getXCoord(), g.getYCoord(), g.getZCoord(), g.getWorld()))) { - Logger.INFO("Injected Controller into Turbine Assembly."); - return this.mTurbineRotorHatches.add(aTurbineHatch); + boolean aDidAdd = this.mTurbineRotorHatches.add(aTurbineHatch); + Logger.INFO("Injected Controller into Turbine Assembly. Found: "+this.mTurbineRotorHatches.size()); + return aDidAdd; } else { Logger.INFO("Failed to inject controller into Turbine Assembly Hatch."); @@ -209,7 +238,6 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM return addToMachineList(aTileEntity, aBaseCasingIndex); } } - log("Bad Muffler"); return false; } @@ -264,10 +292,10 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM public final Block getCasingBlock() { return ModBlocks.blockSpecialMultiCasings; } - + @Override public final boolean hasSlotInGUI() { - return false; + return true; } public abstract int getCasingMeta(); @@ -278,104 +306,292 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM public abstract byte getCasingTextureIndex(); - public abstract int getFuelValue(FluidStack aLiquid); - - public static boolean isValidTurbine(ItemStack aTurbine) { - return (aTurbine !=null && aTurbine.getItem() instanceof GT_MetaGenerated_Tool && aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() <= 176); - } - - private ArrayList getAllBufferedTurbines(){ - ArrayList aTurbinesInStorage = new ArrayList(); - for (GT_MetaTileEntity_Hatch_InputBus aBus: this.mInputBusses) { - if (isValidMetaTileEntity(aBus)) { - for (ItemStack aContent : aBus.mInventory) { - if (isValidTurbine(aContent)) { - aTurbinesInStorage.add(aContent); - } - } - } - } - return aTurbinesInStorage; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - + public abstract int getFuelValue(FluidStack aLiquid); + + public static boolean isValidTurbine(ItemStack aTurbine) { + return (aTurbine !=null && aTurbine.getItem() instanceof GT_MetaGenerated_Tool && aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() <= 176); + } + + private ArrayList getAllBufferedTurbines(){ + ArrayList aTurbinesInStorage = new ArrayList(); + for (GT_MetaTileEntity_Hatch_InputBus aBus: this.mInputBusses) { + if (isValidMetaTileEntity(aBus)) { + for (ItemStack aContent : aBus.mInventory) { + if (isValidTurbine(aContent)) { + aTurbinesInStorage.add(aContent); + } + } + } + } + return aTurbinesInStorage; + } + + public boolean areAllTurbinesTheSame() { + ArrayList aTurbineAssemblies = getFullTurbineAssemblies(); + if (aTurbineAssemblies.size() < 12) { + log("Found "+aTurbineAssemblies.size()+", expected 12."); + return false; + } + AutoMap aTurbineMats = new AutoMap(); + AutoMap aTurbineSizes = new AutoMap(); + for (GT_MetaTileEntity_Hatch_Turbine aHatch : aTurbineAssemblies) { + aTurbineMats.add(GT_MetaGenerated_Tool.getPrimaryMaterial(aHatch.getTurbine())); + aTurbineSizes.add(getTurbineSize(aHatch.getTurbine())); + } + Materials aBaseMat = aTurbineMats.get(0); + int aBaseSize = aTurbineSizes.get(0); + for (int aSize : aTurbineSizes) { + if (aBaseSize != aSize) { + return false; + } + } + for (Materials aMat : aTurbineMats) { + if (aBaseMat != aMat) { + return false; + } + } + return true; + } + + public static int getTurbineSize(ItemStack aTurbine) { + if (isValidTurbine(aTurbine)) { + if (aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() < 172) { + return 1; + } + else if (aTurbine.getItemDamage() >= 172 && aTurbine.getItemDamage() < 174) { + return 2; + } + else if (aTurbine.getItemDamage() >= 174 && aTurbine.getItemDamage() < 176) { + return 3; + } + else if (aTurbine.getItemDamage() >= 176 && aTurbine.getItemDamage() < 178) { + return 4; + } + } + return 0; + } + + public static String getTurbineSizeString(int aSize) { + switch (aSize) { + case 1: + return "Small Turbine"; + case 2: + return "Turbine"; + case 3: + return "Large Turbine"; + case 4: + return "Huge Turbine"; + default: + return ""; + } + } + + private ArrayList getEmptyTurbineAssemblies() { ArrayList aEmptyTurbineRotorHatches = new ArrayList(); + //log("Checking "+mTurbineRotorHatches.size()+" Assemblies for empties."); for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) { if (!aTurbineHatch.hasTurbine()) { + //log("Found Assembly without Turbine."); aEmptyTurbineRotorHatches.add(aTurbineHatch); } } - if (aEmptyTurbineRotorHatches.size() > 0) { - ArrayList aTurbines = getAllBufferedTurbines(); - for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { - for (ItemStack aTurbineItem : aTurbines) { - if (aHatch.insertTurbine(aTurbineItem) && this.depleteInput(aTurbineItem)) { - continue; - } - else { - break; - } - } + return aEmptyTurbineRotorHatches; + } + + private ArrayList getFullTurbineAssemblies() { + ArrayList aTurbineRotorHatches = new ArrayList(); + //log("Checking "+mTurbineRotorHatches.size()+" Assemblies for Turbines."); + for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) { + if (aTurbineHatch.hasTurbine()) { + //log("Found Assembly with Turbine."); + aTurbineRotorHatches.add(aTurbineHatch); } - } - - if((counter&7)==0 && (aStack==null || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) || aStack.getItemDamage() < 170 || aStack.getItemDamage() >179)) { - stopMachine(); - return false; } - ArrayList tFluids = getStoredFluids(); - if (tFluids.size() > 0) { - if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() - || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { - counter = 0; - baseEff = MathUtils.safeInt((long)((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - optFlow = MathUtils.safeInt((long)Math.max(Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() - * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed - * 50)); - if(optFlow<=0 || baseEff<=0){ - stopMachine();//in case the turbine got removed - return false; + return aTurbineRotorHatches; + } + + private boolean depleteTurbineFromStock(ItemStack aTurbine) { + for (GT_MetaTileEntity_Hatch_InputBus aInputBus : this.mInputBusses) { + for (int slot = 0; slot < aInputBus.mInventory.length; slot++) { + ItemStack aStack = aInputBus.getStackInSlot(slot); + if (aStack != null && GT_Utility.areStacksEqual(aStack, aTurbine)) { + aInputBus.setInventorySlotContents(slot, null); + updateSlots(); + return true; } - } else { - counter++; } } - else { - Logger.INFO("Did not find any valid input fluids."); - } + return false; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(new ItemStack[] {}, getStoredFluids().toArray(new FluidStack[] {}), 1, 100, 100, 10000); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isPerpectOC) { + + try { + ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); + if (aEmptyTurbineRotorHatches.size() > 0) { + log("Found "+aEmptyTurbineRotorHatches.size()+" Assemblies without Turbine."); + ArrayList aTurbines = getAllBufferedTurbines(); + hatch : for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { + for (ItemStack aTurbineItem : aTurbines) { + if (aTurbineItem == null) { + continue; + } + if (aTurbineItem != null && aHatch.insertTurbine(aTurbineItem.copy())) { + boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem); + log("Put Turbine into Assembly - "+aDidDeplete); + continue hatch; + } + } + } + } + //log("Found "+getFullTurbineAssemblies().size()+" Assemblies with a Turbine."); - int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow - int difference = newPower - this.mEUt; // difference between current output and new output + if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { + log("BAD RETURN - 1"); + stopMachine(); + return false; + } - // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) - // This is how much the turbine can actually change during this tick - int maxChangeAllowed = Math.max(10, MathUtils.safeInt((long)Math.abs(difference)/100)); + //log("Running checkRecipeGeneric(0)"); + + ArrayList tFluids = getStoredFluids(); + + if (tFluids.size() > 0) { + if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() + || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { + counter = 0; + + //log("Running checkRecipeGeneric(1)"); + float aTotalBaseEff = 0; + float aTotalOptimalFlow = 0; + + ItemStack aStack = getFullTurbineAssemblies().get(0).getTurbine(); + for (int i=0;i<18;i++) { + if (i == 0) { + aTotalBaseEff += GT_Utility.safeInt((long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); + //log("Bumped base eff to "+aTotalBaseEff); + } + aTotalOptimalFlow += GT_Utility.safeInt((long) Math.max(Float.MIN_NORMAL, + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() + * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed + * 50)); + //log("Bumped base optimal flow to "+aTotalOptimalFlow); + } - if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change - int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. - this.mEUt += change; // Apply the change - } else { - this.mEUt = newPower; + //log("Running checkRecipeGeneric(2)"); + //log("Total base eff: "+aTotalBaseEff); + //log("Total base optimal flow: "+aTotalOptimalFlow); + baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); + optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); + //log("Total eff: "+baseEff); + //log("Total optimal flow: "+optFlow); + if(optFlow<=0 || baseEff<=0){ + log("Running checkRecipeGeneric(bad-1)"); + stopMachine();//in case the turbine got removed + return false; + } + } else { + counter++; + } + } + + //log("Total eff: "+baseEff); + //log("Total optimal flow: "+optFlow); + + // How much the turbine should be producing with this flow + int newPower = fluidIntoPower(tFluids, optFlow, baseEff); + //log("Bumped newPower to "+newPower); + //log("New Power: "+newPower); + int difference = newPower - this.mEUt; // difference between current output and new output + //log("diff: "+difference); + + // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) + // This is how much the turbine can actually change during this tick + int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long)Math.abs(difference)/100)); + //log("Max Change Allowed: "+maxChangeAllowed); + + if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change + int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. + this.mEUt += change; // Apply the change + //log("Applied power change."); + } + else { + this.mEUt = newPower; + //log("Using same value."); + } + if (this.mEUt <= 0) { + this.mEUt=0; + this.mEfficiency=0; + log("Running checkRecipeGeneric(bad-2)"); + //stopMachine(); + return false; + } else { + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 10; + // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + //log("GOOD RETURN - Making: "+this.mEUt+" EU/t"); + return true; + } + } + catch (Throwable t) { + t.printStackTrace(); } + return false; + } - if (this.mEUt <= 0) { - //stopMachine(); - this.mEUt=0; - this.mEfficiency=0; + public boolean doRandomMaintenanceDamage() { + if (getMaxParallelRecipes() == 0 || getRepairStatus() == 0) { + stopMachine(); return false; - } else { - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 10; - if(this.mDynamoHatches.size()>0){ - for(GT_MetaTileEntity_Hatch dynamo:mDynamoHatches) - if(isValidMetaTileEntity(dynamo) && dynamo.maxEUOutput() < mEUt) - explodeMultiblock(); - } - return true; } + if (mRuntime++ > 1000) { + mRuntime = 0; + if (getBaseMetaTileEntity().getRandomNumber(6000) == 0) { + switch (getBaseMetaTileEntity().getRandomNumber(6)) { + case 0: + mWrench = false; + break; + case 1: + mScrewdriver = false; + break; + case 2: + mSoftHammer = false; + break; + case 3: + mHardHammer = false; + break; + case 4: + mSolderingTool = false; + break; + case 5: + mCrowbar = false; + break; + } + } + for (GT_MetaTileEntity_Hatch_Turbine aHatch : getFullTurbineAssemblies()) { + aHatch.damageTurbine(mEUt, damageFactorLow, damageFactorHigh); + } + } + return true; + } + + @Override + public int getMaxParallelRecipes() { + return (getFullTurbineAssemblies().size()); + } + + public boolean runRecipe(GT_MetaTileEntity_Hatch_Turbine aHatch) { + return false; } abstract int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff); @@ -386,19 +602,17 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM } public int getMaxEfficiency(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return 0; - } - if (aStack.getItem() instanceof GT_MetaGenerated_Tool_01) { - return 10000; - } - return 0; + return this.getMaxParallelRecipes() == 12 ? 10000 : 0; } @Override public boolean explodesOnComponentBreak(ItemStack aStack) { return true; } + public boolean isLooseMode() { + return false; + } + @Override public String[] getExtraInfoData() { int mPollutionReduction=0; @@ -408,17 +622,20 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM } } - String tRunning = mMaxProgresstime>0 ? - + String tRunning = mMaxProgresstime > 0 ? EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.running.true")+EnumChatFormatting.RESET : EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.running.false")+EnumChatFormatting.RESET; + String tMaintainance = getIdealStatus() == getRepairStatus() ? EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET : EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET ; int tDura = 0; - if (mInventory[1] != null && mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { - tDura = MathUtils.safeInt((long)(100.0f / GT_MetaGenerated_Tool.getToolMaxDamage(mInventory[1]) * (GT_MetaGenerated_Tool.getToolDamage(mInventory[1]))+1)); + String aTurbineDamage = ""; + for (GT_MetaTileEntity_Hatch_Turbine aHatch : this.getFullTurbineAssemblies()) { + ItemStack aTurbine = aHatch.getTurbine(); + tDura = MathUtils.safeInt((long)(100.0f / GT_MetaGenerated_Tool.getToolMaxDamage(aTurbine) * (GT_MetaGenerated_Tool.getToolDamage(aTurbine))+1)); + aTurbineDamage += EnumChatFormatting.RED+Integer.toString(tDura)+EnumChatFormatting.RESET+"% | "; } long storedEnergy=0; @@ -429,29 +646,23 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); } } + + boolean aIsSteam = this.getClass().getName().toLowerCase().contains("steam"); + String[] ret = new String[]{ // 8 Lines available for information panels tRunning + ": " + EnumChatFormatting.RED+mEUt+EnumChatFormatting.RESET+" EU/t", - /* 1 */ tMaintainance, - /* 2 */ StatCollector.translateToLocal("GT5U.turbine.efficiency")+": "+EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.RESET+"%", - /* 2 */ StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ - /* 3 */ - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", - StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+MathUtils.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t" + - /* 4 */ - EnumChatFormatting.YELLOW+" ("+(looseFit?StatCollector.translateToLocal("GT5U.turbine.loose"):StatCollector.translateToLocal("GT5U.turbine.tight"))+")", - /* 5 */ - StatCollector.translateToLocal("GT5U.turbine.fuel")+": "+EnumChatFormatting.GOLD+storedFluid+EnumChatFormatting.RESET+"L", - /* 6 */ - StatCollector.translateToLocal("GT5U.turbine.dmg")+": "+EnumChatFormatting.RED+Integer.toString(tDura)+EnumChatFormatting.RESET+"%", - /* 7 */ - StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" - /* 8 */ + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", + StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+MathUtils.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t" + + EnumChatFormatting.YELLOW+" ("+(isLooseMode()?StatCollector.translateToLocal("GT5U.turbine.loose"):StatCollector.translateToLocal("GT5U.turbine.tight"))+")", + StatCollector.translateToLocal("GT5U.turbine.fuel")+": "+EnumChatFormatting.GOLD+storedFluid+EnumChatFormatting.RESET+"L", + StatCollector.translateToLocal("GT5U.turbine.dmg")+": "+aTurbineDamage, + StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" }; - if (!this.getClass().getName().contains("Steam")) + if (!aIsSteam) ret[4]=StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+MathUtils.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t"; return ret; @@ -465,19 +676,22 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM public boolean polluteEnvironment(int aPollutionLevel) { - mPollution += aPollutionLevel; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (mPollution >= 1000) { - if (PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 1000)) { - mPollution -= 1000; + if (this.requiresMufflers()) { + mPollution += aPollutionLevel; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (mPollution >= 10000) { + if (PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10000)) { + mPollution -= 10000; + } + } else { + break; } - } else { - break; } } + return mPollution < 10000; } - return mPollution < 1000; + return true; } @Override public long maxAmperesOut() { @@ -506,7 +720,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM } } } - */} + */} } @Override @@ -523,15 +737,19 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide()) { - if (mUpdate == 0 || this.mStartUpCheck == 0) { + if (mUpdate == 1 || mStartUpCheck == 1) { + log("Cleared Rotor Assemblies."); this.mTurbineRotorHatches.clear(); } - } - if (aTick % 20 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + } + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.maxProgresstime() > 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { enableAllTurbineHatches(); } + if (this.maxProgresstime() <= 0) { + stopMachine(); + } } @Override @@ -539,16 +757,13 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM super.startProcess(); enableAllTurbineHatches(); } - - @Override - public boolean onRunningTick(ItemStack aStack) { - return super.onRunningTick(aStack); - } - + @Override public void stopMachine() { - super.stopMachine(); + baseEff = 0; + optFlow = 0; disableAllTurbineHatches(); + super.stopMachine(); } @Override public void onRemoval() { @@ -585,16 +800,11 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM return aUpdated; } - @Override - public int getMaxParallelRecipes() { - return 1; - } - @Override public int getEuDiscountForParallelism() { return 0; } - + @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); @@ -604,5 +814,82 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM this.getBaseMetaTileEntity().setFrontFacing((byte) 1); } } + + /** + * Called every tick the Machine runs + */ + public boolean onRunningTick(ItemStack aStack) { + if (mEUt > 0) { + addEnergyOutput(((long) mEUt * mEfficiency) / 10000); + return true; + } + return false; + } + + @Override + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) { + return true; + } + if (this.mAllDynamoHatches.size() > 0) { + return addEnergyOutputMultipleDynamos(aEU, true); + } + return false; + } + + public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { + int injected = 0; + long totalOutput = 0; + long aFirstVoltageFound = -1; + boolean aFoundMixedDynamos = false; + for (GT_MetaTileEntity_Hatch aDynamo : mAllDynamoHatches) { + if(aDynamo == null) { + return false; + } + if (isValidMetaTileEntity(aDynamo)) { + long aVoltage = aDynamo.maxEUOutput(); + long aTotal = aDynamo.maxAmperesOut() * aVoltage; + // Check against voltage to check when hatch mixing + if (aFirstVoltageFound == -1) { + aFirstVoltageFound = aVoltage; + } + else { + if (aFirstVoltageFound != aVoltage) { + aFoundMixedDynamos = true; + } + } + totalOutput += aTotal; + } + } + + if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { + explodeMultiblock(); + return false; + } + + long leftToInject; + long aVoltage; + int aAmpsToInject; + int aRemainder; + int ampsOnCurrentHatch; + for (GT_MetaTileEntity_Hatch aDynamo : mAllDynamoHatches) { + if (isValidMetaTileEntity(aDynamo)) { + leftToInject = aEU - injected; + aVoltage = aDynamo.maxEUOutput(); + aAmpsToInject = (int) (leftToInject / aVoltage); + aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); + ampsOnCurrentHatch= (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); + for (int i = 0; i < ampsOnCurrentHatch; i++) { + aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false); + } + injected+=aVoltage*ampsOnCurrentHatch; + if(aRemainder>0 && ampsOnCurrentHatch 0; + } } diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index 4f6b835f67..bd455a2c4c 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -15,6 +15,7 @@ GTPP.multiblock.efficiency=Efficiency GTPP.multiblock.problems=Problems GTPP.multiblock.mei=Max Energy Income GTPP.multiblock.usage=Probably uses +GTPP.multiblock.generation=Probably generates GTPP.multiblock.specialvalue=Special Value GTPP.multiblock.duration=Duration -- cgit From 7c02ac0977ee37dda637d21d7d1092835b1d03eb Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 6 Jan 2022 11:18:05 +0000 Subject: Added Asm, Screenshots and World to .gitignore. Removed some useless classes. Buffed Amazon Packager. Implemented Caching for Amazon Packager. Fixed all GT++ multis getting stuck when input bus contains less than required input of an item. (It will check other inputs for another valid recipe now) --- .gitignore | 3 + .../base/GregtechMeta_MultiBlockBase.java | 17 +- .../gregtech/api/objects/MultiblockBlueprint.java | 469 --------------- .../xmod/gregtech/api/objects/MultiblockLayer.java | 643 --------------------- .../api/objects/MultiblockRequirements.java | 108 ---- .../common/blueprint/Blueprint_Generic_3x3.java | 87 --- .../gregtech/common/blueprint/Blueprint_LFTR.java | 137 ----- .../requirements/RequirementsBasicCubic.java | 11 - .../machines/multi/misc/GMTE_AmazonPackager.java | 376 ++++++++++-- 9 files changed, 343 insertions(+), 1508 deletions(-) delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockBlueprint.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/.gitignore b/.gitignore index 558ad12d27..ba4022fb72 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ whitelist.json *.ipr *.iws src/main/resources/mixins.*.json +asm +/screenshots +/world diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 42fdc246b4..c8b58ff097 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -40,7 +40,6 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput; -import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -94,7 +93,6 @@ public abstract class GregtechMeta_MultiBlockBase j = MultiblockLayer.rotateOffsetValues(aDir, X, Z); - offsetX = j.getKey(); - offsetZ = j.getValue(); - - Logger.INFO("Pre-Rotated Offsets ["+X+", "+(aPos.yPos + Y)+", "+Z+"] | "+aDir.name()); - Logger.INFO("Rotated Offsets ["+offsetX+", "+(aPos.yPos + Y)+", "+offsetZ+"]"); - - // Resolve Negatives - int negTestX, negTestZ; - if (aPos.xPos < 0) { - int testA = aPos.xPos; - testA -= -offsetX; - negTestX = testA; - } else { - negTestX = offsetX + aPos.xPos; - } - if (aPos.zPos < 0) { - int testA = aPos.zPos; - testA -= -offsetZ; - negTestZ = testA; - } else { - negTestZ = offsetZ + aPos.zPos; - } - Logger.INFO("Caching With Offset ["+negTestX+", "+(aPos.yPos + Y)+", "+negTestZ+"]"); - StructureMatrix[X][Y][Z] = new BlockPos(negTestX, (aPos.yPos + Y), negTestZ, aPos.world); - - if (debugCacheDataVisually) { - aBaseMetaTileEntity.getWorld().setBlock(negTestX, (aPos.yPos + Y), negTestZ, Blocks.glass); - } - } - } - } - Logger.INFO("Cached blueprint matrix."); - mGeneratedMatrix = true; - } - else { - Logger.INFO("Found cached blueprint matrix."); - } - - if (StructureMatrix == null) { - Logger.INFO("Error caching blueprint matrix."); - return false; - } - - - int a1, a2, a3; - a1 = StructureMatrix.length; - a2 = StructureMatrix[0].length; - a3 = StructureMatrix[0][0].length; - - Logger.INFO("Matrix Size ["+a1+", "+a2+", "+a3+"]"); - - for (int H = 0; H < a2; H++) { - - MultiblockLayer currentLayer = this.getLayer(H); - for (int W = 0; W < a1; W++) { - for (int D = 0; D < a3; D++) { - - BlockPos aToCheck = StructureMatrix[W][H][D]; - if (aToCheck == null) { - Logger.INFO("Found bad data stored at X: "+W+", Y: "+H+", Z: "+D); - continue; - } - else { - //Logger.INFO("Found data stored at X: "+W+", Y: "+H+", Z: "+D); - Logger.INFO("Checking "+aToCheck.getLocationString()); - } - - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntity(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos); - final Block tBlock = aBaseMetaTileEntity.getBlock(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos); - final int tMeta = aBaseMetaTileEntity.getMetaID(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos); - - - LayerBlockData g1 = currentLayer.getDataFromCoordsWithDirection(aDir, W, D); - if (g1 == null) { - Logger.INFO("Failed to find LayerBlockData. Using AIR_FALLBACK"); - //return false;*/ - g1 = LayerBlockData.FALLBACK_AIR_CHECK; - } - else { - if (g1.isController) { - Logger.INFO("Controller is at X: "+W+", Y: "+H+", Z: "+D); - } - } - - boolean isMatch = g1.match(tBlock, tMeta); - - - if (!isMatch) { - Logger.INFO("Checking ["+aToCheck.xPos+", "+ aToCheck.yPos +", "+ aToCheck.zPos+"]"); - Logger.INFO("Checking Position relative to Grid. X: "+W+", Y: "+H+", Z: "+D); - Logger.INFO("Found "+tBlock.getLocalizedName()+" : "+tMeta + " | Bad ["+W+", "+D+"]"); - - LayerBlockData g = currentLayer.getDataFromCoordsWithDirection(aDir, W, D); - - if (g == null) { - Logger.INFO("Expected "+" BAD DATA - Possibly Unset Area in Blueprint."); - - } - else { - Logger.INFO("Expected "+g.mBlock.getLocalizedName()+" : "+g.mMeta + ""); - } - aBaseMetaTileEntity.getWorld().setBlock(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos, g.mBlock); - aBaseMetaTileEntity.getWorld().setBlockMetadataWithNotify(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos, g.mMeta, 4); - //return false; - } - else { - - LayerBlockData g = currentLayer.getDataFromCoordsWithDirection(aDir, W, D); - - - - - - - - - - - - - - - - - - - - boolean isHatchValidType = false; - if (g != null) { - if (g.canBeHatch && !g.isController && tTileEntity != null) { - IMetaTileEntity aMetaTileEntity2 = tTileEntity.getMetaTileEntity(); - if (aMetaTileEntity2 != null) { - if (aMetaTileEntity2 instanceof GT_MetaTileEntity_MultiBlockBase) { - isHatchValidType = true; - break; - } - else { - for (Class c : g.mHatchClass) { - if (c != null) { - if (c.isInstance(aMetaTileEntity2)) { - isHatchValidType = true; - break; - } - } - } - } - } - } - } - - if (!isHatchValidType && !g.isController && tTileEntity != null) { - Logger.INFO("Checking ["+aToCheck.xPos+", "+ aToCheck.yPos +", "+ aToCheck.zPos+"]"); - Logger.INFO("Hatch Type did not match allowed types. "+tTileEntity.getClass().getSimpleName()); - return false; - } - if (!aControllerObject.addToMachineList(tTileEntity, mTextureID)) { - tAmount++; - } - - - } - } - } - } - - boolean hasCorrectHatches = ( - aControllerObject.mInputBusses.size() >= this.getMinimumInputBus() && - aControllerObject.mOutputBusses.size() >= this.getMinimumOutputBus() && - aControllerObject.mInputHatches.size() >= this.getMinimumInputHatch() && - aControllerObject.mOutputHatches.size() >= this.getMinimumOutputHatch() && - aControllerObject.mDynamoHatches.size() >= this.getMinimumOutputEnergy() && - aControllerObject.mEnergyHatches.size() >= this.getMinimumInputEnergy() && - aControllerObject.mMaintenanceHatches.size() >= this.getMinimumMaintHatch() && - aControllerObject.mMufflerHatches.size() >= this.getMinimumMufflers()); - - - Logger.INFO("mInputBusses: "+aControllerObject.mInputBusses.size()); - Logger.INFO("mOutputBusses: "+aControllerObject.mOutputBusses.size()); - Logger.INFO("mInputHatches: "+aControllerObject.mInputHatches.size()); - Logger.INFO("mOutputHatches: "+aControllerObject.mOutputHatches.size()); - Logger.INFO("mEnergyHatches: "+aControllerObject.mEnergyHatches.size()); - Logger.INFO("mDynamoHatches: "+aControllerObject.mDynamoHatches.size()); - Logger.INFO("mMaintenanceHatches: "+aControllerObject.mMaintenanceHatches.size()); - Logger.INFO("mMufflerHatches: "+aControllerObject.mMufflerHatches.size()); - - boolean built = hasCorrectHatches && tAmount >= mMinimumCasingCount; - Logger.INFO("Built? "+built); - Logger.INFO("hasCorrectHatches? "+hasCorrectHatches); - Logger.INFO("tAmount? "+tAmount); - return built; - } - - public BlockPos getOffsetRelativeToGridPosition(final IGregTechTileEntity aBaseMetaTileEntity, final int x, final int y, final int z) { - - if (aBaseMetaTileEntity == null) { - return null; - } - - int controllerX, controllerY, controllerZ; - MultiblockLayer layerController = this.getControllerLayer(); - - if (layerController == null) { - return null; - } - - int controllerYRelative = this.getControllerY(); - Pair controllerLocationRelativeToGrid = layerController.getControllerLocation(); - - if (controllerLocationRelativeToGrid == null) { - return null; - } - - controllerX = aBaseMetaTileEntity.getXCoord(); - controllerY = aBaseMetaTileEntity.getYCoord(); - controllerZ = aBaseMetaTileEntity.getZCoord(); - - Logger.INFO("Controller is at ["+controllerX+", "+controllerY+", "+controllerZ+"]"); - - ForgeDirection aDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); - Logger.INFO("Controller is facing "+aDir.name()); - - //Find Bottom Left corner of Structure - // 0, 0, 0 - - int offsetX, offsetY, offsetZ; - int X = controllerLocationRelativeToGrid.getKey(), Z = controllerLocationRelativeToGrid.getValue(); - Logger.INFO("Attempting to translate offsets ["+X+", "+Z+"]"); - if (aDir == ForgeDirection.NORTH) { - offsetX = -X; - offsetZ = -Z; - } - - else if (aDir == ForgeDirection.EAST) { - offsetX = Z; - offsetZ = -X; - } - - else if (aDir == ForgeDirection.SOUTH) { - offsetX = X; - offsetZ = Z; - } - - else if (aDir == ForgeDirection.WEST) { - offsetX = -Z; - offsetZ = X; - } - else { - offsetX = -X; - offsetZ = -Z; - } - - offsetY = -controllerYRelative; - - Logger.INFO("Attempting to use offsets ["+offsetX+", "+offsetY+", "+offsetZ+"]"); - - //Resolve Negatives - int negTestX, negTestZ; - if (controllerX < 0) { - Logger.INFO("Found Negative X Pos."); - int testA = controllerX; - testA -= offsetX; - Logger.INFO("Adding Inverted Offset of "+offsetX+", making "+testA); - negTestX = testA; - } - else { - negTestX = offsetX + controllerX; - } - if (controllerZ < 0) { - Logger.INFO("Found Negative Z Pos."); - int testA = controllerZ; - testA -= -offsetZ; - Logger.INFO("Adding Inverted Offset of "+offsetZ+", making "+testA); - negTestZ = testA; - } - else { - negTestZ = offsetZ + controllerZ; - } - - - //} - //Bottom left Corner position - BlockPos p = new BlockPos(negTestX, offsetY+controllerY, negTestZ, aBaseMetaTileEntity.getWorld()); - - Logger.INFO("World XYZ for Bottom left Corner Block of structure ["+p.xPos+", "+p.yPos+", "+p.zPos+"]"); - - //Add the xyz relative to the grid. - BlockPos offsetPos = new BlockPos(p.xPos+x, p.yPos+y, p.zPos+z, aBaseMetaTileEntity.getWorld()); - Logger.INFO("World XYZ for Target Check Block in structure ["+offsetPos.xPos+", "+offsetPos.yPos+", "+offsetPos.zPos+"]"); - - return p; - } - - - public IGregTechTileEntity getTileAtOffset(final IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z){ - BlockPos aPos = getOffsetRelativeToGridPosition(aBaseMetaTileEntity, x, y, z); - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(aPos.xPos, aPos.yPos, aPos.zPos); - //aBaseMetaTileEntity.getWorld().setBlock(xh, yh, zh, Blocks.gold_ore); - return tTileEntity; - } - - public Pair getBlockAtOffset(final IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z){ - BlockPos aPos = getOffsetRelativeToGridPosition(aBaseMetaTileEntity, x, y, z); - final Block tBlock = aBaseMetaTileEntity.getBlockOffset(aPos.xPos, aPos.yPos, aPos.zPos); - final int tMeta = aBaseMetaTileEntity.getMetaIDOffset(aPos.xPos, aPos.yPos, aPos.zPos); - return new Pair(tBlock, tMeta); - } - - public Triplet getOffsetFromControllerTo00(){ - MultiblockLayer l = this.getControllerLayer(); - if (l == null) { - return null; - } - int yOffset = this.getControllerY(); - Pair cl = l.getControllerLocation(); - - if (cl == null) { - return null; - } - - return new Triplet (cl.getKey(), yOffset, cl.getValue()); - //return new Triplet (cl.getKey(), yOffset, cl.getValue()); - - } - - public abstract int getMinimumInputBus(); - public abstract int getMinimumInputHatch(); - public abstract int getMinimumOutputBus(); - public abstract int getMinimumOutputHatch(); - public abstract int getMinimumInputEnergy(); - public abstract int getMinimumOutputEnergy(); - public abstract int getMinimumMaintHatch(); - public abstract int getMinimumMufflers(); - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java deleted file mode 100644 index c5554a6679..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java +++ /dev/null @@ -1,643 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.objects; - -import java.util.HashMap; - -import gregtech.api.GregTech_API; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.init.Blocks; -import net.minecraftforge.common.util.ForgeDirection; - -public class MultiblockLayer { - - public final int width; - public final int depth; - - private boolean mFinalised; - - - /** - * WARNING!! May be {@link null}. - */ - private Pair mControllerLocation; - - /** - * Holds the North facing Orientation data. - */ - public final LayerBlockData[][] mLayerData; - public final AutoMap mVariantOrientations = new AutoMap(); - - /** - * A detailed class which will contain a single x/z Layer for a {@link MultiblockBlueprint}. - * Values are not relative, but in total. - * @param x - Overall width - * @param z - Overall depth - */ - public MultiblockLayer(final int x, final int z) { - width = x; - depth = z; - mLayerData = new LayerBlockData[x][z]; - //Logger.INFO("Created new Blueprint Layer."); - } - - /** - * A detailed class which will contain a single x/z Layer for a {@link MultiblockBlueprint}. - * Values are not relative, but in total. - */ - public MultiblockLayer(final LayerBlockData[][] aData) { - width = aData.length; - depth = aData[0].length; - mLayerData = aData; - } - - /** - * - * @param aBlock - The block expected as this location. - * @param aMeta - The meta for the block above. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @param canBeHatch - is this location able to be substituted for any hatch? - * @return - Is this data added to the layer data map? - */ - public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch) { - return addBlockForPos(aBlock, aMeta, x, z, canBeHatch, new Class[] {}); - } - - /** - * - * @param aBlock - The block expected as this location. - * @param aMeta - The meta for the block above. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @param canBeHatch - is this location able to be substituted for a hatch? - * @param aHatchTypeClass - Specify the class for the hatch if you want it explicit. Use base classes to allow custom hatches which extend. - * @return - Is this data added to the layer data map? - */ - public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch, Class aHatchTypeClass) { - return addBlockForPos(aBlock, aMeta, x, z, canBeHatch, new Class[] {aHatchTypeClass}); - } - - /** - * - * @param aBlock - The block expected as this location. - * @param aMeta - The meta for the block above. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @param canBeHatch - is this location able to be substituted for a hatch? - * @param aHatchTypeClass - Specify the class for the hatch if you want it explicit. Use base classes to allow custom hatches which extend. - * @return - Is this data added to the layer data map? - */ - public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch, Class[] aHatchTypeClass) { - if (x > width -1) { - return false; - } - if (z > depth - 1) { - return false; - } - - if (canBeHatch && (aHatchTypeClass == null || aHatchTypeClass.length <= 0)){ - - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - aHatchTypeClass = new Class[] { - GT_MetaTileEntity_Hatch_Dynamo.class, - GT_MetaTileEntity_Hatch_Energy.class, - GT_MetaTileEntity_Hatch_Input.class, - GT_MetaTileEntity_Hatch_InputBus.class, - GT_MetaTileEntity_Hatch_Maintenance.class, - GT_MetaTileEntity_Hatch_Muffler.class, - GT_MetaTileEntity_Hatch_Output.class, - GT_MetaTileEntity_Hatch_OutputBus.class, - GT_MetaTileEntity_Hatch.class - }; - } - else { - Class aDataHatch = ReflectionUtils.getClass("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess"); - if (aDataHatch != null) { - aHatchTypeClass = new Class[] { - aDataHatch, - GT_MetaTileEntity_Hatch_Dynamo.class, - GT_MetaTileEntity_Hatch_Energy.class, - GT_MetaTileEntity_Hatch_Input.class, - GT_MetaTileEntity_Hatch_InputBus.class, - GT_MetaTileEntity_Hatch_Maintenance.class, - GT_MetaTileEntity_Hatch_Muffler.class, - GT_MetaTileEntity_Hatch_Output.class, - GT_MetaTileEntity_Hatch_OutputBus.class, - GT_MetaTileEntity_Hatch.class - }; - } else { - aHatchTypeClass = new Class[] { - GT_MetaTileEntity_Hatch_Dynamo.class, - GT_MetaTileEntity_Hatch_Energy.class, - GT_MetaTileEntity_Hatch_Input.class, - GT_MetaTileEntity_Hatch_InputBus.class, - GT_MetaTileEntity_Hatch_Maintenance.class, - GT_MetaTileEntity_Hatch_Muffler.class, - GT_MetaTileEntity_Hatch_Output.class, - GT_MetaTileEntity_Hatch_OutputBus.class, - GT_MetaTileEntity_Hatch.class - }; - } - } - } - - - - mLayerData[x][z] = new LayerBlockData(aBlock, aMeta, canBeHatch, aHatchTypeClass); - return true; - } - - /** - * Adds a controller to the layer at the designated location, Details about the controller do not need to be specified. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addController(int x, int z) { - setControllerLocation(new Pair(x, z)); - return addBlockForPos(GregTech_API.sBlockMachines, 0, x, z, true, GT_MetaTileEntity_MultiBlockBase.class); - } - - - /** - * Adds a Muffler to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addMuffler(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Muffler.class); - } - - - /** - * Adds a Maint Hatch to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addMaintHatch(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Maintenance.class); - } - - - /** - * Adds ah Input to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addInputBus(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_InputBus.class); - } - - - /** - * Adds an Output to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addOutputBus(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_OutputBus.class); - } - - /** - * Adds ah Input to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addInputHatch(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Input.class); - } - - - /** - * Adds an Output to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addOutputHatch(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Output.class); - } - - /** - * Adds ah Input to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addInput(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, new Class[] {GT_MetaTileEntity_Hatch_Input.class, GT_MetaTileEntity_Hatch_InputBus.class}); - } - - - /** - * Adds an Output to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addOutput(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, new Class[] {GT_MetaTileEntity_Hatch_Output.class, GT_MetaTileEntity_Hatch_OutputBus.class}); - } - - /** - * Adds ah Input to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addEnergyInput(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Energy.class); - } - - - /** - * Adds an Output to the layer at the designated location. - * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. - * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. - * @return - Is this controller added to the layer data map? - */ - public boolean addEnergyOutput(Block aBlock, int aMeta, int x, int z) { - return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Dynamo.class); - } - - /** - * - * @param aBlock - The block you expect. - * @param aMeta - The meta you expect. - * @param x - the non-relative x location you expect it. - * @param z - the non-relative z location you expect it. - * @param aDir - The direction the controller is facing. - * @return - True if the correct Block was found. May also return true if a hatch is found when allowed or it's the controller. - */ - public boolean getBlockForPos(Block aBlock, int aMeta, int x, int z, ForgeDirection aDir) { - //Logger.INFO("Grid Index X: "+x+" | Z: "+z + " | "+aDir.name()); - LayerBlockData g; - if (aDir == ForgeDirection.SOUTH) { - g = mVariantOrientations.get(2)[x][z]; - } - else if (aDir == ForgeDirection.WEST) { - g = mVariantOrientations.get(3)[x][z]; - } - else if (aDir == ForgeDirection.NORTH) { - LayerBlockData[][] aData = mVariantOrientations.get(0); - if (aData != null) { - //Logger.INFO("Found Valid Orientation Data. "+aData.length + ", "+aData[0].length); - g = aData[x][z]; - } - else { - //Logger.INFO("Did not find valid orientation data."); - g = null; - } - } - else if (aDir == ForgeDirection.EAST) { - g = mVariantOrientations.get(1)[x][z]; - } - else { - g = mLayerData[x][z]; - } - if (g == null) { - Logger.INFO("Failed to find LayerBlockData. Using AIR_FALLBACK"); - //return false;*/ - g = LayerBlockData.FALLBACK_AIR_CHECK; - } - - return g.match(aBlock, aMeta); - } - - - - /** - * Is this layer final? - * @return - If true, layer data cannot be edited. - */ - public final boolean isLocked() { - return mFinalised; - } - - /** - * Used to finalize the layer, after which all four Orientations are then generated. - * Cannot be set to false, useful for not locking the layer if an error occurs. - * @param lockData - */ - public final void lock(boolean lockData) { - if (!lockData) { - Logger.INFO("Failed to lock layer"); - return; - } - //Logger.INFO("Trying to lock layer"); - this.mFinalised = true; - generateOrientations(); - //Logger.INFO("Trying to Build Blueprint Layer [Constructed orietations & finalized]"); - } - - private void generateOrientations() { - try { - - //Logger.INFO("Trying to gen orients for layer"); - //North - mVariantOrientations.put(mLayerData); - LayerBlockData[][] val; - //Logger.INFO("1 done"); - //East - val = rotateArrayClockwise(mLayerData); - mVariantOrientations.put((LayerBlockData[][]) val); - //Logger.INFO("2 done"); - //South - val = rotateArrayClockwise(mLayerData); - mVariantOrientations.put((LayerBlockData[][]) val); - //Logger.INFO("3 done"); - //West - val = rotateArrayClockwise(mLayerData); - mVariantOrientations.put((LayerBlockData[][]) val); - //Logger.INFO("4 done"); - - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - public static LayerBlockData[][] rotateArrayClockwise(LayerBlockData[][] mat) { - //Logger.INFO("Rotating Layer 90' Clockwise"); - try { - final int M = mat.length; - final int N = mat[0].length; - //Logger.INFO("Dimension X: "+M); - //Logger.INFO("Dimension Z: "+N); - LayerBlockData[][] ret = new LayerBlockData[N][M]; - for (int r = 0; r < M; r++) { - for (int c = 0; c < N; c++) { - ret[c][M-1-r] = mat[r][c]; - } - } - //Logger.INFO("Returning Rotated Layer"); - return ret; - } - catch (Throwable t) { - t.printStackTrace(); - return null; - } - } - - public boolean hasController() { - if (getControllerLocation() == null) { - return false; - } - return true; - } - - public Pair getControllerLocation() { - return mControllerLocation; - } - - public void setControllerLocation(Pair mControllerLocation) { - if (hasController()) { - return; - } - this.mControllerLocation = mControllerLocation; - } - - public LayerBlockData getDataFromCoordsWithDirection(ForgeDirection aDir, int W, int D) { - LayerBlockData g; - if (aDir == ForgeDirection.SOUTH) { - g = this.mVariantOrientations.get(2)[W][D]; - } - else if (aDir == ForgeDirection.WEST) { - g = this.mVariantOrientations.get(3)[W][D]; - } - else if (aDir == ForgeDirection.NORTH) { - g = this.mVariantOrientations.get(0)[W][D]; - } - else if (aDir == ForgeDirection.EAST) { - g = this.mVariantOrientations.get(1)[W][D]; - } - else { - g = this.mLayerData[W][D]; - } - return g; - } - - public static Pair rotateOffsetValues(ForgeDirection aDir, int X, int Z) { - int offsetX, offsetZ; - - if (aDir == ForgeDirection.NORTH) { - offsetX = X; - offsetZ = Z; - } - - else if (aDir == ForgeDirection.EAST) { - offsetX = -X; - offsetZ = Z; - } - - else if (aDir == ForgeDirection.SOUTH) { - offsetX = -X; - offsetZ = -Z; - } - - else if (aDir == ForgeDirection.WEST) { - offsetX = X; - offsetZ = -Z; - } - else { - offsetX = X; - offsetZ = Z; - } - - return new Pair(offsetX, offsetZ); - } - - - - - - - - - - - - - - - - /** - * Generates a complete {@link MultiblockLayer} from String data. - * @param aDataMap - A {@link HashMap} containing single character {@link String}s, which map to {@link Pair}<{@link Block}, {@link Integer}>s contains pairs of Blocks & Meta. - * @param aHorizontalStringRows - The horizontal rows used to map blocks to a grid. Each array slot is one vertical row going downwards as the index increases. - * @return - */ - public static MultiblockLayer generateLayerFromData(HashMap> aDataMap, String[] aHorizontalStringRows) { - AutoMap>> x = new AutoMap>>(); - - for (String u : aDataMap.keySet()) { - Pair r = aDataMap.get(u); - if (r != null) { - x.put(new Pair>(u, r)); - } - } - - //String aFreeLetters = "abdefgijklmnopqrstuvwxyz"; - /*for (Pair h : aDataMap.values()) { - String y = aFreeLetters.substring(0, 0); - aFreeLetters = aFreeLetters.replace(y.toLowerCase(), ""); - Pair> t = new Pair>(y, h); - x.put(t); - }*/ - return generateLayerFromData(x, aHorizontalStringRows); - } - - - /** - * Generates a complete {@link MultiblockLayer} from String data. - * @param aDataMap - An {@link AutoMap} which contains {@link Pair}s. These Pairs hold a single character {@link String} and another Pair. This inner pair holds a {@link Block} and an {@link Integer}. - * @param aHorizontalStringRows - An array which holds the horizontal (X/Width) string data for the layer. - * @return A complete Multiblock Layer. - */ - public static MultiblockLayer generateLayerFromData(AutoMap>> aDataMap, String[] aHorizontalStringRows) { - int width = aHorizontalStringRows[0].length(); - int depth = aHorizontalStringRows.length; - MultiblockLayer L = new MultiblockLayer(width, depth); - HashMap> K = new HashMap>(); - - //24 Free Letters - //C = Controller - //H = Hatch - String aFreeLetters = "abdefgijklmnopqrstuvwxyz"; - AutoMap>> j = new AutoMap>>(); - - //Map the keys to a Hashmap - for (Pair> t : aDataMap) { - String aKeyTemp = t.getKey(); - if (aKeyTemp.toUpperCase().equals("C")){ - j.put(t); - } - else if (aKeyTemp.toUpperCase().equals("H")){ - j.put(t); - } - else { - K.put(aKeyTemp.toLowerCase(), t.getValue()); - aFreeLetters.replace(aKeyTemp.toLowerCase(), ""); - } - } - - //Map any Invalid Characters to new ones, in case someone uses C/H. - if (j.size() > 0) { - for (Pair> h : j) { - String newKey = aFreeLetters.substring(0, 0); - K.put(newKey.toLowerCase(), h.getValue()); - aFreeLetters.replace(newKey.toLowerCase(), ""); - } - } - - int xPos = 0; - int zPos = 0; - - //Vertical Iterator - for (String s : aHorizontalStringRows) { - //Horizontal Iterator - for (int q = 0; q < s.length(); q++) { - //Get char as a String at index q. - String c = s.substring(q, q); - //if the character at c matches the character in this row, we add it to the map. - if (c.toLowerCase().equals(s.toLowerCase())) { - Pair p = K.get(c); - if (c.toLowerCase().equals("c")) { - L.addController(xPos, zPos); - } - else if (c.toLowerCase().equals("h")) { - L.addBlockForPos(p.getKey(), p.getValue(), xPos, zPos, true); - } - else { - L.addBlockForPos(p.getKey(), p.getValue(), xPos, zPos, false); - } - } - xPos++; - } - xPos = 0; - zPos++; - } - L.lock(true); - return L; - } - - - - - public static class LayerBlockData{ - - public static final LayerBlockData FALLBACK_AIR_CHECK = new LayerBlockData(Blocks.air, 0, false); - - public final Block mBlock; - public final int mMeta; - public final boolean canBeHatch; - public final Class[] mHatchClass; - - public final boolean isController; - - - public LayerBlockData(Block aBlock, int aMeta, boolean aHatch) { - this(aBlock, aMeta, aHatch, new Class[] {}); - } - - public LayerBlockData(Block aBlock, int aMeta, boolean aHatch, Class clazz) { - this(aBlock, aMeta, aHatch, new Class[] {clazz}); - } - - public LayerBlockData(Block aBlock, int aMeta, boolean aHatch, Class[] clazz) { - mBlock = aBlock; - mMeta = aMeta; - canBeHatch = aHatch; - mHatchClass = clazz; - if (clazz != null && clazz.length > 0 && clazz[0].equals(GT_MetaTileEntity_MultiBlockBase.class)) { - isController = true; - } - else { - isController = false; - } - } - - public boolean match(Block blockToTest, int metaToTest) { - - //If Both are some kind of Air Block, good enough. - if (blockToTest instanceof BlockAir && mBlock instanceof BlockAir) { - return true; - } - - if (isController && blockToTest == GregTech_API.sBlockMachines) { - return true; - } - - if (canBeHatch && blockToTest == GregTech_API.sBlockMachines) { - return true; - } - - if (blockToTest == mBlock && metaToTest == mMeta) { - return true; - } - - return false; - } - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java deleted file mode 100644 index 10909081d1..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java +++ /dev/null @@ -1,108 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.objects; - -public class MultiblockRequirements { - - public int mInputBusMinimum = 0; - public int mInputHatchMinimum = 0; - - public int mOutputBusMinimum = 0; - public int mOutputHatchMinimum = 0; - - public int mMaintMinimum = 1; - - public int mEnergyHatchMinimum = 1; - public int mDynamoHatchMinimum = 0; - - public final int mMinimumCasingCount; - - public final MultiblockBlueprint mBlueprint; - - //public static final int mControlCoreMinimum = 1; - /** - * - * @param aInputBusses - * @param aOutputBusses - * @param aInputHatches - * @param aOutputHatches - * @param aEnergyHatches - * @param aDynamoHatches - * @param aMaintHatches - * @param aBlueprint - A data object containing the structural data for this Multiblock - */ - public MultiblockRequirements(int aCasingCount, MultiblockBlueprint aBlueprint) { - mMinimumCasingCount = aCasingCount; - mBlueprint = aBlueprint; - } - - public final int getInputBusMinimum() { - return this.mInputBusMinimum; - } - - public final MultiblockRequirements setInputBusMinimum(int mInputBusMinimum) { - this.mInputBusMinimum = mInputBusMinimum; - return this; - } - - public final int getInputHatchMinimum() { - return this.mInputHatchMinimum; - } - - public final MultiblockRequirements setInputHatchMinimum(int mInputHatchMinimum) { - this.mInputHatchMinimum = mInputHatchMinimum; - return this; - } - - public final int getOutputBusMinimum() { - return this.mOutputBusMinimum; - } - - public final MultiblockRequirements setOutputBusMinimum(int mOutputBusMinimum) { - this.mOutputBusMinimum = mOutputBusMinimum; - return this; - } - - public final int getOutputHatchMinimum() { - return this.mOutputHatchMinimum; - } - - public final MultiblockRequirements setOutputHatchMinimum(int mOutputHatchMinimum) { - this.mOutputHatchMinimum = mOutputHatchMinimum; - return this; - } - - public final int getMaintMinimum() { - return this.mMaintMinimum; - } - - public final MultiblockRequirements setMaintMinimum(int mMaintMinimum) { - this.mMaintMinimum = mMaintMinimum; - return this; - } - - public final int getEnergyHatchMinimum() { - return this.mEnergyHatchMinimum; - } - - public final MultiblockRequirements setEnergyHatchMinimum(int mEnergyHatchMinimum) { - this.mEnergyHatchMinimum = mEnergyHatchMinimum; - return this; - } - - public final int getDynamoHatchMinimum() { - return this.mDynamoHatchMinimum; - } - - public final MultiblockRequirements setDynamoHatchMinimum(int mDynamoHatchMinimum) { - this.mDynamoHatchMinimum = mDynamoHatchMinimum; - return this; - } - - public final MultiblockBlueprint getBlueprint() { - return this.mBlueprint; - } - - public final int getMinimumCasingCount() { - return this.mMinimumCasingCount; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java deleted file mode 100644 index ca7cbca5f8..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java +++ /dev/null @@ -1,87 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.blueprint; - -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.xmod.gregtech.api.objects.MultiblockBlueprint; -import gtPlusPlus.xmod.gregtech.api.objects.MultiblockLayer; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; - -public class Blueprint_Generic_3x3 extends MultiblockBlueprint { - - public Blueprint_Generic_3x3(Pair aCasing, int aTextureID) { - super(3, 3, 3, 10, aTextureID); - - // Top/Bottom - MultiblockLayer a0 = new MultiblockLayer(3, 3); - Block aCasingBlock_1 = aCasing.getKey(); - int aMeta = aCasing.getValue(); - a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 0, true); - a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 1, true); - a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 2, true); - a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 0, true); - a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 1, true); - a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 2, true); - a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 0, true); - a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 1, true); - a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 2, true); - a0.lock(true); - - //Layer one - MultiblockLayer a1 = new MultiblockLayer(3, 3); - a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 0, true); - a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 1, true); - a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 2, true); - a1.addBlockForPos(aCasingBlock_1, aMeta, 1, 0, true); - a1.addBlockForPos(Blocks.air, 0, 1, 1, true); - a1.addController(1, 2); - a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 0, true); - a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 1, true); - a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 2, true); - a1.lock(true); - - this.setLayer(a0, 0); - this.setLayer(a1, 1); - this.setLayer(a0, 2); - } - - @Override - public int getMinimumInputBus() { - return 0; - } - - @Override - public int getMinimumInputHatch() { - return 0; - } - - @Override - public int getMinimumOutputBus() { - return 0; - } - - @Override - public int getMinimumOutputHatch() { - return 0; - } - - @Override - public int getMinimumInputEnergy() { - return 1; - } - - @Override - public int getMinimumOutputEnergy() { - return 0; - } - - @Override - public int getMinimumMaintHatch() { - return 1; - } - - @Override - public int getMinimumMufflers() { - return 1; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java deleted file mode 100644 index 3551172904..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java +++ /dev/null @@ -1,137 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.blueprint; - -import gregtech.api.enums.TAE; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.xmod.gregtech.api.objects.MultiblockBlueprint; -import gtPlusPlus.xmod.gregtech.api.objects.MultiblockLayer; -import net.minecraft.block.Block; - -public class Blueprint_LFTR extends MultiblockBlueprint { - - public Blueprint_LFTR() { - super(7, 4, 7, 10, TAE.GTPP_INDEX(12)); - - - Block aCasingMain = ModBlocks.blockCasingsMisc; - int aMetaCasingMain = 12; - int aMetaCasingSecondary = 13; - - - - /** - * First Layer (All edges can be Hatches, controller is centered in the front) - */ - - MultiblockLayer a0 = new MultiblockLayer(7, 7); - for (int i = 0; i < 7; i++) { - a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, 0, true); - } - for (int i = 0; i < 7; i++) { - for (int u = 1; u < 6; u++) { - a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, u, i == 0 ? true : i == 6 ? true : false); - } - } - for (int i = 0; i < 7; i++) { - if (i != 3) { - a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, 6, true); - } - else { - a0.addController(i, 6); - } - } - a0.lock(true); - - - - - /** - * Middle Layer(s) - */ - - MultiblockLayer a1 = new MultiblockLayer(7, 7); - for (int i = 0; i < 7; i++) { - a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, 0, false); - } - for (int i = 0; i < 7; i++) { - for (int u = 1; u < 6; u++) { - if (i == 0 || i == 6) - a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, u, false); - } - } - for (int i = 0; i < 7; i++) { - a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, 6, false); - - } - a1.lock(true); - - - /** - * Top Layer (All edges can be Hatches, Mufflers required in inner 3x3) - */ - - MultiblockLayer a2 = new MultiblockLayer(7, 7); - for (int i = 0; i < 7; i++) { - a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, 0, true); - } - for (int i = 0; i < 7; i++) { - for (int u = 1; u < 6; u++) { - if ((i == 2 || i == 3 || i == 4) && (u == 2 || u ==3 || u == 4)) { - a2.addMuffler(aCasingMain, aMetaCasingMain, i, u); - } - else { - a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, u, true); - } - } - } - for (int i = 0; i < 7; i++) { - a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, 6, true); - } - a2.lock(true); - - this.setLayer(a0, 0); - this.setLayer(a1, 1); - this.setLayer(a1, 2); - this.setLayer(a2, 3); - } - - @Override - public int getMinimumInputBus() { - return 0; - } - - @Override - public int getMinimumInputHatch() { - return 4; - } - - @Override - public int getMinimumOutputBus() { - return 0; - } - - @Override - public int getMinimumOutputHatch() { - return 4; - } - - @Override - public int getMinimumInputEnergy() { - return 0; - } - - @Override - public int getMinimumOutputEnergy() { - return 4; - } - - @Override - public int getMinimumMaintHatch() { - return 1; - } - - @Override - public int getMinimumMufflers() { - return 4; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java deleted file mode 100644 index e53a7e4738..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java +++ /dev/null @@ -1,11 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.requirements; - -import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements; - -public class RequirementsBasicCubic extends MultiblockRequirements { - - public RequirementsBasicCubic( ) { - super(0, null); - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java index b8f24d6c5e..7e7ecfa390 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -1,16 +1,36 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; -import gregtech.api.enums.*; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TAE; +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.interfaces.tileentity.IHasWorldObjectAndCoords; -import gregtech.api.metatileentity.implementations.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -19,19 +39,23 @@ import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemStackData; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; - -public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { +public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { private long mVoltage; private byte mTier; private int mCasing; + + private ItemStack mSchematicCache;; + private ItemStack mInputCache; + private ItemStack mOutputCache; + private GT_Recipe mCachedRecipe; + private IStructureDefinition STRUCTURE_DEFINITION = null; @Override @@ -67,24 +91,24 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { if (STRUCTURE_DEFINITION == null) { STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, })) .addElement( 'C', ofChain( ofHatchAdder( GMTE_AmazonPackager::addAmazonPackagerList, TAE.getIndexFromPage(2, 9), 1 - ), + ), onElementPass( x -> ++x.mCasing, ofBlock( ModBlocks.blockCasings3Misc, 9 + ) ) ) ) - ) .build(); } return STRUCTURE_DEFINITION; @@ -116,25 +140,25 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Amazon Warehouse") - .addInfo("This Multiblock is used for EXTREME packaging requirements") - .addInfo("Dust Schematics are inserted into the input busses") - .addInfo("If inserted into the controller, it is shared across all busses") - .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot") - .addInfo("Uncomparably fast compared to a single packager of the same tier") - .addInfo("Only uses 75% of the eu/t normally required") - .addInfo("Processes five items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfo("Supply Depot Casings", 10) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher("GT++"); + .addInfo("Controller Block for the Amazon Warehouse") + .addInfo("This Multiblock is used for EXTREME packaging requirements") + .addInfo("Dust Schematics are inserted into the input busses") + .addInfo("If inserted into the controller, it is shared across all busses") + .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot") + .addInfo("Uncomparably fast compared to a single packager of the same tier") + .addInfo("Only uses 75% of the eu/t normally required") + .addInfo("Processes 16 items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Supply Depot Casings", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher("GT++"); return tt; } @@ -146,9 +170,9 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 1)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 9)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 1))}; + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 9))}; } @@ -164,20 +188,20 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { } } + private static final FluidStack[] sNoFluids = new FluidStack[] {}; + @Override public boolean checkRecipe(ItemStack aStack) { - + //Just the best place to check this~ initFields(); - + ArrayList tItems = getStoredInputs(); if (this.getGUIItemStack() != null) { tItems.add(this.getGUIItemStack()); } - ArrayList tFluids = getStoredFluids(); ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - boolean state = checkRecipeGeneric(tItemInputs, tFluidInputs, 5 * GT_Utility.getTier(this.getMaxInputVoltage()), 75, 500, 10000); + boolean state = checkRecipeGeneric(tItemInputs, sNoFluids, 16 * GT_Utility.getTier(this.getMaxInputVoltage()), 75, 500, 10000); if (state) { @@ -204,7 +228,7 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { } } } - + return mCompleted != null && mCompleted.size() > 0; } } @@ -262,6 +286,282 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { return false; } + private ItemStack getSchematic(ItemStack[] aInputs) { + for (ItemStack aStack : aInputs) { + if (ItemList.Schematic_Dust.isStackEqual(aStack) || ItemList.Schematic_1by1.isStackEqual(aStack) || ItemList.Schematic_2by2.isStackEqual(aStack) || ItemList.Schematic_3by3.isStackEqual(aStack)) { + return aStack; + } + } + return null; + } + + private ItemStack getRecipeInput(ItemStack[] aInputs) { + for (ItemStack aStack : aInputs) { + if (!ItemList.Schematic_Dust.isStackEqual(aStack) && !ItemList.Schematic_1by1.isStackEqual(aStack) && !ItemList.Schematic_2by2.isStackEqual(aStack) && !ItemList.Schematic_3by3.isStackEqual(aStack)) { + return aStack; + } + } + return null; + } + + private boolean hasValidCache(ItemStack aStack, ItemStack aSchematic, boolean aClearOnFailure) { + if (mSchematicCache != null && mInputCache != null && mOutputCache != null && mCachedRecipe != null) { + if (GT_Utility.areStacksEqual(aStack, mInputCache) && GT_Utility.areStacksEqual(aSchematic, mSchematicCache)) { + return true; + } + } + // clear cache if it was invalid + if (aClearOnFailure) { + mSchematicCache = null; + mInputCache = null; + mOutputCache = null; + mCachedRecipe = null; + } + return false; + } + + private void cacheItem(ItemStack aSchematic, ItemStack aInputItem, ItemStack aOutputItem, GT_Recipe aRecipe) { + mSchematicCache = aSchematic.copy(); + mInputCache = aInputItem.copy(); + mOutputCache = aOutputItem.copy(); + mCachedRecipe = aRecipe; + } + + private GT_Recipe generatePackageRecipe(ItemStack aSchematic, ItemStack aInput) { + boolean tIsCached = hasValidCache(aInput, aSchematic, true); + if (tIsCached) { + ItemStack tOutput = mOutputCache.copy(); + if (tOutput != null) { + if (mCachedRecipe != null && GT_Utility.areStacksEqual(aInput, mInputCache) && GT_Utility.areStacksEqual(tOutput, mOutputCache)) { + int aRequiredInputSize = 0; + if (ItemList.Schematic_Dust.isStackEqual(aSchematic)) { + if (OrePrefixes.dustTiny.contains(aInput)) { + aRequiredInputSize = 9; + } + if (OrePrefixes.dustSmall.contains(aInput)) { + aRequiredInputSize = 4; + } + if (OrePrefixes.dust.contains(aInput)) { + aRequiredInputSize = 1; + } + } + if (ItemList.Schematic_1by1.isStackEqual(aSchematic)) { + aRequiredInputSize = 1; + } + if (ItemList.Schematic_2by2.isStackEqual(aSchematic)) { + aRequiredInputSize = 4; + } + if (ItemList.Schematic_3by3.isStackEqual(aSchematic)) { + aRequiredInputSize = 9; + } + if (aInput.stackSize >= aRequiredInputSize) { + log("Using Cached Recipe. Require: "+aRequiredInputSize+", Found: "+aInput.stackSize); + return mCachedRecipe; + } + else { + log("Not enough input"); + } + } + } + } + // We can package this + GT_Recipe aRecipe = lookupRecipe(); + log("Looking up new recipe"); + if (aRecipe != null) { + // Cache it + aInput = aInput != null ? aInput : getRecipeInput(aRecipe.mInputs); + cacheItem(aSchematic, aInput, aRecipe.mOutputs[0], aRecipe); + if (hasValidCache(aInput, aSchematic, false)) { + log("Caching Recipe"); + return aRecipe; + } + } + return null; + } + + private GT_Recipe lookupRecipe() { + ArrayList aItems = getStoredInputs(); + if (this.getGUIItemStack() != null) { + aItems.add(this.getGUIItemStack()); + } + ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, false, + gregtech.api.enums.GT_Values.V[mTier], sNoFluids, aItemInputs); + + if (tRecipe != null) { + return tRecipe; + } + return null; + } + + + + + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isPerpectOC) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + ItemStack aInput = getRecipeInput(aItemInputs); + ItemStack aSchematic = getSchematic(aItemInputs); + GT_Recipe tRecipe = generatePackageRecipe(aSchematic, aInput); + + ItemStack[] aRealInputs = new ItemStack[] {aSchematic, aInput}; + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, sNoFluids, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + mCachedRecipe = null; + log("BAD RETURN - 3 - Reset Cached Recipe"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + if (isPerpectOC) this.mMaxProgresstime /= 4; + else this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + public boolean allowPutStack(final ItemStack aStack, ItemStack schematicStack) { //If Schematic Static is not 1x1, 2x2, 3x3 if (!ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) && !ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) && !ItemList.Schematic_3by3.isStackEqual((Object) schematicStack)) { -- cgit From bf84805c93a1b92293be45a27728448a4fadbfad Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 7 Jan 2022 04:54:59 +0000 Subject: Finish work on the Elemental Duplicator. --- src/main/java/gregtech/api/util/GTPP_Recipe.java | 3 + .../core/util/minecraft/RecipeUtils.java | 14 +- .../java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 61 +++ .../xmod/gregtech/api/gui/CONTAINER_DataHatch.java | 82 +++ .../xmod/gregtech/api/gui/GUI_DataHatch.java | 41 ++ .../xmod/gregtech/api/gui/GUI_MultiMachine.java | 34 +- ...etaTileEntity_Hatch_ElementalDataOrbHolder.java | 57 ++- .../base/GregtechMeta_MultiBlockBase.java | 30 +- .../GregtechMTE_ElementalDuplicator.java | 567 +++++++++++++++++---- .../GregtechIndustrialElementDuplicator.java | 2 +- src/main/resources/assets/gregtech/lang/en_US.lang | 2 +- .../assets/gregtech/textures/gui/HatchDataOrb.png | Bin 0 -> 2831 bytes 12 files changed, 749 insertions(+), 144 deletions(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DataHatch.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DataHatch.java create mode 100644 src/main/resources/assets/gregtech/textures/gui/HatchDataOrb.png (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gregtech/api/util/GTPP_Recipe.java b/src/main/java/gregtech/api/util/GTPP_Recipe.java index 8fde47ad80..0b081adec4 100644 --- a/src/main/java/gregtech/api/util/GTPP_Recipe.java +++ b/src/main/java/gregtech/api/util/GTPP_Recipe.java @@ -364,6 +364,9 @@ public class GTPP_Recipe extends GT_Recipe implements IComparableRecipe { //Molecular Transformer Map public static final GTPP_Recipe_Map_Internal sMolecularTransformerRecipes = new GTPP_Recipe_Map_Internal(new HashSet(3), "gtpp.recipe.moleculartransformer", "Molecular Transformer", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 0, 0, 1, E, 1, E, true, true); + //Elemental Duplicator Map + public static final GTPP_Recipe_Map_Internal sElementalDuplicatorRecipes = new GTPP_Recipe_Map_Internal(new HashSet(3), "gtpp.recipe.elementaldupe", "Elemental Duplicator", null, RES_PATH_GUI + "basicmachines/Replicator", 1, 1, 0, 1, 1, E, 1, E, true, false); + //public static final GT_Recipe_Map sSimpleWasherRecipes_FakeFuckBW = new GT_Recipe_Map(new HashSet(3), "gtpp.recipe.simplewasher", "Fuck you Bart", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 1, 0, 0, 1, E, 1, E, true, false); diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index da5bc071bc..595635d411 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -703,14 +703,14 @@ public static int mInvalidID = 1; CORE.crash("Bad Shaped Recipe."); } } - Logger.INFO("Using String: "+aFullString); + Logger.RECIPE("Using String: "+aFullString); String aRow1 = aFullString.substring(0, 3); String aRow2 = aFullString.substring(3, 6); String aRow3 = aFullString.substring(6, 9); - Logger.INFO(""+aRow1); - Logger.INFO(""+aRow2); - Logger.INFO(""+aRow3); + Logger.RECIPE(""+aRow1); + Logger.RECIPE(""+aRow2); + Logger.RECIPE(""+aRow3); String[] aStringData = new String[] {aRow1, aRow2, aRow3}; Object[] aDataObject = new Object[19]; @@ -730,10 +730,10 @@ public static int mInvalidID = 1; aIndex++; } - Logger.INFO("Data Size: "+aDataObject.length); + Logger.RECIPE("Data Size: "+aDataObject.length); aDataObject = ArrayUtils.removeNulls(aDataObject); - Logger.INFO("Clean Size: "+aDataObject.length); - Logger.INFO("ArrayData: "+Arrays.toString(aDataObject)); + Logger.RECIPE("Clean Size: "+aDataObject.length); + Logger.RECIPE("ArrayData: "+Arrays.toString(aDataObject)); ShapedOreRecipe aRecipe = new ShapedOreRecipe(aOutputStack, aDataObject); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 7396915483..d42ea35a78 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -9,17 +9,22 @@ import java.util.List; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.GregTech_API; +import gregtech.api.enums.Element; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_ModHandler.RecipeBits; 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 gregtech.common.items.behaviors.Behaviour_DataOrb; import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -50,6 +55,7 @@ import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_ElementalDuplicator; import gtPlusPlus.xmod.gregtech.loaders.Gregtech_Blocks; import gtPlusPlus.xmod.gregtech.loaders.ProcessingAngleGrinder; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricButcherKnife; @@ -64,6 +70,7 @@ import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechNitroDieselFix; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; public class HANDLER_GT { @@ -167,6 +174,7 @@ public class HANDLER_GT { } RecipesToRemove.go(); convertPyroToCokeOven(); + generateElementalDuplicatorRecipes(); Meta_GT_Proxy.fixIC2FluidNames(); RecipeLoader_AlgaeFarm.generateRecipes(); if (LoadedMods.AdvancedSolarPanel) { @@ -181,6 +189,59 @@ public class HANDLER_GT { } } + + private static void generateElementalDuplicatorRecipes() { + for (GT_Recipe aRecipe : GT_Recipe_Map.sReplicatorFakeRecipes.mRecipeList) { + Object aDataOrb = aRecipe.mSpecialItems; + if (aDataOrb != null) { + ItemStack aOutput = aRecipe.mOutputs[0]; + if (aOutput != null) { + FluidStack aFluid = aRecipe.mFluidInputs[0]; + if (aFluid != null && aFluid.amount > 0) { + ItemStack tDataOrb = GregtechMTE_ElementalDuplicator.getSpecialSlotStack(aRecipe); + Materials tMaterial = Element.get(Behaviour_DataOrb.getDataName(tDataOrb)).mLinkedMaterials.get(0); + FluidStack aOutputFluid = null; + ItemStack aOutputItem = null; + if (tMaterial != null) { + boolean aUsingFluid = false; + if ((aOutputItem = GT_OreDictUnificator.get(OrePrefixes.dust, tMaterial, 1L)) == null) { + if ((aOutputItem = GT_OreDictUnificator.get(OrePrefixes.cell, tMaterial, 1L)) != null) { + aOutputFluid = GT_Utility.getFluidForFilledItem(aOutputItem, true); + aUsingFluid = true; + } + } + GTPP_Recipe aNewRecipe = new GTPP_Recipe( + false, + new ItemStack[] {}, + new ItemStack[] {!aUsingFluid ? aOutputItem : null}, + aRecipe.mSpecialItems, + null, + aRecipe.mFluidInputs, + new FluidStack[] {aUsingFluid ? aOutputFluid : null}, + aRecipe.mDuration, + aRecipe.mEUt, + aRecipe.mFluidInputs[0].amount); + GTPP_Recipe_Map.sElementalDuplicatorRecipes.add(aNewRecipe); + + Logger.INFO("[EM] Generated recipe for "+tMaterial.mLocalizedName+", Outputs "+(aUsingFluid ? "Fluid" : "Dust")); + } + } + else { + Logger.INFO("[EM] Bad UU Requirement. "+RecipeUtils.getRecipeInfo(aRecipe)); + } + } + else { + Logger.INFO("[EM] Bad Output. "+RecipeUtils.getRecipeInfo(aRecipe)); + } + } + else { + Logger.INFO("[EM] Bad Data Orb. "+RecipeUtils.getRecipeInfo(aRecipe)); + } + } + int aSize = GTPP_Recipe_Map.sElementalDuplicatorRecipes.mRecipeList.size(); + Logger.INFO("[EM] Generated "+aSize+"/"+GT_Recipe_Map.sReplicatorFakeRecipes.mRecipeList.size()+" Replicator recipes."); + } + private static void convertPyroToCokeOven() { if (ReflectionUtils.doesFieldExist(GT_Recipe.GT_Recipe_Map.class, "sPyrolyseRecipes")) { int aCount = 0; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DataHatch.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DataHatch.java new file mode 100644 index 0000000000..fe100955e0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DataHatch.java @@ -0,0 +1,82 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.enums.ItemList; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.slots.SlotIntegratedCircuit; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CONTAINER_DataHatch extends GT_ContainerMetaTile_Machine { + + public CONTAINER_DataHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 0, 53, 8)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 1, 71, 8)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 2, 89, 8)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 3, 107, 8)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 4, 53, 26)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 5, 71, 26)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 6, 89, 26)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 7, 107, 26)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 8, 53, 44)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 9, 71, 44)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 10, 89, 44)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 11, 107, 44)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 12, 53, 62)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 13, 71, 62)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 14, 89, 62)); + addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 15, 107, 62)); + addSlotToContainer(new SlotIntegratedCircuit(mTileEntity, 16, 19, 35)); + + } + + @Override + public int getSlotCount() { + return 17; + } + + @Override + public int getShiftClickSlotCount() { + return 0; + } + + @Override + public void putStackInSlot(int par1, ItemStack par2ItemStack) { + /*Logger.INFO("Slot: "+par1); + if (par1 < 16 && ItemList.Tool_DataOrb.isStackEqual(par2ItemStack)) { + super.putStackInSlot(par1, par2ItemStack); + } + if (par1 == 16 && ItemUtils.isControlCircuit(par2ItemStack)) { + super.putStackInSlot(par1, par2ItemStack); + }*/ + super.putStackInSlot(par1, par2ItemStack); + } + + @Override + public boolean canDragIntoSlot(Slot par1Slot) { + return super.canDragIntoSlot(par1Slot); + } + + public class GT_Slot_DataOrb extends Slot { + public GT_Slot_DataOrb(IInventory par1iInventory, int par2, int par3, int par4) { + super(par1iInventory, par2, par3, par4); + } + + @Override + public boolean isItemValid(ItemStack aStack) { + return ItemList.Tool_DataOrb.isStackEqual(aStack, false, true); + } + } + + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DataHatch.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DataHatch.java new file mode 100644 index 0000000000..77cb0d71a2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DataHatch.java @@ -0,0 +1,41 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; + +public class GUI_DataHatch extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GUI_DataHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_DataHatch(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "HatchDataOrb.png"); + mName = aName; + } + + public GUI_DataHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(new CONTAINER_DataHatch(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "HatchDataOrb.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(mName, 8, 4, 4210752); + /*String[] aName = mName.trim().split("\\s+"); + int aY = 4; + for (String s : aName) { + fontRendererObj.drawString(s, 120, (aY += 12), 4210752); + }*/ + } + + @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/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java index c78e7789b8..61cf59f6c9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java @@ -112,18 +112,32 @@ public class GUI_MultiMachine extends GT_GUIContainerMetaTile_Machine { mInfo.add(StatCollector.translateToLocal("GTPP.machines.output")+" "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ EnumChatFormatting.GREEN +GT_Values.VOLTAGE_NAMES[aOutputTier]); } + + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ EnumChatFormatting.GREEN + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mProgressTime/20) + EnumChatFormatting.RESET +" s / "+ EnumChatFormatting.YELLOW + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mMaxProgressTime/20) + EnumChatFormatting.RESET +" s"); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+": "+ - EnumChatFormatting.GREEN + Long.toString(aStoredEnergy) + EnumChatFormatting.RESET +" "+EU+" / "+ - EnumChatFormatting.YELLOW + Long.toString(aMaxEnergy) + EnumChatFormatting.RESET +" "+EU+""); + + + + + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+":"); + mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.GREEN + Long.toString(aStoredEnergy) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(aMaxEnergy) + EnumChatFormatting.RESET +" EU")); if (aRecipeEU != 0 && aRecipeDuration > 0) { - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+": "+ - EnumChatFormatting.RED + Integer.toString(-aRecipeEU) + EnumChatFormatting.RESET + " "+EU+"/t"); + if (aRecipeEU > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+":"); + mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.RED + Integer.toString(-aRecipeEU) + EnumChatFormatting.RESET + " EU/t/parallel")); + } + else { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.generation")+":"); + mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.GREEN + Integer.toString(aRecipeEU) + EnumChatFormatting.RESET + " EU/t/parallel")); + } mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.duration")+": "+ EnumChatFormatting.RED + Integer.toString(aRecipeDuration) + EnumChatFormatting.RESET + " ticks"); if (aRecipeSpecial > 0) { @@ -132,18 +146,16 @@ public class GUI_MultiMachine extends GT_GUIContainerMetaTile_Machine { } } - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+": "+ - EnumChatFormatting.YELLOW+Long.toString(aMaxInputVoltage)+EnumChatFormatting.RESET+ " "+EU+"/t"+EnumChatFormatting.RESET); - - mInfo.add(StatCollector.translateToLocal(StatCollector.translateToLocal("GTPP.machines.tier")+": "+ - EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(aMaxInputVoltage)]+ EnumChatFormatting.RESET)); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+":"); + mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.YELLOW+Long.toString(aMaxInputVoltage)+EnumChatFormatting.RESET+ " EU/t(*2A) "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ + EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(aMaxInputVoltage)]+ EnumChatFormatting.RESET)); mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ EnumChatFormatting.YELLOW+Float.toString(aEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + (aPollutionTick*20)+ EnumChatFormatting.RESET+"/sec"); mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + aPollutionReduction + EnumChatFormatting.RESET+" %"); - mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(aMaxParallel)+EnumChatFormatting.RESET); + //mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(aMaxParallel)+EnumChatFormatting.RESET); mInfo.add("Total Time Since Built: "); mInfo.add("" + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks)+EnumChatFormatting.RESET+" Weeks,"); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java index a892346463..9dc3f4e1d5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import java.util.ArrayList; -import gregtech.api.gui.GT_Container_4by4; -import gregtech.api.gui.GT_GUIContainer_4by4; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -11,7 +9,11 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_DataHatch; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_DataHatch; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -22,18 +24,18 @@ public class GT_MetaTileEntity_Hatch_ElementalDataOrbHolder extends GT_MetaTileE public GT_Recipe_Map mRecipeMap = null; public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 16, new String[]{ + super(aID, aName, aNameRegional, aTier, 17, new String[]{ "Holds Data Orbs for the Elemental Duplicator", CORE.GT_Tooltip }); } public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 16, aDescription, aTextures); + super(aName, aTier, 17, aDescription, aTextures); } public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 16, aDescription, aTextures); + super(aName, aTier, 17, aDescription, aTextures); } @Override @@ -80,12 +82,12 @@ public class GT_MetaTileEntity_Hatch_ElementalDataOrbHolder extends GT_MetaTileE @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); + return new CONTAINER_DataHatch(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Data Orb Repository"); + return new GUI_DataHatch(aPlayerInventory, aBaseMetaTileEntity, "Data Orb Repository"); } @Override @@ -96,13 +98,13 @@ public class GT_MetaTileEntity_Hatch_ElementalDataOrbHolder extends GT_MetaTileE } public void updateSlots() { - for (int i = 0; i < mInventory.length; i++) + for (int i = 0; i < mInventory.length-1; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; fillStacksIntoFirstSlots(); } protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < mInventory.length; i++) { + for (int i = 0; i < mInventory.length-1; i++) { if (mInventory[i] != null && mInventory[i].stackSize <= 0) { mInventory[i] = null; } @@ -130,20 +132,47 @@ public class GT_MetaTileEntity_Hatch_ElementalDataOrbHolder extends GT_MetaTileE @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; + Logger.INFO("Checking if we can pull "+aStack.getDisplayName()+" from slot "+aIndex); + if (aIndex == mInventory.length-1 && ItemUtils.isControlCircuit(aStack) && aSide == getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return false; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + Logger.INFO("Checking if we can put "+aStack.getDisplayName()+" into slot "+aIndex); + if (aIndex == mInventory.length-1 && ItemUtils.isControlCircuit(aStack) && aSide == getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return false; } public ArrayList getInventory(){ ArrayList aContents = new ArrayList(); - for (int i=0;i= 0; i--) { + if (getBaseMetaTileEntity().getStackInSlot(i) != null) + aContents.add(getBaseMetaTileEntity().getStackInSlot(i)); + } return aContents; } + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex == mInventory.length-1 && ItemUtils.isControlCircuit(aStack) && aSide == getBaseMetaTileEntity().getFrontFacing()) { + Logger.INFO("Putting "+aStack.getDisplayName()+" into slot "+aIndex); + return true; + } + return false; + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex == mInventory.length-1 && ItemUtils.isControlCircuit(aStack)) { + Logger.INFO("Pulling "+aStack.getDisplayName()+" from slot "+aIndex); + return true; + } + return false; + } + } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index c8b58ff097..e2ca92d8b0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -224,28 +224,30 @@ public abstract class GregtechMeta_MultiBlockBase 0) { - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+": "+ - EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+":"); + mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t")); } else { - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.generation")+": "+ - EnumChatFormatting.GREEN + Integer.toString(mEUt) + EnumChatFormatting.RESET + " EU/t"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.generation")+":"); + mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.GREEN + Integer.toString(mEUt) + EnumChatFormatting.RESET + " EU/t")); } mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.problems")+": "+ @@ -2452,7 +2454,7 @@ public abstract class GregtechMeta_MultiBlockBase { @@ -63,87 +79,95 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType(getMachineType()) - .addInfo("Produces Elemental Material from UU Matter") - .addInfo("This multiblock cannot be overclocked") - .addInfo("Maximum 1x of each bus/hatch.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(7, 7, 7, false) - .addController("Top Center") - .addCasingInfo("Robust Tungstensteel Machine Casing", 40) - .addCasingInfo("Tungstensteel Coils", 16) - .addCasingInfo("Molecular Containment Casing", 52) - .addCasingInfo("High Voltage Current Capacitor", 32) - .addCasingInfo("Particle Containment Casing", 4) - .addCasingInfo("Resonance Chamber I", 5) - .addCasingInfo("Modulator I", 4) - .addInputBus("Any Robust Tungstensteel Machine Casing", 1) - .addOutputBus("Any Robust Tungstensteel Machine Casing", 1) - .addEnergyHatch("Any Robust Tungstensteel Machine Casing", 1) - .addMaintenanceHatch("Any Robust Tungstensteel Machine Casing", 1) - .addMufflerHatch("Any Robust Tungstensteel Machine Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); + .addInfo("Produces Elemental Material from UU Matter") + .addInfo("This multiblock cannot be overclocked") + .addInfo("Maximum 1x of each bus/hatch.") + .addInfo("Does not require both Output Hatch & Bus") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 6, 9, true) + .addController("Top Center") + .addCasingInfo("Elemental Confinement Shell", 138) + .addCasingInfo("Matter Fabricator Casing", 24) + .addCasingInfo("Containment Casing", 24) + .addCasingInfo("Matter Generation Coil", 24) + .addCasingInfo("High Voltage Current Capacitor", 20) + .addCasingInfo("Resonance Chamber III", 24) + .addCasingInfo("Modulator III", 16) + .addOtherStructurePart("Data Orb Repository", "1x", 1) + .addInputHatch("Any 1 dot hint", 1) + .addOutputBus("Any 1 dot hint", 1) + .addOutputHatch("Any 1 dot hint", 1) + .addEnergyHatch("Any 1 dot hint", 1) + .addMaintenanceHatch("Any 1 dot hint", 1) + .addMufflerHatch("Any 1 dot hint", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); return tt; } - + private static final String STRUCTURE_PIECE_MAIN = "main"; private IStructureDefinition STRUCTURE_DEFINITION = null; - + @Override public IStructureDefinition getStructureDefinition() { - STRUCTURE_DEFINITION = null; - log("Reset Structure Def"); if (STRUCTURE_DEFINITION == null) { STRUCTURE_DEFINITION = StructureDefinition.builder() - + // h = Hatch // c = Casing - + // a = MF Casing 1 // b = Matter Gen Coil - + // d = Current Capacitor // e = Particle - + // f = Resonance III // g = Modulator III - + .addShape(STRUCTURE_PIECE_MAIN, (new String[][]{ {" ccc ", " ccccc ", " ccccccc ", "ccchhhccc", "ccch~hccc", "ccchhhccc", " ccccccc ", " ccccc ", " ccc "}, - {" ", " ", " ", " ", " ", " ", " ", " ", " "}, - {" ", " ", " ", " ", " ", " ", " ", " ", " "}, - {" ", " ", " ", " ", " ", " ", " ", " ", " "}, - {" ", " ", " ", " ", " ", " ", " ", " ", " "}, - {" ", " ", " ", " ", " ", " ", " ", " ", " "}, - {" ", " ", " ", " ", " ", " ", " ", " ", " "}, + {" cac ", " abfba ", " abfgfba ", "cbfgdgfbc", "afgdddgfa", "cbfgdgfbc", " abfgfba ", " abfba ", " cac "}, + {" cec ", " e e ", " e e ", "c d c", "e ddd e", "c d c", " e e ", " e e ", " cec "}, + {" cec ", " e e ", " e e ", "c d c", "e ddd e", "c d c", " e e ", " e e ", " cec "}, + {" cac ", " abfba ", " abfgfba ", "cbfgdgfbc", "afgdddgfa", "cbfgdgfbc", " abfgfba ", " abfba ", " cac "}, + {" ccc ", " ccccc ", " ccccccc ", "ccchhhccc", "ccchhhccc", "ccchhhccc", " ccccccc ", " ccccc ", " ccc "}, })) - - //.addElement('c', ofBlock(getCasingBlock(), getCasingMeta())) + + .addElement('a', ofBlock(getCasingBlock4(), getCasingMeta6())) + .addElement('b', ofBlock(getCasingBlock4(), getCasingMeta7())) + + .addElement('d', ofBlock(getCasingBlock2(), getCasingMeta2())) + .addElement('e', ofBlock(getCasingBlock2(), getCasingMeta3())) + + .addElement('f', ofBlock(getCasingBlock3(), getCasingMeta4())) + .addElement('g', ofBlock(getCasingBlock3(), getCasingMeta5())) .addElement('c', lazy(t -> onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) .addElement('h', lazy(t -> ofChain( ofHatchAdder(GregtechMTE_ElementalDuplicator::addGenericHatch, getCasingTextureIndex(), 1), - onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock3(), getTungstenCasingMeta())) + onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())) ))) .build(); } return STRUCTURE_DEFINITION; } - + @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN , stackSize, hintsOnly, 3, 3, 0); + buildPiece(STRUCTURE_PIECE_MAIN , stackSize, hintsOnly, 4, 4, 0); } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasing = 0; - boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); - if (this.mInputBusses.size() != 1 || this.mOutputBusses.size() != 1 || this.mEnergyHatches.size() != 1) { + boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 4, 4, 0); + if (this.mInputHatches.size() != 1 || (this.mOutputBusses.size() != 1 && this.mOutputHatches.size() !=0) || this.mEnergyHatches.size() != 1 || this.mReplicatorDataOrbHatches.size() != 1) { return false; } - return aDidBuild && mCasing >= 40 && checkHatch(); + log("Casings: "+mCasing); + return aDidBuild && mCasing >= 138 && checkHatch(); } protected static int getCasingTextureIndex() { @@ -153,33 +177,45 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase protected static Block getCasingBlock() { return ModBlocks.blockCasings5Misc; } - + protected static Block getCasingBlock2() { - return ModBlocks.blockSpecialMultiCasings2; + return ModBlocks.blockSpecialMultiCasings; } - + protected static Block getCasingBlock3() { - return GregTech_API.sBlockCasings4; + return ModBlocks.blockSpecialMultiCasings2; } - - protected static Block getCoilBlock() { - return GregTech_API.sBlockCasings5; + + protected static Block getCasingBlock4() { + return ModBlocks.blockCasingsMisc; } - + protected static int getCasingMeta() { return 3; } - + protected static int getCasingMeta2() { return 12; } - + protected static int getCasingMeta3() { return 13; } - - protected static int getTungstenCasingMeta() { - return 0; + + protected static int getCasingMeta4() { + return 2; + } + + protected static int getCasingMeta5() { + return 6; + } + + protected static int getCasingMeta6() { + return 9; + } + + protected static int getCasingMeta7() { + return 8; } public final boolean addGenericHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { @@ -188,13 +224,19 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase } else { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ return addToMachineList(aTileEntity, aBaseCasingIndex); } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { return addToMachineList(aTileEntity, aBaseCasingIndex); } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { return addToMachineList(aTileEntity, aBaseCasingIndex); } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { @@ -204,11 +246,15 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase return addToMachineList(aTileEntity, aBaseCasingIndex); } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) { - ((GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) aTileEntity).mRecipeMap = getRecipeMap(); - return addToMachineListInternal(mReplicatorDataOrbHatches, aMetaTileEntity, aBaseCasingIndex); - } + try { + ((GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return addToMachineListInternal(mReplicatorDataOrbHatches, aMetaTileEntity, aBaseCasingIndex); + } + catch (Throwable t) { + t.printStackTrace(); + } + } } - log("Bad Hatch"); return false; } @@ -223,21 +269,21 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase @Override public boolean hasSlotInGUI() { - return true; + return false; } - + @Override public boolean requiresVanillaGtGUI() { - return true; + return false; } @Override public String getCustomGUIResourceName() { - return "VacuumFreezer"; + return null; } public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe_Map.sMolecularTransformerRecipes; + return GTPP_Recipe_Map.sElementalDuplicatorRecipes; } public boolean isCorrectMachinePart(final ItemStack aStack) { @@ -246,12 +292,220 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase @Override public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(1, 100, 100); + return checkRecipeGeneric(getMaxParallelRecipes(), 100, 100); } - + + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isPerpectOC) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = null; + + try { + log("Checking "+aItemInputs.length+" Data Orbs"); + + for (int i=0;i 0 && nRecipe.mOutputs[0] != null ? nRecipe.mOutputs[0].getDisplayName() : nRecipe.mFluidOutputs[0].getLocalizedName())); + ItemStack aTempStack = getSpecialSlotStack(nRecipe); + if (aTempStack != null) { + for (ItemStack aItem : aItemInputs) { + if (nRecipe.mSpecialItems != null) { + if (GT_Utility.areStacksEqual(aTempStack, aItem, false)) { + Materials tMaterial = Element.get(Behaviour_DataOrb.getDataName(aTempStack)).mLinkedMaterials.get(0); + log("Found: "+aTempStack.getDisplayName()+" for "+tMaterial.name()); + aDataOrbStack = aTempStack; + break recipe; + } + } + } + } + } + if (aDataOrbStack != null) { + tRecipe = findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aDataOrbStack, aItemInputs); + if (tRecipe != null) { + Materials tMaterial = Element.get(Behaviour_DataOrb.getDataName(aDataOrbStack)).mLinkedMaterials.get(0); + log("Found recipe for "+tMaterial.name()); + } + else { + log("No Recipe Found"); + } + } + else { + log("Null DO"); + } + + } + catch (Throwable t) { + t.printStackTrace(); + } + + + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + if (isPerpectOC) this.mMaxProgresstime /= 4; + else this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + @Override public int getMaxParallelRecipes() { - return 1; + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); } @Override @@ -274,36 +528,157 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } - + @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); // Fix GT bug - /*if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { + if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { this.getBaseMetaTileEntity().setFrontFacing((byte) 1); - }*/ - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mReplicatorDataOrbHatches.clear(); - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public ArrayList getStoredInputs() { - ArrayList tItems = super.getStoredInputs(); - for (GT_MetaTileEntity_Hatch_ElementalDataOrbHolder tHatch : mReplicatorDataOrbHatches) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - tItems.addAll(tHatch.getInventory()); - } - } - return tItems; - } + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mReplicatorDataOrbHatches.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public ArrayList getStoredInputs() { + ArrayList tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_ElementalDataOrbHolder tHatch : mReplicatorDataOrbHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getInventory()); + } + } + tItems.removeAll(Collections.singleton(null)); + return tItems; + } + + /** + * 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 aDontCheckStackSizes if set to false will only return recipes that can be executed at least once with the provided input + * @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 GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + + GT_Recipe_Map mRecipeMap = this.getRecipeMap(); + // No Recipes? Well, nothing to be found then. + if (mRecipeMap.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 (mRecipeMap.mMinimalInputFluids > 0) { + if (aFluids == null) return null; + int tAmount = 0; + for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; + if (tAmount < mRecipeMap.mMinimalInputFluids) return null; + } + if (mRecipeMap.mMinimalInputItems > 0) { + if (aInputs == null) return null; + int tAmount = 0; + for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; + if (tAmount < mRecipeMap.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) { + ItemStack aRecipeSpecial = getSpecialSlotStack(aRecipe); + if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) && GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { + return aRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= aRecipe.mEUt ? aRecipe : null; + } + } + + // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. + if (mRecipeMap.mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) + if (tStack != null) { + Collection tRecipes = mRecipeMap.mRecipeItemMap.get(new GT_ItemStack(tStack)); + if (tRecipes != null) { + for (GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); + if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { + return tRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= tRecipe.mEUt ? tRecipe : null; + } + } + tRecipes = mRecipeMap.mRecipeItemMap.get(new GT_ItemStack(tStack, true)); + } + } + if (tRecipes != null) { + for (GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); + if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { + return tRecipe.mEnabled && aVoltage * mRecipeMap.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 (mRecipeMap.mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) + if (aFluid != null) { + Collection + tRecipes = mRecipeMap.mRecipeFluidMap.get(aFluid.getFluid()); + if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); + if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { + return tRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= tRecipe.mEUt ? tRecipe : null; + } + } + } + } + + // And nothing has been found. + return null; + } + + public static ItemStack getSpecialSlotStack(GT_Recipe aRecipe) { + ItemStack aStack = null; + if (aRecipe.mSpecialItems != null) { + if (aRecipe.mSpecialItems instanceof ItemStack[]) { + ItemStack[] aTempStackArray = (ItemStack[]) aRecipe.mSpecialItems; + aStack = aTempStackArray[0]; + } + } + return aStack; + } + + private static boolean areDataOrbsEqual(ItemStack aOrb1, ItemStack aOrb2) { + if (aOrb1 != null && aOrb2 != null) { + Materials tMaterial1 = Element.get(Behaviour_DataOrb.getDataName(aOrb1)).mLinkedMaterials.get(0); + Materials tMaterial2 = Element.get(Behaviour_DataOrb.getDataName(aOrb2)).mLinkedMaterials.get(0); + if (tMaterial1.equals(tMaterial2)) { + return true; + } + } + + return false; + } } \ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java index 9e940dff26..9301844071 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java @@ -12,7 +12,7 @@ public class GregtechIndustrialElementDuplicator { Logger.INFO("Gregtech5u Content | Registering Elemental Duplicator Multiblock."); GregtechItemList.Controller_ElementalDuplicator.set(new GregtechMTE_ElementalDuplicator(31050, "gtpp.multimachine.replicator", "Elemental Duplicator").getStackForm(1L)); - GregtechItemList.Hatch_Input_Elemental_Duplicator.set(new GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(31051, "hatch.input_bus.elementalorbholder", "Elemental Data Orb Storage", 7).getStackForm(1L)); + GregtechItemList.Hatch_Input_Elemental_Duplicator.set(new GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(31051, "hatch.input_bus.elementalorbholder", "Data Orb Repository", 7).getStackForm(1L)); } diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index bd455a2c4c..cd01a7a2aa 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -23,7 +23,7 @@ GTPP.multiblock.duration=Duration GTPP.CC.machinetier=Control Core Tier GTPP.CC.discount=EU Discount -GTPP.CC.parallel=Maximum Parallel Processing +GTPP.CC.parallel=Maximum Parallel //Tooltips for the Charger Packs GTPP.battpack.tooltip.1=Worn as a Belt within Baubles diff --git a/src/main/resources/assets/gregtech/textures/gui/HatchDataOrb.png b/src/main/resources/assets/gregtech/textures/gui/HatchDataOrb.png new file mode 100644 index 0000000000..c161ec40af Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/gui/HatchDataOrb.png differ -- cgit From 2a7860a8d7b9c31a390441c6da198a0ccbc062c6 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 7 Jan 2022 04:57:03 +0000 Subject: Updated Data Orb Repository tooltip. --- .../implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java index 9dc3f4e1d5..cf187a8b92 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java @@ -26,6 +26,8 @@ public class GT_MetaTileEntity_Hatch_ElementalDataOrbHolder extends GT_MetaTileE public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 17, new String[]{ "Holds Data Orbs for the Elemental Duplicator", + "Can insert/extract the circuit slot", + "Use Circuit to select a slot (1-16)", CORE.GT_Tooltip }); } -- cgit From 1520d231ffda1fbb11be3baea3e860bb77a02559 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 7 Jan 2022 05:06:11 +0000 Subject: Added new overlay for the Data Orb Repository. --- .../GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java | 4 ++-- .../gregtech/common/blocks/textures/TexturesGtBlock.java | 2 ++ .../textures/blocks/iconsets/Overlay_DataOrb.png | Bin 0 -> 525 bytes 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/assets/miscutils/textures/blocks/iconsets/Overlay_DataOrb.png (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java index cf187a8b92..67a6fc7aeb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java @@ -42,12 +42,12 @@ public class GT_MetaTileEntity_Hatch_ElementalDataOrbHolder extends GT_MetaTileE @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Cyber_Interface)}; + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Data_Orb)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Cyber_Interface)}; + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Data_Orb)}; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 246f016202..4f878dc074 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -431,6 +431,8 @@ public class TexturesGtBlock { // Catalyst Bus private static final CustomIcon Internal_Overlay_Bus_Catalyst = new CustomIcon("iconsets/OVERLAY_CATALYSTS"); public static final CustomIcon Overlay_Bus_Catalyst = Internal_Overlay_Bus_Catalyst; + // Data Orb Hatch + public static final CustomIcon Overlay_Hatch_Data_Orb = new CustomIcon("iconsets/Overlay_DataOrb"); // RTG Hatch private static final CustomIcon Internal_Overlay_Hatch_RTG_Off = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_OFF"); public static final CustomIcon Overlay_Hatch_RTG_Off = Internal_Overlay_Hatch_RTG_Off; diff --git a/src/main/resources/assets/miscutils/textures/blocks/iconsets/Overlay_DataOrb.png b/src/main/resources/assets/miscutils/textures/blocks/iconsets/Overlay_DataOrb.png new file mode 100644 index 0000000000..8df008a8bc Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/blocks/iconsets/Overlay_DataOrb.png differ -- cgit From 13b79706b6eddef6118453bf51782ad01b3e8328 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 9 Jan 2022 17:49:52 +0000 Subject: Partially implemented Computer Cube. Fix Multis wanting Mufflers when pollution = 0. Fix getMethodName potentially crawling too far up the stack. --- src/main/java/gtPlusPlus/core/lib/CORE.java | 49 +- .../core/util/reflect/ReflectionUtils.java | 3 + .../java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 2 + .../xmod/gregtech/api/enums/GregtechItemList.java | 1 + .../gui/computer/GT_Container_ComputerCube.java | 314 +++++++ .../gui/computer/GT_GUIContainer_ComputerCube.java | 133 +++ .../base/GregtechMeta_MultiBlockBase.java | 2 +- .../common/blocks/textures/TexturesGtBlock.java | 1 + .../computer/GT_ComputercubeDescription.java | 189 ++++ .../misc/GT_TileEntity_ComputerCube.java | 986 +++++++++++++++++++++ .../registration/gregtech/Gregtech4Content.java | 9 + .../textures/blocks/TileEntities/gt4/computer.png | Bin 0 -> 822 bytes .../assets/miscutils/textures/gui/computer/0.png | Bin 0 -> 3702 bytes .../assets/miscutils/textures/gui/computer/1.png | Bin 0 -> 4237 bytes .../assets/miscutils/textures/gui/computer/2.png | Bin 0 -> 3481 bytes .../assets/miscutils/textures/gui/computer/3.png | Bin 0 -> 4278 bytes .../assets/miscutils/textures/gui/computer/4.png | Bin 0 -> 4307 bytes .../assets/miscutils/textures/gui/computer/5.png | Bin 0 -> 4072 bytes .../assets/miscutils/textures/gui/computer/6.png | Bin 0 -> 4294 bytes .../miscutils/textures/gui/computer/Redstone.png | Bin 0 -> 2877 bytes 20 files changed, 1666 insertions(+), 23 deletions(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputercubeDescription.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java create mode 100644 src/main/resources/assets/miscutils/textures/blocks/TileEntities/gt4/computer.png create mode 100644 src/main/resources/assets/miscutils/textures/gui/computer/0.png create mode 100644 src/main/resources/assets/miscutils/textures/gui/computer/1.png create mode 100644 src/main/resources/assets/miscutils/textures/gui/computer/2.png create mode 100644 src/main/resources/assets/miscutils/textures/gui/computer/3.png create mode 100644 src/main/resources/assets/miscutils/textures/gui/computer/4.png create mode 100644 src/main/resources/assets/miscutils/textures/gui/computer/5.png create mode 100644 src/main/resources/assets/miscutils/textures/gui/computer/6.png create mode 100644 src/main/resources/assets/miscutils/textures/gui/computer/Redstone.png (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gtPlusPlus/core/lib/CORE.java b/src/main/java/gtPlusPlus/core/lib/CORE.java index d805375e2d..bb0df9d5fb 100644 --- a/src/main/java/gtPlusPlus/core/lib/CORE.java +++ b/src/main/java/gtPlusPlus/core/lib/CORE.java @@ -333,28 +333,33 @@ public class CORE { } public static final void crash(String aReason) { - Logger.INFO("=========================================================="); - Logger.INFO("[GT++ CRASH]"); - Logger.INFO("=========================================================="); - Logger.INFO("Oooops..."); - Logger.INFO("This should only happy in a development environment or when something really bad happens."); - Logger.INFO("Reason: "+aReason); - Logger.INFO("=========================================================="); - Logger.INFO("Called from: "+ReflectionUtils.getMethodName(1)); - Logger.INFO(ReflectionUtils.getMethodName(2)); - Logger.INFO(ReflectionUtils.getMethodName(3)); - Logger.INFO(ReflectionUtils.getMethodName(4)); - Logger.INFO(ReflectionUtils.getMethodName(5)); - Logger.INFO(ReflectionUtils.getMethodName(6)); - Logger.INFO(ReflectionUtils.getMethodName(7)); - Logger.INFO(ReflectionUtils.getMethodName(8)); - Logger.INFO(ReflectionUtils.getMethodName(9)); - Logger.INFO(ReflectionUtils.getMethodName(10)); - Logger.INFO(ReflectionUtils.getMethodName(11)); - Logger.INFO(ReflectionUtils.getMethodName(12)); - Logger.INFO(ReflectionUtils.getMethodName(13)); - Logger.INFO(ReflectionUtils.getMethodName(14)); - Logger.INFO(ReflectionUtils.getMethodName(15)); + try { + Logger.INFO("=========================================================="); + Logger.INFO("[GT++ CRASH]"); + Logger.INFO("=========================================================="); + Logger.INFO("Oooops..."); + Logger.INFO("This should only happy in a development environment or when something really bad happens."); + Logger.INFO("Reason: "+aReason); + Logger.INFO("=========================================================="); + Logger.INFO("Called from: "+ReflectionUtils.getMethodName(1)); + Logger.INFO(ReflectionUtils.getMethodName(2)); + Logger.INFO(ReflectionUtils.getMethodName(3)); + Logger.INFO(ReflectionUtils.getMethodName(4)); + Logger.INFO(ReflectionUtils.getMethodName(5)); + Logger.INFO(ReflectionUtils.getMethodName(6)); + Logger.INFO(ReflectionUtils.getMethodName(7)); + Logger.INFO(ReflectionUtils.getMethodName(8)); + Logger.INFO(ReflectionUtils.getMethodName(9)); + Logger.INFO(ReflectionUtils.getMethodName(10)); + Logger.INFO(ReflectionUtils.getMethodName(11)); + Logger.INFO(ReflectionUtils.getMethodName(12)); + Logger.INFO(ReflectionUtils.getMethodName(13)); + Logger.INFO(ReflectionUtils.getMethodName(14)); + Logger.INFO(ReflectionUtils.getMethodName(15)); + } + catch (Throwable t) { + t.printStackTrace(); + } FMLCommonHandler.instance().exitJava(0, true); } diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 1ef925f793..aaec2024e4 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -335,6 +335,9 @@ public class ReflectionUtils { public static String getMethodName(final int depth) { final StackTraceElement[] ste = new Throwable().getStackTrace(); //System. out.println(ste[ste.length-depth].getClassName()+"#"+ste[ste.length-depth].getMethodName()); + if (ste.length < depth) { + return "No valid stack."; + } return ste[depth+1].getMethodName(); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index d42ea35a78..999d80199f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -54,6 +54,7 @@ import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; +import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_ElementalDuplicator; import gtPlusPlus.xmod.gregtech.loaders.Gregtech_Blocks; @@ -176,6 +177,7 @@ public class HANDLER_GT { convertPyroToCokeOven(); generateElementalDuplicatorRecipes(); Meta_GT_Proxy.fixIC2FluidNames(); + GT_ComputercubeDescription.addStandardDescriptions(); RecipeLoader_AlgaeFarm.generateRecipes(); if (LoadedMods.AdvancedSolarPanel) { RecipeLoader_MolecularTransformer.run(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 7a7ae278c0..c61195a9e8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -105,6 +105,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Computer Cube Gregtech_Computer_Cube, + Gregtech_Computer_Cube_Machine, //Casings for batteries Battery_Casing_Gem_1, Battery_Casing_Gem_2, diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java new file mode 100644 index 0000000000..5c5c7961d8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java @@ -0,0 +1,314 @@ +package gtPlusPlus.xmod.gregtech.api.gui.computer; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.gui.GT_Slot_Output; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; +import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { + + public int mEUOut; + + public int mHeat; + + public int mMaxHeat; + + public int mHEM; + + public int mExplosionStrength; + + public int mEU; + + public int mProgress; + + public int mID; + + public GT_Container_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aID) { + super(aInventoryPlayer, aTileEntity); + mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + int y; + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 156 + ((this.mID == 5) ? 50 : 0), 4, false, false, 1)); + switch (this.mID) { + case 1: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 156, 86, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 156, 70, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 156, 54, false, false, 1)); + for (y = 0; y < 6; y++) { + for (int x = 0; x < 9; x++) + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, x + y * 9, 5 + x * 16, 5 + y * 16, false, false, 64)); + } + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 113, 153, 28, false, false, 64)); + break; + case 2: + addSlotToContainer(new Slot((IInventory)this.mTileEntity, 54, 8, 28)); + addSlotToContainer(new Slot((IInventory)this.mTileEntity, 55, 26, 28)); + addSlotToContainer(new GT_Slot_Output((IInventory)this.mTileEntity, 56, 134, 28)); + addSlotToContainer(new GT_Slot_Output((IInventory)this.mTileEntity, 57, 152, 28)); + break; + case 3: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 59, 122, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 60, 92, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 61, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 62, 152, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 63, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 64, 92, 35, false, false, 64)); + break; + case 4: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 59, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 60, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 61, 152, 35, false, false, 64)); + break; + case 5: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 190, 146, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 206, 146, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 59, 206, 38, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 60, 206, 56, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 61, 206, 74, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 62, 206, 92, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 63, 206, 110, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 64, 153, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 65, 169, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 66, 185, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 67, 153, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 68, 169, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 69, 185, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 70, 153, 39, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 71, 169, 39, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 72, 185, 39, false, false, 64)); + break; + case 6: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 59, 122, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 60, 92, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 61, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 62, 152, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 63, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 64, 92, 35, false, false, 64)); + break; + } + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + Logger.INFO("Clicked slot "+aSlotIndex); + if (aSlotIndex < 0) { + Logger.INFO(""); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + if (this.mID != ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode) { + Logger.INFO("This ID: "+mID+", Tile: "+((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode); + return null; + } + Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + ItemStack tStack = tSlot.getStack(); + if (tSlot == null) { + Logger.INFO("Null Slot?"); + } + else { + Logger.INFO("Good Slot!"); + if (aSlotIndex == 0) { + Logger.INFO("Slot is 0"); + if (aMouseclick == 0) { + Logger.INFO("Forward"); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeForward(); + } else { + Logger.INFO("Backwards"); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeBackward(); + } + //aPlayer.openGui(CORE.MODID, GT_BlockMetaID_Machine.getComputerCubeGUIID((TileEntity)this.mTileEntity), this.mTileEntity.getWorld(), this.mTileEntity.getXCoord(), this.mTileEntity.getYCoord(), this.mTileEntity.getZCoord()); + } else if (aSlotIndex <= 2 && this.mID == 3) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchCentrifugePageBackward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchCentrifugePageForward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 6) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchElectrolyzerPageBackward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchElectrolyzerPageForward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 4) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchFusionPageBackward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchFusionPageForward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 5) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchDescriptionPageBackward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchDescriptionPageForward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } + } else if (aSlotIndex <= 58 && this.mID == 1) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchNuclearReactor(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).loadNuclearReactor(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 3) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).saveNuclearReactor(); + } else { + if (aShifthold == 1) { + tSlot.putStack(null); + return null; + } + if (aMouseclick == 0) { + if (tStack == null) { + if (getSlot(58).getStack() != null && aSlotIndex != 58) { + tSlot.putStack(getSlot(58).getStack().copy()); + } else { + tSlot.putStack(new ItemStack(GT_TileEntity_ComputerCube.sReactorList.get(0).mItem, 1)); + } + return null; + } + for (int i = 1; i < GT_TileEntity_ComputerCube.sReactorList.size(); i++) { + if (GT_TileEntity_ComputerCube.sReactorList.get(i - 1).mItem == tStack.getItem()) { + tSlot.putStack(new ItemStack(GT_TileEntity_ComputerCube.sReactorList.get(i).mItem, 1, 0)); + if (tSlot.getStack() != null && tSlot.getStack().getItem() == GT_ModHandler.getIC2Item("reactorIsotopeCell", 1).getItem()) + tSlot.getStack().setItemDamage(tSlot.getStack().getMaxDamage() - 1); + return null; + } + } + tSlot.putStack(null); + return null; + } + if (tStack == null) + return null; + if (tStack.stackSize < tStack.getMaxStackSize()) { + tStack.stackSize++; + return null; + } + tStack.stackSize = 1; + return null; + } + } else { + Logger.INFO("Super 2"); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + } + Logger.INFO("???"); + return null; + } + + public boolean doesBindPlayerInventory() { + return (this.mID != 1 && this.mID != 5); + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + //this.mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; + this.mEUOut = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEUOut; + this.mHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHeat; + this.mMaxHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMaxHeat; + this.mHEM = (int)(((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHEM * 10000.0F); + this.mExplosionStrength = (int)(((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mExplosionStrength * 100.0F); + this.mEU = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEU; + this.mProgress = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mProgress; + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = var2.next(); + var1.sendProgressBarUpdate((Container)this, 101, this.mEUOut); + var1.sendProgressBarUpdate((Container)this, 102, this.mHeat & 0xFFFF); + var1.sendProgressBarUpdate((Container)this, 103, this.mMaxHeat & 0xFFFF); + var1.sendProgressBarUpdate((Container)this, 104, this.mHEM); + var1.sendProgressBarUpdate((Container)this, 105, this.mExplosionStrength); + var1.sendProgressBarUpdate((Container)this, 106, this.mHeat >>> 16); + var1.sendProgressBarUpdate((Container)this, 107, this.mMaxHeat >>> 16); + var1.sendProgressBarUpdate((Container)this, 108, this.mEU & 0xFFFF); + var1.sendProgressBarUpdate((Container)this, 109, this.mEU >>> 16); + var1.sendProgressBarUpdate((Container)this, 110, this.mProgress); + //var1.sendProgressBarUpdate((Container)this, 111, this.mEUOut); + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 101: + this.mEUOut = par2; + break; + case 102: + this.mHeat = this.mHeat & 0xFFFF0000 | par2; + break; + case 103: + this.mMaxHeat = this.mMaxHeat & 0xFFFF0000 | par2; + break; + case 104: + this.mHEM = par2; + break; + case 105: + this.mExplosionStrength = par2; + break; + case 106: + this.mHeat = this.mHeat & 0xFFFF | par2 << 16; + break; + case 107: + this.mMaxHeat = this.mMaxHeat & 0xFFFF | par2 << 16; + break; + case 108: + this.mEU = this.mEU & 0xFFFF0000 | par2; + case 109: + this.mEU = this.mEU & 0xFFFF | par2 << 16; + break; + case 110: + this.mProgress = par2; + break; + case 111: + //this.mID = par2; + break; + } + } + + public int getSlotStartIndex() { + return 1; + } + + public int getSlotCount() { + return (this.mID == 2) ? 4 : 0; + } + + public int getShiftClickSlotCount() { + return (this.mID == 2) ? 2 : 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java new file mode 100644 index 0000000000..0006ce8823 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java @@ -0,0 +1,133 @@ +package gtPlusPlus.xmod.gregtech.api.gui.computer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machine { + public GT_GUIContainer_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aBaseMetaTileEntity, int aID) { + super(new GT_Container_ComputerCube(aInventoryPlayer, aBaseMetaTileEntity, aID), CORE.RES_PATH_GUI + "computer/"+aID+".png"); + if (aID == 5) + this.xSize += 50; + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; + //GT_TileEntity_ComputerCube tTileEntity = (GT_TileEntity_ComputerCube) tContainer.mTileEntity; + if (tContainer != null) + switch (tContainer.mID) { + case 0 : + this.fontRendererObj.drawString("G.L.A.D.-OS", 64, 61, 16448255); + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + break; + case 1 : + this.fontRendererObj.drawString("Reactorstats:", 7, 108, 16448255); + this.fontRendererObj.drawString(toNumber(tContainer.mEU) + "EU at " + tContainer.mEUOut + "EU/t", 7, 120, 16448255); + this.fontRendererObj.drawString("HEM: " + (tContainer.mHEM / 10000.0F), 7, 128, 16448255); + this.fontRendererObj.drawString(toNumber(tContainer.mHeat) + "/" + toNumber(tContainer.mMaxHeat) + "Heat", 7, 136, 16448255); + this.fontRendererObj.drawString("Explosionpower: " + (tContainer.mExplosionStrength / 100.0F), 7, 144, 16448255); + this.fontRendererObj.drawString("Runtime: " + ((tContainer.mEUOut > 0) ? ((tContainer.mEU / tContainer.mEUOut) / 20.0F) : 0.0F) + "secs", 7, 152, 16448255); + break; + case 2 : + this.fontRendererObj.drawString("Scanner", 51, 7, 16448255); + if (tContainer.mProgress == 0) { + this.fontRendererObj.drawString("Can be used to", 51, 24, 16448255); + this.fontRendererObj.drawString("scan Seedbags", 51, 32, 16448255); + } + else { + this.fontRendererObj.drawString("Progress:", 51, 24, 16448255); + this.fontRendererObj.drawString(tContainer.mProgress + "%", 51, 32, 16448255); + } + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + break; + case 3 : + this.fontRendererObj.drawString("Centrifuge", 7, 7, 16448255); + this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size(), 7, 23, 16448255); + this.fontRendererObj.drawString("EU: " + toNumber(tContainer.mEU), 7, 31, 16448255); + break; + case 4 : + this.fontRendererObj.drawString("Fusionreactor", 7, 7, 16448255); + this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_Recipe_Map.sFusionRecipes.mRecipeList.size(), 7, 23, 16448255); + this.fontRendererObj.drawString("Start: " + toNumber(tContainer.mEU) + "EU", 7, 31, 16448255); + this.fontRendererObj.drawString("EU/t: " + toNumber(tContainer.mEUOut), 7, 39, 16448255); + this.fontRendererObj.drawString(toNumber(tContainer.mHeat) + " Ticks", 7, 47, 16448255); + if (tContainer.mEUOut < 0) { + this.fontRendererObj.drawString("IN: " + toNumber(-tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 55, 16448255); + break; + } + this.fontRendererObj.drawString("OUT: " + toNumber(tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 55, 16448255); + break; + case 5 : + if (tContainer.mMaxHeat >= 0 && tContainer.mMaxHeat < GT_ComputercubeDescription.sDescriptions.size()) + for (int i = 0; i < ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription.length; i++) { + if (i == 0) { + this.fontRendererObj.drawString(((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7, 16448255); + } + else { + this.fontRendererObj.drawString(((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7 + + 8 * i, 16448255); + } + } + break; + case 6 : + this.fontRendererObj.drawString("Electrolyzer", 7, 7, 16448255); + this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size(), 7, 23, 16448255); + this.fontRendererObj.drawString("EU: " + toNumber(tContainer.mEU), 7, 31, 16448255); + break; + } + } + + 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); + + if (mContainer != null) { + GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; + mGUIbackground = new ResourceLocation(mGUIbackgroundPath = CORE.RES_PATH_GUI + "computer/"+ ((GT_Container_ComputerCube) this.mContainer).mID + ".png"); + + switch (tContainer.mID) { + case 5 : + if (tContainer.mExplosionStrength != 0) + drawTexturedModalRect(x + 152, y + 6, 0, 166, 50, 50); + break; + } + } + + } + + public String toNumber(int aNumber) { + String tString = ""; + boolean temp = true, negative = false; + if (aNumber < 0) { + aNumber *= -1; + negative = true; + } + int i; + for (i = 1000000000; i > 0; i /= 10) { + int tDigit = aNumber / i % 10; + if (temp && tDigit != 0) + temp = false; + if (!temp) { + tString = tString + tDigit; + if (i != 1) { + int j; + for (j = i; j > 0;) { + if (j == 1) + tString = tString + ","; + j /= 1000; + } + } + } + } + if (tString.equals("")) + tString = "0"; + return negative ? ("-" + tString) : tString; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index e2ca92d8b0..ec7115cb0f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1690,7 +1690,7 @@ public abstract class GregtechMeta_MultiBlockBase 0 ? !mMufflerHatches.isEmpty() : true); } public boolean addToMachineListInternal(ArrayList aList, final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 84c0686d61..8f68b646f9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -432,6 +432,7 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Electric_Auto_Workbench_Side = new CustomIcon("TileEntities/gt4/OVERLAY_SIDE_CABINET"); + public static final CustomIcon Casing_Computer_Cube = new CustomIcon("TileEntities/gt4/computer"); public static final CustomIcon Casing_CropHarvester_Cutter = new CustomIcon("TileEntities/gt4/OVERLAY_CROP"); public static final CustomIcon Casing_CropHarvester_Boxes = new CustomIcon("TileEntities/gt4/OVERLAY_BOXES"); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputercubeDescription.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputercubeDescription.java new file mode 100644 index 0000000000..ba48df1311 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputercubeDescription.java @@ -0,0 +1,189 @@ +package gtPlusPlus.xmod.gregtech.common.computer; + +import java.util.ArrayList; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; + +public class GT_ComputercubeDescription { + public static ArrayList sDescriptions = new ArrayList(); + + public String[] mDescription; + + public ItemStack[] mStacks; + + public GT_ComputercubeDescription(String[] aDescription, ItemStack[] aStacks) { + this.mDescription = aDescription; + this.mStacks = aStacks; + sDescriptions.add(this); + } + + public static void addStandardDescriptions() { + Logger.INFO("Adding Default Description Set of the Computer Cube"); + new GT_ComputercubeDescription(new String[] { + "Lightning Rod", "Also known as the Bane of", "Alblaka. The Lightning Rod", "enables you to gain Energy", "from Lightning! To set it up", "you just need the Block", "itself, 4 HV-Transformers", "and a crapton of Ironfences,", "which you then place on top", "of it. After that you have to", + "wait for a Thunderstorm and", "when you are lucky you get", "2.5 MFSU of Energy out of", "it. If a Rod is high enough", "then Rain is also enough to", "get stroke, but with less", "probability ofcourse." }, new ItemStack[] { + GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), ItemList.Machine_IV_LightningRod.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Quantum Chest", "You want to store tons of", "Materials into your Chests", "but you hate the Item limit", "of them? Not anymore! The", "Quantum Chest is able to", "store an INFINITE* amount", "of one single Item type per", "Chest.", "This Chest stores your Items", + "like Data and ever has a", "Stack of the Item ready for", "extraction. It is compatible", "with any Item that doesnt", "have a NBT-Tag. You ask what", "NBT is? I know it, thats enough.", "* = 2147483391" }, new ItemStack[] { + null, null, null, null, ItemList.Quantum_Chest_LV.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Computer Cube", "The Device you are", "currently using. This Computer", "is running the G.L.A.D.-OS,", "which is containing many", "usefull Apps:", "- Reactor Planner", "- Seedbag Scanner", "- Recipelists for GT-Devices", "- ", + "- ", "- ", "- ", "- ", "And the Description List you", "are currently reading.", "~This Device has private Access~" }, new ItemStack[] { + null, null, null, null, GregtechItemList.Gregtech_Computer_Cube.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_ComputercubeDescription(new String[] { + "UUM-Assembler", "It's like an automatic", "Crafting Table just for UUM", "It can store 20 UUM-Recipes", "and produces those on demand", "It costs 512EU per used piece", "of Universal-Usable-Matter(TM).", "The integrated Quantum Chest", "allows it to store all your", "UUM inside it.", + "Top and Bottom are for Input,", "while the Output is on the", "Sides. The Output is designed,", "to work with RP-Managers, so", "build it into your recursive", "Autocraftingsystem.", "" }, new ItemStack[] { + null, null, null, GT_ModHandler.getIC2Item("matter", 1), new ItemStack(GregTech_API.sBlockList[1], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Sonictron", "You like Music? Then the", "Sonictron 9001 is your best", "choice! You can compose Alarms,", "Doorbell Sounds or boring", "Elevator Music, with the 64 Slots", "inside it. Just leftclick them", "to switch the Sound, rightclick", "them to switch the modulation", "and shiftclick to remove it.", + "Then apply Redstone to play", "With the mobile Version you can", "play sounds everywhere, after", "you copied them from a normal", "Sonictron via rightclicking", "Sneakrightclicking pastes", "Emits Redstone when finished." }, new ItemStack[] { + null, null, null, GregTech_API.getGregTechItem(32, 1, 0), new ItemStack(GregTech_API.sBlockList[1], 1, 6), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "L.E.S.U.", "The unlaggiest Multiblock ever!", "One Controllerblock, and as many", "'stupid' Storageblocks as you want.", "To use it, place one Controller", "and then place the LESU-Storages", "adjacent to it or other placed", "LESU-Storages. The Tier (max EU/t)", "of it depends on the amount of", "adjacent Storages. The", + "Storageblocks are NOT TileEntities,", "what means that they cause as much", "Lag as a random Dirtblock. And the", "Controller Block only checks ONCE", "for the Storages, so no", "Blockiterationlag, AT. ALL. Anyone,", "who says that they lag gets murdered!" }, new ItemStack[] { + null, null, null, new ItemStack(GregTech_API.sBlockList[0], 1, 6), new ItemStack(GregTech_API.sBlockList[1], 1, 7), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "I.D.S.U.", "The Interdimensional Storage Unit", "is a Device, which is like a", "wireless, crossdimensional and", "enderchestlike EU-Storage Block", "", "Every Player has one Network of", "these. The ID is determined by", "the Hashcode of the Name from the", "first Player, who opens it's GUI", + "", "It stores up to 1 Billion EU", "and emits EV. But you need at", "least two of them for Energy", "Transfer", "", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 8), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "A.E.S.U.", "The Adjustable Energy Storage Unit", "is like 10 MFSU and has an", "adjustable Output between 0 and", "2048EU/t. You could use it as a", "Transformer. It is Tier-IV, so", "it's basically needed to charge", "Energy Orbs and Lapotron Packs", "", "Not much else to say about it.", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 9), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Charge-O-Mat", "An automatable Charging Bench", "It puts (de-)charged Tools into", "the right Outputslots, which are", "accessible on the Sides of it.", "", "The Energy Orb inside stores enough", "to charge your QSuit almost instantly", "", "This is a Tier-V Charging Station", + "even when the Max-IN/OUT is only", "2048EU/t. It also charges your Armor", "when you are standing close to it.", "", "If you apply Redstone, then it", "decharges instead.", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 10), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Centrifuge", "This is a Machine to seperate", "Isotopes.", "", "It has a maximum Consumption Rate", "of 5EU/t, and its Maxinput is", "32EU/t. The time it needs depends", "on the Recipe you use.", "", "It needs Tin Cells for some Recipes,", + "which you put in the Top Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "", "You can pipe Lava into this Device" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 11), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Electrolyzer", "This is a Machine to seperate", "Molecules and electrolyze", "Watercells.", "", "It has a maximum Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs depends", "on the Recipe you use.", "", + "It needs Tin Cells for some Recipes,", "which you put in the Bottom Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 25), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Grinder", "This Machines purpose is to", "macerate and grind Ores.", "It can ONLY grind Ores, don't", "try regular Macerator Recipes.", "It has a fixed Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs is", "5 seconds per Ore Block", "It needs Water for most Recipes,", + "which you put in the Bottom Left Slot", "Top = Input", "Bottom = Water", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, new ItemStack(Block.field_71943_B, 1), new ItemStack(GregTech_API.sBlockList[0], 1, 14), new ItemStack(GregTech_API.sBlockList[0], 1, 13), new ItemStack(GregTech_API.sBlockList[1], 1, 28), null, null, null, null, null, + null, null, null, null });*/ + new GT_ComputercubeDescription(new String[] { + "Electric Blast Furnace", "You may know the Blast Furnace", "of Railcraft. This one works", "similar, as it can also produce", "Steel out of Iron and Coal.", "", "Its heat Capacity depends on the", "used Machine Casings for building", "it. The better they are, the more", "Heat it can achieve.", + "", "Top = Input 1", "Bottom = Input 2", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, null, null, ItemList.Machine_Multi_BlastFurnace.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_ComputercubeDescription(new String[] { + "Sawmill", "This Device turns your Logs", "into more Planks, than a normal", "Steve can produce with his Hands.", "", "Its byproduct, Wood Pulp, can be", "compressed into special Planks,", "which are burning like Charcoal.", "", "It needs Water for most Recipes,", + "which you put in the Bottom Left Slot", "Top = Input", "Water Sides = Water", "Saw Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, GT_MetaItem_Material.instance.getStack(15, 1), GT_MetaItem_Dust.instance.getStack(15, 1), new ItemStack(GregTech_API.sBlockList[1], 1, 32), null, null, null, null, null, + null, null, null, null });*/ + new GT_ComputercubeDescription(new String[] { + "Implosion Compressor", "You need to turn Dusts back", "into Gems? Or do you just want", "to make Iridium Plates?", "With a bit ITNT you can achieve", "that in this Device!", "", "We strongly recommend to use", "Flint Dust instead of Flints", "for making the ITNT.", + "", "Top = Input", "Explosion Sides = Output", "ITNT Side = ITNT Input", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, null, GT_ModHandler.getIC2Item("industrialTnt", 1, new ItemStack(net.minecraft.init.Blocks.tnt, 1)), ItemList.Machine_Multi_ImplosionCompressor.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_ComputercubeDescription(new String[] { + "Superconductor", "Expensive, but superconducting", "nearly infinite EU/p and it has", "no Cableloss!", "Do not confuse this with the", "Superconductor Item!", "", "Supercondensator", "This is a special kind of Transformer", "It allows you to convert anything down", + "to 8192 EU/t, what is like a normal HVT.", "But if you apply Redstone to it then it", "outputs friggin 1000000EU/t!!!", "", "You also need it for the Fusion Reactor.", "Some Machines will require that high", "Voltage in a short period of time." }, new ItemStack[] { + null, null, GregTech_API.getGregTechItem(3, 1, 2), new ItemStack(GregTech_API.sBlockList[1], 1, 12), new ItemStack(GregTech_API.sBlockList[1], 1, 15), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Player Detector", "This nice little Device is able", "to detect Players in a Range of", "16-Spherical Meters and a", "EU-Consumption of 2.5EU/t.", "", "It can be switched to 3 Diffrent", "Modes, to detect YOURSELF, OTHERS", "and ALL Players by Rightclicking it.", "", + "It doesnt detect regular Mobs.", "", "", "", "", "", "~This Device has private Access~" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 13), null, null, null, null, null, + null, null, null, null });*/ + new GT_ComputercubeDescription(new String[] { + "Matter Fabricator", "The Matter Fabricator is nothing", "else than a Mass Fabricator, which", "can ONLY run on Scrap and other", "Amplifiers.", "", "With the Default Config it is 100", "times more expensive than normal.", "Of course you can set the Config", "to 166666, to get your normal", + "Massfabricationrate back, or you", "could make Mass Fabrication even", "cheaper, if you really want to", "make Mass Fabrication that easy", "", "", "" }, new ItemStack[] { + null, null, null, GT_Utility.getFluidDisplayStack(FluidUtils.getUUA(1), false), ItemList.Machine_LV_Massfab.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Electric Autocrafting Tables", "These are Crafting Tables for the", "common need of autocrafting in", "Factories. One Craft needs 5000EU to", "be performed, so you have actually to", "lay Wires to it. This Table is", "unique as its also able, to give you", "the used Capsulecellcontainers, made", "by Industrial Corp, back.", "You may use that behaviour to", + "craft anything releated to chemics,", "like the 2xKNO3-Recipe for Saltpeter.", "The 5 Modes are the following:", "1. Craft Recipe, 2. All 5 Modes", "3. Craft all as single Items", "4. 2x2-Grid and 5. a 3x3-Grid.", "It accepts only 32EU/p as Input." }, new ItemStack[] { + null, null, null, null, GregtechItemList.GT4_Electric_Auto_Workbench_LV.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_ComputercubeDescription(new String[] { + "Automation with GregTech", "Translocators and Buffers are the", "newest Way to automate your Machines.", "Screw Buildcraft, these EU-wasting", "Devices are much more awesome.", "They output 32EU/t to their directed", "IN- and OUT-puts, making them usefull", "for things, like saving wires.", "Translocators are taking Stuff from", "the Block at their green Inputfacing", + "and putting it into the Block at the", "red Outputfacing. Buffers do the same,", "but the grab Items from their own", "Inventory, what makes them usefull", "as Pipe-replacement.", "Buffers also have Redstone Intelligence,", "which you can configure in their GUI." }, new ItemStack[] { + null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 19), new ItemStack(GregTech_API.sBlockList[1], 1, 18), new ItemStack(GregTech_API.sBlockList[1], 1, 17), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Silver Ore", "It's rarity is similar to Gold", "Silver can be used, to make", "Circuits cheaper, or you can use", "it for Redpowerstuff.", "", "", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, GT_OreDictUnificator.get("dustSilver", 1), GregTech_API.getGregTechItem(0, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Sapphires and Rubys", "These spawn exactly like Emeralds.", "But Rubies are found in Deserts,", "while Sapphires can be found in", "Oceans.", "", "They currently make only a cheaper", "Recipe for Energycrystals and", "Lapotroncrystals, but they are", "Redpower Compatible.", + "", "They also sometimes drop random", "other Gems, like Garnet for Ruby", "or green Sapphire for Sapphire", "in addition.", "", "" }, new ItemStack[] { + null, GregTech_API.getGregTechItem(0, 1, 32), new ItemStack(GregTech_API.sBlockList[2], 1, 3), GregTech_API.getGregTechItem(0, 1, 33), new ItemStack(GregTech_API.sBlockList[2], 1, 4), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Bauxite Ore", "The Stuff out of which you can", "produce Aluminium and also", "Titanium.", "You find this Ore in Plains and", "Forests.", "", "If you think Aluminium is useless", "then note, that mobs NEVER spawn", "ontop of an Aluminium Block", + "(Same applies also for Silver-,", "Gem- and Iridium Blocks)", "Production Chain:", "macerating Bauxite Ore", "electrolyzing 24 Bauxite Dust", "smelting Aluminium Dust in a", "Blast Furnace" }, new ItemStack[] { + new ItemStack(GregTech_API.sBlockList[0], 1, 7), GregTech_API.getGregTechItem(0, 1, 18), GregTech_API.getGregTechItem(1, 1, 18), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Titanium", "Produced by centrifuging Bauxitedust", "as a byproduct, this Material can make", "anything much more resistant against", "damage, like Explosions.", "Blocks made of Titaniumingots have a", "large Blastresistance", "", "It can also be used to craft tons of", "mixed Metal Ingots", + "", "", "", "", "", "", "" }, new ItemStack[] { + new ItemStack(GregTech_API.sBlockList[0], 1, 8), GregTech_API.getGregTechItem(0, 1, 19), GregTech_API.getGregTechItem(1, 1, 19), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Iridium Ore", "You can find it only when you", "stripmine very large Areas with", "Quarries and such. There is only", "one in every 5th-10th Chunk.", "It's even more rare in Oceans!", "", "Some people disable the UUM-Recipe", "for Iridium, for making getting it", "an Achievement.", + "", "However Iridium Ore contains traces", "of Platinum, so it's best to use the", "Industrial Grinder for this Ore.", "", "", "" }, new ItemStack[] { + null, null, GT_OreDictUnificator.get("plateAlloyIridium", 1), GT_ModHandler.getIC2Item("iridiumOre", 1), new ItemStack(GregTech_API.sBlockList[2], 1, 2), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Helium Coolant Cell", "These are just cheaper, than the", "Water based Coolant Cells, and can", "also hold six times more Heat.", "", "Helium Cells can also be used for", "making Luminators and Mininglasers", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + GregTech_API.getGregTechItem(2, 1, 6), GregTech_API.getGregTechItem(2, 1, 3), GregTech_API.getGregTechItem(34, 1, 0), GregTech_API.getGregTechItem(35, 1, 0), GregTech_API.getGregTechItem(36, 1, 0), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Destructopack", "Open its GUI via rightclick and", "dump all the useless Stuff from", "your Inventory into it, instead of", "littering Items into the World.", "", "", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(33, 1, 0), null, null, null, null, null, + null, null, null, null });*/ + new GT_ComputercubeDescription(new String[] { + "Data Orbs", "They store Data.", "", "Rightclick on a Computer Cube, to", "extract a Reactorplan", "", "Sneak-Rightclick on it, to insert", "a Reactorplan", "", "Works also with Sonictrons", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, ItemList.Tool_DataOrb.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Energy Orbs", "10Million EU in one Orb!", "", "This is a Tier-IV-Energystorage", "So a MFSU is not enough for it!", "", "Use it to create a Lapotron Pack,", "which is like an ultimate Lap Pack!", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, ItemList.Energy_LapotronicOrb.get(1), null, null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Iridium Neutron Reflector", "It's used for Fusion Reactor Coils,", "and works like a normal one", "inside a Reactor, but it's also", "INDESTRUCTIBLE*.", "", "", "", "", "", + "", "", "", "", "", "", "* = for weardown" }, new ItemStack[] { + null, null, null, null, ItemList.Neutron_Reflector.get(1), null, null, null, null, null, + null, null, null, null }); + /*new GT_ComputercubeDescription(new String[] { + "Rock Cutter", "You want to get whole Blocks, but", "your Drill is not enchantable?", "The Rock Cutter has an awesome", "SilkTouch-III-Function!", "", "It works like a Drill, but you", "get the whole Block instead of", "'macerated' Ores!", "", + "Put those Blocks into a Macerator", "and double your Diamond Income!", "", "Or better. Use the Industrial", "Grinder to get even more", "Resources!", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(46, 1, 0), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Tesla Staff", "This completly untested PvP-Weapon", "destroys electric Armor in one hit", "", "The Energy Orb inside it must be", "fully charged to let this work.", "", "We are not responsible for any", "Electrocution Damage to yourself,", "while using it.", + "", "We also dont even know, if this", "Weapon has any effect AT ALL.", "", "", "", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(47, 1, 0), null, null, null, null, null, + null, null, null, null });*/ + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java new file mode 100644 index 0000000000..dd8c79a855 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java @@ -0,0 +1,986 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.misc; + +import java.util.ArrayList; +import java.util.Collections; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +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_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_Container_ComputerCube; +import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_GUIContainer_ComputerCube; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; +import ic2.api.reactor.IReactor; +import ic2.api.reactor.IReactorComponent; +import ic2.core.Ic2Items; +import ic2.core.init.MainConfig; +import ic2.core.util.ConfigUtil; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +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.util.ChunkCoordinates; +import net.minecraft.world.World; + +public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank implements IReactor { + + public static boolean mSeedscanner = true; + + public static boolean mReactorplanner = true; + + public static ArrayList sReactorList; + + public boolean mStarted = false; + + public int mMode = 0; + + public int mHeat = 0; + + public int mEUOut = 0; + + public int mMaxHeat = 10000; + + public int mEU = 0; + + public int mProgress = 0; + + public int mEUTimer = 0; + + public int mEULast1 = 0; + + public int mEULast2 = 0; + + public int mEULast3 = 0; + + public int mEULast4 = 0; + + public float mHEM = 1.0F, mExplosionStrength = 0.0F; + + private boolean mNeedsUpdate; + + public GT_TileEntity_ComputerCube(final int aID, final String aDescription) { + super(aID, "computer.cube", "Computer Cube", 5, 114, aDescription); + } + + public GT_TileEntity_ComputerCube(final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 114, aDescription, aTextures); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + try { + return new GT_Container_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + try { + return new GT_GUIContainer_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + Logger.INFO("Did rmb."); + boolean aDidOpen = aBaseMetaTileEntity.openGUI(aPlayer); + Logger.INFO("Did open? "+aDidOpen); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_TileEntity_ComputerCube(this.mName, this.mDescription, this.mTextures); + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + ItemStack tStack = aPlayer.getCurrentEquippedItem(); + if (tStack != null && ItemList.Tool_DataOrb.isStackEqual(tStack)) { + return false; + } + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aDirection) { + return true; + } + + @Override + public long maxAmperesIn() { + return 4; + } + + @Override + public long maxEUInput() { + return GT_Values.V[2]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[5] * 1024; + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public int getSizeInventory() { + return 114; + } + + @Override + public boolean isValidSlot(int aIndex) { + return (aIndex > 53 && aIndex < 58); + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + public void saveNuclearReactor() { + for (int i = 0; i < 54; i++) { + if (this.mInventory[i] == null) { + this.mInventory[i + 59] = null; + } + else { + this.mInventory[i + 59] = this.mInventory[i].copy(); + } + } + } + + public void loadNuclearReactor() { + for (int i = 0; i < 54; i++) { + if (this.mInventory[i + 59] == null) { + this.mInventory[i] = null; + } + else { + this.mInventory[i] = this.mInventory[i + 59].copy(); + } + } + } + + public int getXCoord() { + return this.getBaseMetaTileEntity().getXCoord(); + } + + public int getYCoord() { + return this.getBaseMetaTileEntity().getYCoord(); + } + + public int getZCoord() { + return this.getBaseMetaTileEntity().getZCoord(); + } + + public void reset() { + this.mEU = 0; + this.mHeat = 0; + this.mEUOut = 0; + this.mMaxHeat = 10000; + this.mHEM = 1.0F; + this.mExplosionStrength = 0.0F; + this.mProgress = 0; + this.mInventory[113] = null; + int i; + for (i = 0; i < 54; i++) { + this.mInventory[i] = null; + this.mInventory[i + 59] = null; + } + for (i = 54; i < 58; i++) { + if (this.mInventory[i] != null) { + if (!this.getWorld().isRemote) + this.getWorld().spawnEntityInWorld((Entity) new EntityItem(this.getWorld(), this.getXCoord() + 0.5D, this.getYCoord() + 0.5D, this.getZCoord() + 0.5D, this.mInventory[i])); + this.mInventory[i] = null; + } + } + } + + public void switchModeForward() { + this.mMode = (this.mMode + 1) % 7; + switchMode(); + } + + public void switchModeBackward() { + this.mMode--; + if (this.mMode < 0) + this.mMode = 6; + switchMode(); + } + + private void switchMode() { + reset(); + if (this.mMode == 1 && !mReactorplanner) { + switchMode(); + return; + } + if (this.mMode == 2 && !mSeedscanner) { + switchMode(); + return; + } + if (this.mMode == 3) { + showCentrifugeRecipe(0); + } + if (this.mMode == 4) { + showFusionRecipe(0); + } + if (this.mMode == 5) { + showDescription(0); + } + if (this.mMode == 6) { + showElectrolyzerRecipe(0); + } + //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), (GregTech_API.sBlockList[1]), 10, this.mMode); + //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), (GregTech_API.sBlockList[1]), 11, this.mMaxHeat); + } + + public void showDescription(int aIndex) { + this.mExplosionStrength = 0.0F; + if (GT_ComputercubeDescription.sDescriptions.isEmpty()) { + return; + } + if (aIndex >= GT_ComputercubeDescription.sDescriptions.size() || aIndex < 0) + aIndex = 0; + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[0] == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[0].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[1] == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[1].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[2] == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[2].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[3] == null) { + this.mInventory[62] = null; + } + else { + this.mInventory[62] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[3].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[4] == null) { + this.mInventory[63] = null; + } + else { + this.mInventory[63] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[4].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[5] == null) { + this.mInventory[64] = null; + } + else { + this.mInventory[64] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[5].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[6] == null) { + this.mInventory[65] = null; + } + else { + this.mInventory[65] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[6].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[7] == null) { + this.mInventory[66] = null; + } + else { + this.mInventory[66] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[7].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[8] == null) { + this.mInventory[67] = null; + } + else { + this.mInventory[67] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[8].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[9] == null) { + this.mInventory[68] = null; + } + else { + this.mInventory[68] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[9].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[10] == null) { + this.mInventory[69] = null; + } + else { + this.mInventory[69] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[10].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[11] == null) { + this.mInventory[70] = null; + } + else { + this.mInventory[70] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[11].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[12] == null) { + this.mInventory[71] = null; + } + else { + this.mInventory[71] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[12].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[13] == null) { + this.mInventory[72] = null; + } + else { + this.mInventory[72] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[13].copy(); + this.mExplosionStrength = 100.0F; + } + this.mMaxHeat = aIndex; + //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockList[1], 11, this.mMaxHeat); + } + + public void switchDescriptionPageForward() { + if (++this.mMaxHeat >= GT_ComputercubeDescription.sDescriptions.size()) + this.mMaxHeat = 0; + showDescription(this.mMaxHeat); + } + + public void switchDescriptionPageBackward() { + if (--this.mMaxHeat < 0) + this.mMaxHeat = GT_ComputercubeDescription.sDescriptions.size() - 1; + showDescription(this.mMaxHeat); + } + + public void showCentrifugeRecipe(int aIndex) { + /* + if (aIndex >= GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size() || aIndex < 0) + aIndex = 0; + GT_Recipe tRecipe = GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mInput1 == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = tRecipe.mInput1.copy(); + } + if (tRecipe.mInput2 == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = tRecipe.mInput2.copy(); + } + if (tRecipe.mOutput1 == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = tRecipe.mOutput1.copy(); + } + if (tRecipe.mOutput2 == null) { + this.mInventory[62] = null; + } + else { + this.mInventory[62] = tRecipe.mOutput2.copy(); + } + if (tRecipe.mOutput3 == null) { + this.mInventory[63] = null; + } + else { + this.mInventory[63] = tRecipe.mOutput3.copy(); + } + if (tRecipe.mOutput4 == null) { + this.mInventory[64] = null; + } + else { + this.mInventory[64] = tRecipe.mOutput4.copy(); + } + this.mEU = tRecipe.mDuration * 5; + this.mMaxHeat = aIndex; + } + this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + */} + + public void switchCentrifugePageForward() { + if (++this.mMaxHeat >= GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size()) + this.mMaxHeat = 0; + // showCentrifugeRecipe(this.mMaxHeat); + } + + public void switchCentrifugePageBackward() { + if (--this.mMaxHeat < 0) + this.mMaxHeat = GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size() - 1; + // showCentrifugeRecipe(this.mMaxHeat); + } + + public void showElectrolyzerRecipe(int aIndex) { + /* + if (aIndex >= GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size() || aIndex < 0) + aIndex = 0; + GT_Recipe tRecipe = GT_Recipe_Map.sElectrolyzerRecipes.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mInput1 == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = tRecipe.mInput1.copy(); + } + if (tRecipe.mInput2 == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = tRecipe.mInput2.copy(); + } + if (tRecipe.mOutput1 == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = tRecipe.mOutput1.copy(); + } + if (tRecipe.mOutput2 == null) { + this.mInventory[62] = null; + } + else { + this.mInventory[62] = tRecipe.mOutput2.copy(); + } + if (tRecipe.mOutput3 == null) { + this.mInventory[63] = null; + } + else { + this.mInventory[63] = tRecipe.mOutput3.copy(); + } + if (tRecipe.mOutput4 == null) { + this.mInventory[64] = null; + } + else { + this.mInventory[64] = tRecipe.mOutput4.copy(); + } + this.mEU = tRecipe.mDuration * tRecipe.mEUt; + this.mMaxHeat = aIndex; + } + this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + */} + + public void switchElectrolyzerPageForward() { + if (++this.mMaxHeat >= GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size()) + this.mMaxHeat = 0; + showElectrolyzerRecipe(this.mMaxHeat); + } + + public void switchElectrolyzerPageBackward() { + if (--this.mMaxHeat < 0) + this.mMaxHeat = GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size() - 1; + showElectrolyzerRecipe(this.mMaxHeat); + } + + public static ArrayList sFusionReactorRecipes = new ArrayList(); + + public void showFusionRecipe(int aIndex) { + + if (sFusionReactorRecipes.isEmpty()) { + for (GT_Recipe aRecipe : GT_Recipe_Map.sFusionRecipes.mRecipeList) { + sFusionReactorRecipes.add(aRecipe); + } + Collections.sort(sFusionReactorRecipes); + } + + if (aIndex >= sFusionReactorRecipes.size() || aIndex < 0) { + aIndex = 0; + } + GT_Recipe tRecipe = sFusionReactorRecipes.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mFluidInputs[0] == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[0], true); + } + if (tRecipe.mFluidInputs[1] == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[1], true); + } + if (tRecipe.mFluidOutputs[0] == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[0], true); + } + this.mEU = tRecipe.mSpecialValue; + this.mEUOut = tRecipe.mEUt; + this.mHeat = tRecipe.mDuration; + this.mMaxHeat = aIndex; + } + //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockList[1], 11, this.mMaxHeat); + } + + public void switchFusionPageForward() { + if (++this.mMaxHeat >= sFusionReactorRecipes.size()) + this.mMaxHeat = 0; + showFusionRecipe(this.mMaxHeat); + } + + public void switchFusionPageBackward() { + if (--this.mMaxHeat < 0) + this.mMaxHeat = sFusionReactorRecipes.size() - 1; + showFusionRecipe(this.mMaxHeat); + } + + public void switchNuclearReactor() { + if (this.mStarted) { + stopNuclearReactor(); + } + else { + startNuclearReactor(); + } + } + + public void startNuclearReactor() { + this.mStarted = true; + this.mHeat = 0; + this.mEU = 0; + } + + public void stopNuclearReactor() { + this.mStarted = false; + } + + public void storeAdditionalData(NBTTagCompound aNBT) { + aNBT.setInteger("mMode", this.mMode); + aNBT.setInteger("mProgress", this.mProgress); + aNBT.setBoolean("mStarted", this.mStarted); + aNBT.setInteger("mEU", this.mEU); + aNBT.setInteger("mHeat", this.mHeat); + aNBT.setInteger("mEUOut", this.mEUOut); + aNBT.setInteger("mMaxHeat", this.mMaxHeat); + aNBT.setFloat("mHEM", this.mHEM); + aNBT.setFloat("mExplosionStrength", this.mExplosionStrength); + } + + public void getAdditionalData(NBTTagCompound aNBT) { + this.mMode = aNBT.getInteger("mMode"); + this.mProgress = aNBT.getInteger("mProgress"); + this.mStarted = aNBT.getBoolean("mStarted"); + this.mEU = aNBT.getInteger("mEU"); + this.mHeat = aNBT.getInteger("mHeat"); + this.mEUOut = aNBT.getInteger("mEUOut"); + this.mMaxHeat = aNBT.getInteger("mMaxHeat"); + this.mHEM = aNBT.getFloat("mHEM"); + this.mExplosionStrength = aNBT.getFloat("mExplosionStrength"); + } + + public void onFirstTickUpdate() { + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (sReactorList == null) { + sReactorList = new ArrayList(); + + String[] aIc2Items = new String[]{ + "reactorUraniumSimple", "reactorUraniumDual", "reactorUraniumQuad", /*"reactorIsotopeCell",*/ "reactorReflector", "reactorReflectorThick", "reactorCoolantSimple", + "reactorCoolantTriple", "reactorCoolantSix", "reactorCondensator", "reactorCondensatorLap", "reactorPlating", "reactorPlatingHeat", "reactorPlatingExplosive", "reactorVent", + "reactorVentCore", "reactorVentGold", "reactorVentSpread", "reactorVentDiamond", "reactorHeatSwitch", "reactorHeatSwitchCore", "reactorHeatSwitchSpread", + "reactorHeatSwitchDiamond", /*"reactorHeatpack",*/ + }; + + for (String aItem : aIc2Items) { + ItemStack aStack = GT_ModHandler.getIC2Item(aItem, 1); + if (!ItemUtils.checkForInvalidItems(aStack)) { + Logger.INFO("Unable to find IC2 Item: " + aItem); + CORE.crash("Unable to find IC2 Item: " + aItem); + } + else { + sReactorList.add(new GT_ItemStack(aStack.copy())); + } + } + + ItemList[] aGtItems = new ItemList[]{ + ItemList.Neutron_Reflector, ItemList.Moxcell_1, ItemList.Moxcell_2, ItemList.Moxcell_4, ItemList.Uraniumcell_1, ItemList.Uraniumcell_2, ItemList.Uraniumcell_4, + ItemList.NaquadahCell_1, ItemList.NaquadahCell_2, ItemList.NaquadahCell_4, ItemList.ThoriumCell_1, ItemList.ThoriumCell_2, ItemList.ThoriumCell_4, ItemList.Reactor_Coolant_He_1, + ItemList.Reactor_Coolant_He_3, ItemList.Reactor_Coolant_He_6, ItemList.Reactor_Coolant_NaK_1, ItemList.Reactor_Coolant_NaK_3, ItemList.Reactor_Coolant_NaK_6, + }; + + for (ItemList aItem : aGtItems) { + sReactorList.add(new GT_ItemStack(aItem.get(1))); + } + + } + + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if(this.getBaseMetaTileEntity().isClientSide()) { + this.getWorld().markBlockForUpdate(this.getXCoord(), this.getYCoord(), this.getZCoord()); + this.mNeedsUpdate = false; + } + else { + this.mNeedsUpdate = false; + } + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mMode == 2) { + if (this.mInventory[55] == null) { + this.mInventory[55] = this.mInventory[54]; + this.mInventory[54] = null; + } + if (this.mInventory[57] == null) { + this.mInventory[57] = this.mInventory[56]; + this.mInventory[56] = null; + } + + if (mSeedscanner && this.mInventory[55] != null && GT_Utility.areStacksEqual(this.mInventory[55], Ic2Items.cropSeed, true) && this.mInventory[55].getTagCompound() != null) { + if (this.mInventory[55].getTagCompound().getByte("scan") < 4) { + if (this.mProgress >= 100) { + this.mInventory[55].getTagCompound().setByte("scan", (byte) 4); + this.mProgress = 0; + } + else if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(100, false)) { + this.mProgress++; + } + } + else { + this.mProgress = 0; + if (this.mInventory[56] == null) { + this.mInventory[56] = this.mInventory[55]; + this.mInventory[55] = null; + } + } + } + else { + this.mProgress = 0; + if (this.mInventory[56] == null) { + this.mInventory[56] = this.mInventory[55]; + this.mInventory[55] = null; + } + } + } + if (this.mMode == 1 && mReactorplanner && this.mStarted && this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(32, false)) + for (int i = 0; i < 25 && this.mStarted; i++) { + this.mEUOut = 0; + this.mMaxHeat = 10000; + this.mHEM = 1.0F; + this.mExplosionStrength = 10.0F; + float tMultiplier = 1.0F; + for (int y = 0; y < 6; y++) { + for (int x = 0; x < 9; x++) { + ItemStack tStack = getStackInSlot(x + y * 9); + if (tStack != null) + if (tStack.getItem() instanceof IReactorComponent) { + IReactorComponent tComponent = (IReactorComponent) tStack.getItem(); + tComponent.processChamber(this, tStack, x, y, false); //TODO + float tInfluence = ((IReactorComponent) tStack.getItem()).influenceExplosion(this, tStack); + if (tInfluence > 0.0F && tInfluence < 1.0F) { + tMultiplier *= tInfluence; + } + else { + this.mExplosionStrength += tInfluence; + } + } + else if (tStack.isItemEqual(GT_ModHandler.getIC2Item("nearDepletedUraniumCell", 1)) || tStack.isItemEqual(GT_ModHandler.getIC2Item("reEnrichedUraniumCell", 1))) { + stopNuclearReactor(); + } + else { + setInventorySlotContents(x + y * 9, (ItemStack) null); + } + } + } + this.mEUOut *= getReactorEUOutput(); + if ((this.mEUOut == 0 && this.mEUTimer++ > 20) || this.mHeat >= this.mMaxHeat) + stopNuclearReactor(); + if (this.mEUOut != 0) + this.mEUTimer = 0; + this.mExplosionStrength *= this.mHEM * tMultiplier; + this.mEU += this.mEUOut * 20; + int tEU = this.mEULast1; + this.mEULast1 = this.mEULast2; + this.mEULast2 = this.mEULast3; + this.mEULast3 = this.mEULast4; + this.mEULast4 = this.mEUOut; + this.mEUOut = (this.mEUOut + this.mEULast1 + this.mEULast2 + this.mEULast3 + tEU) / 5; + } + if (aTick % 20L == 0L) { + //this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 10, this.mMode); + //this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + } + } + } + + private int getReactorEUOutput() { + return MathUtils.roundToClosestInt(getReactorEnergyOutput() * 5.0F * ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear")); + } + + @Override + public void receiveClientEvent(byte aEventID, byte aValue) { + super.receiveClientEvent(aEventID, aValue); + if (this.getWorld().isRemote) + switch (aEventID) { + case 10 : + this.mNeedsUpdate = true; + this.mMode = aValue; + break; + case 11 : + this.mMaxHeat = aValue; + break; + } + return; + } + + @Override + public void onValueUpdate(byte aValue) { + super.onValueUpdate(aValue); + this.mNeedsUpdate = true; + } + + @Override + public void onMachineBlockUpdate() { + super.onMachineBlockUpdate(); + this.mNeedsUpdate = true; + } + + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return (this.mMode == 2) ? ((i == 54 || i == 55)) : false; + } + + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return (this.mMode == 2) ? ((i == 56 || i == 57)) : false; + } + + public String getInvName() { + return "GregTech_Computercube"; + } + + public int getTexture(int aSide, int aMeta) { + switch (this.mMode) { + case 0 : + return 8; + case 1 : + return 46; + case 2 : + return 45; + } + return 48; + } + + @Override + public ChunkCoordinates getPosition() { + return new ChunkCoordinates(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); + } + + @Override + public int getHeat() { + return this.mHeat; + } + + @Override + public void setHeat(int aHeat) { + this.mHeat = aHeat; + } + + @Override + public int addHeat(int aAmount) { + this.mHeat += aAmount; + return this.mHeat; + } + + @Override + public int getMaxHeat() { + return this.mMaxHeat; + } + + @Override + public void setMaxHeat(int aMaxHeat) { + this.mMaxHeat = aMaxHeat; + } + + @Override + public float getHeatEffectModifier() { + return this.mHEM; + } + + @Override + public void setHeatEffectModifier(float aHEM) { + this.mHEM = aHEM; + } + + + public int addOutput(int aEnergy) { + this.mEUOut += aEnergy; + return this.mEUOut; + } + + @Override + public ItemStack getItemAt(int x, int y) { + if (x < 0 || x > 8 || y < 0 || y > 5) + return null; + return getStackInSlot(x + y * 9); + } + + @Override + public void setItemAt(int x, int y, ItemStack aStack) { + setInventorySlotContents(x + y * 9, aStack); + } + + @Override + public void explode() { + stopNuclearReactor(); + } + + @Override + public int getTickRate() { + return 1; + } + + @Override + public boolean produceEnergy() { + return true; + } + + public int getProgress() { + return this.mProgress; + } + + public int getMaxProgress() { + return (this.mProgress > 0) ? 100 : 0; + } + + @Override + public float addOutput(float aEnergy) { + this.mEUOut = (int) (this.mEUOut + aEnergy); + return this.mEUOut; + } + + @Override + public World getWorld() { + return this.getBaseMetaTileEntity().getWorld(); + } + + @Override + public void addEmitHeat(int heat) { + + } + + @Override + public float getReactorEnergyOutput() { + return this.mEUOut; + } + + @Override + public double getReactorEUEnergyOutput() { + return 0; + } + + @Override + public void setRedstoneSignal(boolean redstone) { + + } + + @Override + public boolean isFluidCooled() { + return false; + } + + + + @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; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getSides(i); + rTextures[2][i + 1] = this.getSides(i); + rTextures[3][i + 1] = this.getSides(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getSides(i); + rTextures[7][i + 1] = this.getSides(i); + rTextures[8][i + 1] = this.getSides(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_3)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Computer_Cube)}; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java index 6741a3e433..5c34ce70fe 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java @@ -5,6 +5,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricAutoWorkbench; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; @@ -12,6 +13,7 @@ import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_CropHarvestor; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_ThermalBoiler; +import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube; import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneButtonPanel; import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneLamp; import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneStrengthDisplay; @@ -40,9 +42,16 @@ public class Gregtech4Content { basic(); automation(); redstone(); + computer(); } } + + private static void computer() { + Logger.INFO("Gregtech 4 Content | Registering Computer Cube."); + GregtechItemList.Gregtech_Computer_Cube_Machine.set(new GT_TileEntity_ComputerCube(31130, "C-O-M-P-U-T-E-R").getStackForm(1L)); + } + private static void workbenches() { // Gregtech 4 Workbenches Logger.INFO("Gregtech 4 Content | Registering Workbenches."); diff --git a/src/main/resources/assets/miscutils/textures/blocks/TileEntities/gt4/computer.png b/src/main/resources/assets/miscutils/textures/blocks/TileEntities/gt4/computer.png new file mode 100644 index 0000000000..76ebee594c Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/blocks/TileEntities/gt4/computer.png differ diff --git a/src/main/resources/assets/miscutils/textures/gui/computer/0.png b/src/main/resources/assets/miscutils/textures/gui/computer/0.png new file mode 100644 index 0000000000..8f8a4a8f75 Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/gui/computer/0.png differ diff --git a/src/main/resources/assets/miscutils/textures/gui/computer/1.png b/src/main/resources/assets/miscutils/textures/gui/computer/1.png new file mode 100644 index 0000000000..249e8fc4f1 Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/gui/computer/1.png differ diff --git a/src/main/resources/assets/miscutils/textures/gui/computer/2.png b/src/main/resources/assets/miscutils/textures/gui/computer/2.png new file mode 100644 index 0000000000..a128743fef Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/gui/computer/2.png differ diff --git a/src/main/resources/assets/miscutils/textures/gui/computer/3.png b/src/main/resources/assets/miscutils/textures/gui/computer/3.png new file mode 100644 index 0000000000..bf176cd722 Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/gui/computer/3.png differ diff --git a/src/main/resources/assets/miscutils/textures/gui/computer/4.png b/src/main/resources/assets/miscutils/textures/gui/computer/4.png new file mode 100644 index 0000000000..93156df2fe Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/gui/computer/4.png differ diff --git a/src/main/resources/assets/miscutils/textures/gui/computer/5.png b/src/main/resources/assets/miscutils/textures/gui/computer/5.png new file mode 100644 index 0000000000..eb4dd0d086 Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/gui/computer/5.png differ diff --git a/src/main/resources/assets/miscutils/textures/gui/computer/6.png b/src/main/resources/assets/miscutils/textures/gui/computer/6.png new file mode 100644 index 0000000000..0eda26a397 Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/gui/computer/6.png differ diff --git a/src/main/resources/assets/miscutils/textures/gui/computer/Redstone.png b/src/main/resources/assets/miscutils/textures/gui/computer/Redstone.png new file mode 100644 index 0000000000..cd287a0a2e Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/gui/computer/Redstone.png differ -- cgit From 0540e62299cb368a3c430493da0327dba1cf23f1 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 13 Jan 2022 00:53:00 +0000 Subject: Hopefully make Wireless Chargers more responsive. Added more information to Hi-Amp xformers. --- .../base/GregtechMetaTransformerHiAmp.java | 1 + .../gregtech/common/helpers/ChargingHelper.java | 46 ++++++++++---------- .../basic/GregtechMetaWirelessCharger.java | 49 ++++++++++++++-------- 3 files changed, 54 insertions(+), 42 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java index 768a57f8b2..d0021f8358 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java @@ -87,6 +87,7 @@ public class GregtechMetaTransformerHiAmp extends GT_MetaTileEntity_Transformer public String[] getDescription() { return new String[] { this.mDescription, "Accepts 4A and outputs 16A", + "Toggle 2A/8A half-mode with Screwdriver", CORE.GT_Tooltip}; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 70c7b2da23..be9db74eef 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -6,17 +6,11 @@ import java.util.UUID; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_ModHandler; import gregtech.common.items.GT_MetaGenerated_Item_01; import gregtech.common.items.GT_MetaGenerated_Item_02; import gregtech.common.items.GT_MetaGenerated_Tool_01; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -25,14 +19,16 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; -import ic2.api.info.Info; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; public class ChargingHelper { - private static Map> mValidPlayers = new HashMap>(); + private static Map> mValidPlayers = new HashMap>(); protected static Map mChargerMap = new HashMap(); private int mTickTimer = 0; private final int mTickMultiplier = 20; @@ -58,7 +54,7 @@ public class ChargingHelper { long mVoltage = 0; long mEuStored = 0; - if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(mPlayerMan)){ + if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(mPlayerMan.getDisplayName())){ InventoryPlayer mPlayerInventory = mPlayerMan.inventory; ItemStack[] mArmourContents = mPlayerInventory.armorInventory.clone(); ItemStack[] mInventoryContents = mPlayerInventory.mainInventory.clone(); @@ -70,30 +66,30 @@ public class ChargingHelper { mEuStored = mEntityTemp.getEUVar(); if (mVoltage > 0 && mEuStored >= mVoltage){ - Map LR = mEntityTemp.getLongRangeMap(); - Map LO = mEntityTemp.getLocalMap(); + Map LR = mEntityTemp.getLongRangeMap(); + Map LO = mEntityTemp.getLocalMap(); long mStartingEu = mEntityTemp.getEUVar(); long mCurrentEu = mEntityTemp.getEUVar(); long mEuUsed = 0; if (mEntityTemp.getMode() == 0){ - if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + if (!LR.isEmpty() && LR.containsKey(mPlayerMan.getDisplayName())){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); } } else if (mEntityTemp.getMode() == 1){ - if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ + if (!LO.isEmpty() && LO.containsKey(mPlayerMan.getDisplayName())){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); } } else { - if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + if (!LR.isEmpty() && LR.containsKey(mPlayerMan.getDisplayName())){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); } - if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ + if (!LO.isEmpty() && LO.containsKey(mPlayerMan.getDisplayName())){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); } @@ -136,13 +132,13 @@ public class ChargingHelper { catch (Throwable t){ //Utils.LOG_WARNING("State of Wireless Charger changed in an invalid way, this prevented a crash."); - - if (!mChargerMap.isEmpty()){ - for (GregtechMetaWirelessCharger r : mChargerMap.values()){ - if (r == null){ - mChargerMap.remove(r); + if (!mChargerMap.isEmpty()){ + for (BlockPos aPos : mChargerMap.keySet()) { + GregtechMetaWirelessCharger r = mChargerMap.get(aPos); + if (r == null || r.getBaseMetaTileEntity().isInvalidTileEntity()){ + mChargerMap.remove(aPos); } - } + } } //t.printStackTrace(); } @@ -163,7 +159,7 @@ public class ChargingHelper { } } else { - return false; + return true; } } @@ -189,14 +185,14 @@ public class ChargingHelper { return false; } Logger.WARNING("trying to map new player"); - if (mValidPlayers.containsKey(mPlayer)){ + if (mValidPlayers.containsKey(mPlayer.getDisplayName())){ Logger.WARNING("Key contains player already?"); return false; } else { Logger.WARNING("key not found, adding"); Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); - if (mValidPlayers.put(mPlayer, mEntry) == null){ + if (mValidPlayers.put(mPlayer.getDisplayName(), mEntry) == null){ Logger.WARNING("Added a Player to the Tick Map."); return true; } @@ -212,7 +208,7 @@ public class ChargingHelper { return false; } Logger.WARNING("trying to remove player from map"); - if (mValidPlayers.containsKey(mPlayer)){ + if (mValidPlayers.containsKey(mPlayer.getDisplayName())){ Logger.WARNING("key found, removing"); Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); if (mValidPlayers.remove(mPlayer, mEntry)){ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index ffaa77a0be..b50031ac00 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -17,6 +17,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.EntityUtils; @@ -64,11 +65,11 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { return this.mCurrentDimension; } - public Map getLocalMap(){ + public Map getLocalMap(){ return this.mLocalChargingMap; } - public Map getLongRangeMap(){ + public Map getLongRangeMap(){ return this.mWirelessChargingMap; } @@ -364,8 +365,8 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } - private Map mWirelessChargingMap = new HashMap(); - private Map mLocalChargingMap = new HashMap(); + private Map mWirelessChargingMap = new HashMap(); + private Map mLocalChargingMap = new HashMap(); @Override public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { @@ -379,7 +380,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ mHasBeenMapped = true; } - + if (aTick % 20 == 0 && mHasBeenMapped){ if (!aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()){ for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities){ @@ -389,15 +390,15 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { if (this.mMode == 1 || this.mMode == 2){ int tempRange = (this.mMode == 1 ? this.mTier*20 : this.mTier*10); if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ - if (!mLocalChargingMap.containsKey(mTemp.getPersistentID())){ - mLocalChargingMap.put(mTemp.getPersistentID(), mTemp); + if (!mLocalChargingMap.containsKey(mTemp.getDisplayName())){ + mLocalChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); ChargingHelper.addValidPlayer(mTemp, this); //PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m - Local]."); } } else { - if (mLocalChargingMap.containsKey(mTemp.getPersistentID())){ - if (mLocalChargingMap.remove(mTemp.getPersistentID()) != null){ + if (mLocalChargingMap.containsKey(mTemp.getDisplayName())){ + if (mLocalChargingMap.remove(mTemp.getDisplayName()) != null){ //PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m - Local]."); ChargingHelper.removeValidPlayer(mTemp, this); } @@ -407,24 +408,24 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { if (this.mMode == 0 || this.mMode == 2){ int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) <= tempRange){ - if (!mWirelessChargingMap.containsKey(mTemp)){ + if (!mWirelessChargingMap.containsKey(mTemp.getDisplayName())){ if (mTemp.getDisplayName().equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())) { - mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); + mWirelessChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); ChargingHelper.addValidPlayer(mTemp, this); PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m - Long-Range]."); } } } else { - if (mWirelessChargingMap.containsKey(mTemp)){ - if (mWirelessChargingMap.remove(mTemp) != null){ + if (mWirelessChargingMap.containsKey(mTemp.getDisplayName())){ + if (mWirelessChargingMap.remove(mTemp.getDisplayName()) != null){ PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m - Long Range]."); ChargingHelper.removeValidPlayer(mTemp, this); } } } - if (mWirelessChargingMap.containsKey(mTemp) && !mTemp.getDisplayName().equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())){ - if (mWirelessChargingMap.remove(mTemp) != null){ + if (mWirelessChargingMap.containsKey(mTemp.getDisplayName()) && !mTemp.getDisplayName().equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())){ + if (mWirelessChargingMap.remove(mTemp.getDisplayName()) != null){ ChargingHelper.removeValidPlayer(mTemp, this); } } @@ -516,15 +517,29 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } if (this.mMode == 2){ - PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: "+this.mTier*10+"m | Long: "+tempRange+"m"); + PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: "+this.mTier*10+"m | Long: "+tempRange+"m"); + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLocalMap().keySet()) { + PlayerUtils.messagePlayer(aPlayer, "Local: "+name); + } + for (String name : this.getLongRangeMap().keySet()) { + PlayerUtils.messagePlayer(aPlayer, "Long: "+name); + } } else if (this.mMode == 1){ PlayerUtils.messagePlayer(aPlayer, "Local Mode: "+this.mTier*20+"m"); + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLocalMap().keySet()) { + PlayerUtils.messagePlayer(aPlayer, ""+name); + } } else { PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m"); - + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLongRangeMap().keySet()) { + PlayerUtils.messagePlayer(aPlayer, ""+name); + } } return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); -- cgit From f6599e799922840f2e5c94d2c0b638357e75e5cd Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 14 Jan 2022 20:22:34 +0000 Subject: Fix Computer Cube GUI. Fix Glod's shitty implementation of perfect OC which broke some multis. --- .../java/gtPlusPlus/core/util/math/MathUtils.java | 131 +++++----- .../java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 4 +- .../gui/computer/GT_Container_ComputerCube.java | 76 ++++-- .../gui/computer/GT_GUIContainer_ComputerCube.java | 29 ++- .../base/GregtechMeta_MultiBlockBase.java | 40 +-- .../computer/GT_ComputercubeDescription.java | 189 -------------- .../computer/GT_Computercube_Description.java | 194 ++++++++++++++ .../processing/GregtechMetaTileEntity_IsaMill.java | 2 +- .../production/GregtechMTE_FrothFlotationCell.java | 18 +- .../GregtechMetaTileEntity_MassFabricator.java | 35 ++- .../chemplant/GregtechMTE_ChemicalPlant.java | 2 +- .../misc/GT_TileEntity_ComputerCube.java | 284 +++++---------------- .../registration/gregtech/Gregtech4Content.java | 2 +- 13 files changed, 465 insertions(+), 541 deletions(-) delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputercubeDescription.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Description.java (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gtPlusPlus/core/util/math/MathUtils.java b/src/main/java/gtPlusPlus/core/util/math/MathUtils.java index 7573e0d51c..5c7a5bac6d 100644 --- a/src/main/java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/main/java/gtPlusPlus/core/util/math/MathUtils.java @@ -16,12 +16,12 @@ public class MathUtils { final static Random rand = CORE.RANDOM; - /** Formats a number with group separator and at most 2 fraction digits. */ - private static final NumberFormat sNumberFormat = NumberFormat.getInstance(); - - static { - sNumberFormat.setMaximumFractionDigits(2); - } + /** Formats a number with group separator and at most 2 fraction digits. */ + private static final NumberFormat sNumberFormat = NumberFormat.getInstance(); + + static { + sNumberFormat.setMaximumFractionDigits(2); + } /** * Returns a psuedo-random number between min and max, inclusive. @@ -554,7 +554,7 @@ public class MathUtils { return 0; } } - + public static V safeCast(Object aNumberType) { long a1; double a2; @@ -573,7 +573,7 @@ public class MathUtils { String s = ""+a1; Short s1 = Short.valueOf(s); return (V) s1; - + } } else if ((aNumberType.getClass() == int.class) || (aNumberType instanceof Integer)){ @@ -581,7 +581,7 @@ public class MathUtils { String s = ""+a1; Integer s1 = Integer.valueOf(s); return (V) s1; - + } } else if ((aNumberType.getClass() == long.class) || (aNumberType instanceof Long)){ @@ -596,7 +596,7 @@ public class MathUtils { String s = ""+a1; Float s1 = Float.valueOf(s); return (V) s1; - + } } else if ((aNumberType.getClass() == double.class) || (aNumberType instanceof Double)){ @@ -604,40 +604,40 @@ public class MathUtils { String s = ""+a1; Double s1 = Double.valueOf(s); return (V) s1; - + } } - + Integer o = 0; return (V) o; - + } - + public static byte getSafeByte(Byte b) { Byte a = safeCast(b); return a.byteValue(); } - + public static short getSafeShort(Short b) { Short a = safeCast(b); return a.shortValue(); } - + public static int getSafeInt(Integer b) { Integer a = safeCast(b); return a.intValue(); } - + public static long getSafeLong(Long b) { Long a = safeCast(b); return a.longValue(); } - + public static float getSafeFloat(Float b) { Float a = safeCast(b); return a.floatValue(); } - + public static double getSafeDouble(Double b) { Double a = safeCast(b); return a.doubleValue(); @@ -699,7 +699,7 @@ public class MathUtils { public static int balance(int aInput, int aMin, int aMax) { return Math.max(Math.min(aInput, aMax), aMin); } - + /** * Balances a number within a range. * @param aInput - The number to balance @@ -710,7 +710,7 @@ public class MathUtils { public static Number balance(Number aInput, Number aMin, Number aMax) { return max(min(aInput, aMax), aMin); } - + /** * Balances a number within a range. * @param aInput - The number to balance @@ -721,7 +721,7 @@ public class MathUtils { public static int balanceInt(Number aInput, Number aMin, Number aMax) { return MathUtils.safeCast_LongToInt((long) balance(max(min(aInput, aMax), aMin), Integer.MIN_VALUE, Integer.MAX_VALUE)); } - + /** * Balances a number within a range. * @param aInput - The number to balance @@ -737,51 +737,62 @@ public class MathUtils { int aAmount = Math.max(Math.min(i, aMax), aMin); return aAmount; } - + public static Pair splitLongIntoIntegers(long aLong){ int aIntMaxInLong = (int) Math.min(Integer.MAX_VALUE, Math.floor(aLong/Integer.MAX_VALUE)); int aRemainder = (int) (aLong - (aIntMaxInLong * Integer.MAX_VALUE)); return new Pair(aIntMaxInLong, aRemainder); } - - - /** - * Returns the smaller of two {@code Number}s. That is, - * the result the argument closer to the value of - * {@link Long#MIN_VALUE}. If the arguments have the same - * value, the result is that same value. - * - * @param a an argument. - * @param b another argument. - * @return the smaller of {@code a} and {@code b}. - */ - public static Number min(Number a, Number b) { - return (a.longValue() <= b.longValue()) ? a : b; - } - - /** - * Returns the greater of two {@code Number}s. That is, the - * result is the argument closer to the value of - * {@link Long#MAX_VALUE}. If the arguments have the same value, - * the result is that same value. - * - * @param a an argument. - * @param b another argument. - * @return the larger of {@code a} and {@code b}. - */ - public static Number max(Number a, Number b) { - return (a.longValue() >= b.longValue()) ? a : b; - } - - public static String formatNumbers(long aNumber) { - return sNumberFormat.format(aNumber); - } - - public static String formatNumbers(double aNumber) { - return sNumberFormat.format(aNumber); - } + + + /** + * Returns the smaller of two {@code Number}s. That is, + * the result the argument closer to the value of + * {@link Long#MIN_VALUE}. If the arguments have the same + * value, the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static Number min(Number a, Number b) { + return (a.longValue() <= b.longValue()) ? a : b; + } + + /** + * Returns the greater of two {@code Number}s. That is, the + * result is the argument closer to the value of + * {@link Long#MAX_VALUE}. If the arguments have the same value, + * the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static Number max(Number a, Number b) { + return (a.longValue() >= b.longValue()) ? a : b; + } + + public static long combineTwoIntegersToLong(int a, int b) { + long val = (((long) a) << 32) | (b & 0xffffffffL); + return val; + } + public static int[] splitLongIntoTwoIntegers(long aNum) { + int a = (int) (aNum >> 32); + int b = (int) aNum; + return new int[] {a, b}; + } + + public static String formatNumbers(long aNumber) { + return sNumberFormat.format(aNumber); + } + + public static String formatNumbers(double aNumber) { + return sNumberFormat.format(aNumber); + } + } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 3e294a076c..913b72fb0a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -55,7 +55,7 @@ import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputerCube_Setup; -import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; +import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Description; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_ElementalDuplicator; import gtPlusPlus.xmod.gregtech.loaders.Gregtech_Blocks; @@ -178,7 +178,7 @@ public class HANDLER_GT { convertPyroToCokeOven(); generateElementalDuplicatorRecipes(); Meta_GT_Proxy.fixIC2FluidNames(); - GT_ComputercubeDescription.addStandardDescriptions(); + GT_Computercube_Description.addStandardDescriptions(); GT_ComputerCube_Setup.init(); RecipeLoader_AlgaeFarm.generateRecipes(); if (LoadedMods.AdvancedSolarPanel) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java index 477bcef092..80202695e7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java @@ -9,11 +9,12 @@ import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.gui.GT_Slot_Output; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_ModHandler; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -23,7 +24,9 @@ import net.minecraft.item.ItemStack; public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { - public int mEUOut; + public long mEUOut; + public int mEUOut1; + public int mEUOut2; public int mHeat; @@ -33,7 +36,9 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { public int mExplosionStrength; - public int mEU; + public long mEU; + public int mEU1; + public int mEU2; public int mProgress; @@ -41,6 +46,10 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { public GT_Container_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aID) { super(aInventoryPlayer, aTileEntity); + Logger.INFO("1 Container Mode: "+aID); + Logger.INFO("2 Container Mode: "+getMode()); + mID = getMode(); + Logger.INFO("3 Container Mode: "+getMode()); // addSlotsComputer(aInventoryPlayer); detectAndSendChanges(); } @@ -56,7 +65,7 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { public void addSlotsComputer(InventoryPlayer aInventoryPlayer) { int y; mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; - Logger.INFO("Mode: " + mID); + Logger.INFO(""+(Utils.isClient() ? "Client" : "Server")+" Mode: " + mID); addSlotToContainer(new GT_Slot_Holo((IInventory) this.mTileEntity, 58, 156 + ((this.mID == 5) ? 50 : 0), 4, false, false, 1)); switch (this.mID) { case 1 : @@ -142,24 +151,24 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { } public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - Logger.INFO("Clicked slot " + aSlotIndex); + //Logger.INFO("Clicked slot " + aSlotIndex); if (aSlotIndex < 0) { - Logger.INFO(""); + //Logger.INFO(""); return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } if (this.mID != ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode) { - Logger.INFO("This ID: " + mID + ", Tile: " + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode); + //Logger.INFO("This ID: " + mID + ", Tile: " + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode); return null; } Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); if (tSlot == null) { - Logger.INFO("Null Slot?"); + //Logger.INFO("Null Slot?"); } else { ItemStack tStack = tSlot.getStack(); - Logger.INFO("Good Slot!"); + //Logger.INFO("Good Slot!"); if (aSlotIndex == 0) { - Logger.INFO("Slot is 0"); + //Logger.INFO("Slot is 0"); if (aMouseclick == 0) { Logger.INFO("Forward"); ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeForward(); @@ -168,7 +177,12 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { Logger.INFO("Backwards"); ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeBackward(); } - aPlayer.openGui(CORE.MODID, getComputerCubeGUIID(), this.mTileEntity.getWorld(), this.mTileEntity.getXCoord(), this.mTileEntity.getYCoord(), this.mTileEntity.getZCoord()); + if (aPlayer instanceof EntityPlayerMP) { + EntityPlayerMP aPlayerMP = (EntityPlayerMP) aPlayer; + changePage(aPlayerMP, ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode); + } + //FMLNetworkHandler.openGui(entityPlayer, mod, modGuiId, world, x, y, z); + //aPlayer.openGui(CORE.MODID, getComputerCubeGUIID(), this.mTileEntity.getWorld(), this.mTileEntity.getXCoord(), this.mTileEntity.getYCoord(), this.mTileEntity.getZCoord()); } else if (aSlotIndex <= 2 && this.mID == 3) { if (aSlotIndex == 1) { @@ -269,14 +283,21 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { } } else { - Logger.INFO("Super 2"); + //Logger.INFO("Super 2"); return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } } - Logger.INFO("???"); + //Logger.INFO("???"); return null; } + + + public void changePage(EntityPlayerMP aPlayerMP, int aMode) { + GT_TileEntity_ComputerCube aCompTile = (GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity(); + aCompTile.onRightclick(mTileEntity, aPlayerMP); + } + public boolean doesBindPlayerInventory() { return (this.mID != 1 && this.mID != 5); } @@ -288,26 +309,33 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { } this.mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; this.mEUOut = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEUOut; + int[] aEUSplit1 = MathUtils.splitLongIntoTwoIntegers(mEUOut); + this.mEUOut1 = aEUSplit1[0]; + this.mEUOut2 = aEUSplit1[1]; this.mHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHeat; this.mMaxHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMaxHeat; this.mHEM = (int) (((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHEM * 10000.0F); this.mExplosionStrength = (int) (((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mExplosionStrength * 100.0F); this.mEU = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEU; this.mProgress = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mProgress; + int[] aEUSplit2 = MathUtils.splitLongIntoTwoIntegers(mEU); + this.mEU1 = aEUSplit2[0]; + this.mEU2 = aEUSplit2[1]; Iterator var2 = this.crafters.iterator(); while (var2.hasNext()) { ICrafting var1 = var2.next(); - var1.sendProgressBarUpdate((Container) this, 101, this.mEUOut); + var1.sendProgressBarUpdate((Container) this, 101, this.mID); var1.sendProgressBarUpdate((Container) this, 102, this.mHeat & 0xFFFF); var1.sendProgressBarUpdate((Container) this, 103, this.mMaxHeat & 0xFFFF); var1.sendProgressBarUpdate((Container) this, 104, this.mHEM); var1.sendProgressBarUpdate((Container) this, 105, this.mExplosionStrength); var1.sendProgressBarUpdate((Container) this, 106, this.mHeat >>> 16); var1.sendProgressBarUpdate((Container) this, 107, this.mMaxHeat >>> 16); - var1.sendProgressBarUpdate((Container) this, 108, this.mEU & 0xFFFF); - var1.sendProgressBarUpdate((Container) this, 109, this.mEU >>> 16); + var1.sendProgressBarUpdate((Container) this, 108, this.mEU1); + var1.sendProgressBarUpdate((Container) this, 109, this.mEU2); var1.sendProgressBarUpdate((Container) this, 110, this.mProgress); - var1.sendProgressBarUpdate((Container) this, 111, this.mID); + var1.sendProgressBarUpdate((Container) this, 111, this.mEUOut1); + var1.sendProgressBarUpdate((Container) this, 112, this.mEUOut2); } } @@ -316,7 +344,7 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { super.updateProgressBar(par1, par2); switch (par1) { case 101 : - this.mEUOut = par2; + this.mID = par2; break; case 102 : this.mHeat = this.mHeat & 0xFFFF0000 | par2; @@ -337,15 +365,19 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { this.mMaxHeat = this.mMaxHeat & 0xFFFF | par2 << 16; break; case 108 : - this.mEU = this.mEU & 0xFFFF0000 | par2; + this.mEU1 = par2; case 109 : - this.mEU = this.mEU & 0xFFFF | par2 << 16; + this.mEU2 = par2; + this.mEU = MathUtils.combineTwoIntegersToLong(mEU1, mEU2); break; case 110 : this.mProgress = par2; break; case 111 : - this.mID = par2; + this.mEUOut1 = par2; + case 112 : + this.mEUOut2 = par2; + this.mEUOut = MathUtils.combineTwoIntegersToLong(mEUOut1, mEUOut2); break; } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java index 47795f4510..c56e167319 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java @@ -3,8 +3,9 @@ package gtPlusPlus.xmod.gregtech.api.gui.computer; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; +import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Description; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; @@ -12,8 +13,12 @@ import net.minecraft.util.StatCollector; public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machine { public GT_GUIContainer_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aBaseMetaTileEntity, int aID) { super(new GT_Container_ComputerCube(aInventoryPlayer, aBaseMetaTileEntity, aID), CORE.RES_PATH_GUI + "computer/"+aID+".png"); - if (aID == 5) + GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; + Logger.INFO("1 GUI Mode: "+aID); + Logger.INFO("2 GUI Mode: "+tContainer.mID); + if (tContainer.mID == 5) { this.xSize += 50; + } } @@ -33,6 +38,7 @@ public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machin protected void drawGuiContainerForegroundLayer(int par1, int par2) { GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; + //Logger.INFO("3 GUI Mode: "+xSize); //GT_TileEntity_ComputerCube tTileEntity = (GT_TileEntity_ComputerCube) tContainer.mTileEntity; if (tContainer != null) switch (tContainer.mID) { @@ -78,13 +84,16 @@ public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machin this.fontRendererObj.drawString("OUT: " + toNumber(tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 55, 16448255); break; case 5 : - if (tContainer.mMaxHeat >= 0 && tContainer.mMaxHeat < GT_ComputercubeDescription.sDescriptions.size()) - for (int i = 0; i < ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription.length; i++) { + if (tContainer.mID == 5 && this.xSize == 176) { + this.xSize += 50; + } + if (tContainer.mMaxHeat >= 0 && tContainer.mMaxHeat < GT_Computercube_Description.sDescriptions.size()) + for (int i = 0; i < ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription.length; i++) { if (i == 0) { - this.fontRendererObj.drawString(((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7, 16448255); + this.fontRendererObj.drawString(((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7, 16448255); } else { - this.fontRendererObj.drawString(((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7 + this.fontRendererObj.drawString(((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7 + 8 * i, 16448255); } } @@ -113,16 +122,16 @@ public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machin } } - public String toNumber(int aNumber) { + public String toNumber(long mEU) { String tString = ""; boolean temp = true, negative = false; - if (aNumber < 0) { - aNumber *= -1; + if (mEU < 0) { + mEU *= -1; negative = true; } int i; for (i = 1000000000; i > 0; i /= 10) { - int tDigit = aNumber / i % 10; + long tDigit = mEU / i % 10; if (temp && tDigit != 0) temp = false; if (!temp) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index ec7115cb0f..1232166baa 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -753,26 +753,6 @@ public abstract class GregtechMeta_MultiBlockBase tItems = getStoredInputs(); - ArrayList tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe, isPerfectOC); - } - - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null, false); - } - public boolean checkRecipeGeneric(GT_Recipe aRecipe, int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { @@ -783,14 +763,14 @@ public abstract class GregtechMeta_MultiBlockBase tFluids = getStoredFluids(); ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe, false); + return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); } public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, boolean isPerfectOC) { - return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null, isPerfectOC); + int aSpeedBonusPercent, int aOutputChanceRoll) { + return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null); } @@ -941,10 +921,14 @@ public abstract class GregtechMeta_MultiBlockBase sDescriptions = new ArrayList(); - - public String[] mDescription; - - public ItemStack[] mStacks; - - public GT_ComputercubeDescription(String[] aDescription, ItemStack[] aStacks) { - this.mDescription = aDescription; - this.mStacks = aStacks; - sDescriptions.add(this); - } - - public static void addStandardDescriptions() { - Logger.INFO("Adding Default Description Set of the Computer Cube"); - new GT_ComputercubeDescription(new String[] { - "Lightning Rod", "Also known as the Bane of", "Alblaka. The Lightning Rod", "enables you to gain Energy", "from Lightning! To set it up", "you just need the Block", "itself, 4 HV-Transformers", "and a crapton of Ironfences,", "which you then place on top", "of it. After that you have to", - "wait for a Thunderstorm and", "when you are lucky you get", "2.5 MFSU of Energy out of", "it. If a Rod is high enough", "then Rain is also enough to", "get stroke, but with less", "probability ofcourse." }, new ItemStack[] { - GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), ItemList.Machine_IV_LightningRod.get(1), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Quantum Chest", "You want to store tons of", "Materials into your Chests", "but you hate the Item limit", "of them? Not anymore! The", "Quantum Chest is able to", "store an INFINITE* amount", "of one single Item type per", "Chest.", "This Chest stores your Items", - "like Data and ever has a", "Stack of the Item ready for", "extraction. It is compatible", "with any Item that doesnt", "have a NBT-Tag. You ask what", "NBT is? I know it, thats enough.", "* = 2147483391" }, new ItemStack[] { - null, null, null, null, ItemList.Quantum_Chest_LV.get(1), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Computer Cube", "The Device you are", "currently using. This Computer", "is running the G.L.A.D.-OS,", "which is containing many", "usefull Apps:", "- Reactor Planner", "- Seedbag Scanner", "- Recipelists for GT-Devices", "- ", - "- ", "- ", "- ", "- ", "And the Description List you", "are currently reading.", "~This Device has private Access~" }, new ItemStack[] { - null, null, null, null, GregtechItemList.Gregtech_Computer_Cube.get(1), null, null, null, null, null, - null, null, null, null }); - /* new GT_ComputercubeDescription(new String[] { - "UUM-Assembler", "It's like an automatic", "Crafting Table just for UUM", "It can store 20 UUM-Recipes", "and produces those on demand", "It costs 512EU per used piece", "of Universal-Usable-Matter(TM).", "The integrated Quantum Chest", "allows it to store all your", "UUM inside it.", - "Top and Bottom are for Input,", "while the Output is on the", "Sides. The Output is designed,", "to work with RP-Managers, so", "build it into your recursive", "Autocraftingsystem.", "" }, new ItemStack[] { - null, null, null, GT_ModHandler.getIC2Item("matter", 1), new ItemStack(GregTech_API.sBlockList[1], 1, 5), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Sonictron", "You like Music? Then the", "Sonictron 9001 is your best", "choice! You can compose Alarms,", "Doorbell Sounds or boring", "Elevator Music, with the 64 Slots", "inside it. Just leftclick them", "to switch the Sound, rightclick", "them to switch the modulation", "and shiftclick to remove it.", - "Then apply Redstone to play", "With the mobile Version you can", "play sounds everywhere, after", "you copied them from a normal", "Sonictron via rightclicking", "Sneakrightclicking pastes", "Emits Redstone when finished." }, new ItemStack[] { - null, null, null, GregTech_API.getGregTechItem(32, 1, 0), new ItemStack(GregTech_API.sBlockList[1], 1, 6), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "L.E.S.U.", "The unlaggiest Multiblock ever!", "One Controllerblock, and as many", "'stupid' Storageblocks as you want.", "To use it, place one Controller", "and then place the LESU-Storages", "adjacent to it or other placed", "LESU-Storages. The Tier (max EU/t)", "of it depends on the amount of", "adjacent Storages. The", - "Storageblocks are NOT TileEntities,", "what means that they cause as much", "Lag as a random Dirtblock. And the", "Controller Block only checks ONCE", "for the Storages, so no", "Blockiterationlag, AT. ALL. Anyone,", "who says that they lag gets murdered!" }, new ItemStack[] { - null, null, null, new ItemStack(GregTech_API.sBlockList[0], 1, 6), new ItemStack(GregTech_API.sBlockList[1], 1, 7), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "I.D.S.U.", "The Interdimensional Storage Unit", "is a Device, which is like a", "wireless, crossdimensional and", "enderchestlike EU-Storage Block", "", "Every Player has one Network of", "these. The ID is determined by", "the Hashcode of the Name from the", "first Player, who opens it's GUI", - "", "It stores up to 1 Billion EU", "and emits EV. But you need at", "least two of them for Energy", "Transfer", "", "" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 8), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "A.E.S.U.", "The Adjustable Energy Storage Unit", "is like 10 MFSU and has an", "adjustable Output between 0 and", "2048EU/t. You could use it as a", "Transformer. It is Tier-IV, so", "it's basically needed to charge", "Energy Orbs and Lapotron Packs", "", "Not much else to say about it.", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 9), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Charge-O-Mat", "An automatable Charging Bench", "It puts (de-)charged Tools into", "the right Outputslots, which are", "accessible on the Sides of it.", "", "The Energy Orb inside stores enough", "to charge your QSuit almost instantly", "", "This is a Tier-V Charging Station", - "even when the Max-IN/OUT is only", "2048EU/t. It also charges your Armor", "when you are standing close to it.", "", "If you apply Redstone, then it", "decharges instead.", "" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 10), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Centrifuge", "This is a Machine to seperate", "Isotopes.", "", "It has a maximum Consumption Rate", "of 5EU/t, and its Maxinput is", "32EU/t. The time it needs depends", "on the Recipe you use.", "", "It needs Tin Cells for some Recipes,", - "which you put in the Top Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "", "You can pipe Lava into this Device" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 11), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Electrolyzer", "This is a Machine to seperate", "Molecules and electrolyze", "Watercells.", "", "It has a maximum Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs depends", "on the Recipe you use.", "", - "It needs Tin Cells for some Recipes,", "which you put in the Bottom Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 25), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Grinder", "This Machines purpose is to", "macerate and grind Ores.", "It can ONLY grind Ores, don't", "try regular Macerator Recipes.", "It has a fixed Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs is", "5 seconds per Ore Block", "It needs Water for most Recipes,", - "which you put in the Bottom Left Slot", "Top = Input", "Bottom = Water", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { - null, new ItemStack(Block.field_71943_B, 1), new ItemStack(GregTech_API.sBlockList[0], 1, 14), new ItemStack(GregTech_API.sBlockList[0], 1, 13), new ItemStack(GregTech_API.sBlockList[1], 1, 28), null, null, null, null, null, - null, null, null, null });*/ - new GT_ComputercubeDescription(new String[] { - "Electric Blast Furnace", "You may know the Blast Furnace", "of Railcraft. This one works", "similar, as it can also produce", "Steel out of Iron and Coal.", "", "Its heat Capacity depends on the", "used Machine Casings for building", "it. The better they are, the more", "Heat it can achieve.", - "", "Top = Input 1", "Bottom = Input 2", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { - null, null, null, null, ItemList.Machine_Multi_BlastFurnace.get(1), null, null, null, null, null, - null, null, null, null }); - /* new GT_ComputercubeDescription(new String[] { - "Sawmill", "This Device turns your Logs", "into more Planks, than a normal", "Steve can produce with his Hands.", "", "Its byproduct, Wood Pulp, can be", "compressed into special Planks,", "which are burning like Charcoal.", "", "It needs Water for most Recipes,", - "which you put in the Bottom Left Slot", "Top = Input", "Water Sides = Water", "Saw Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { - null, null, GT_MetaItem_Material.instance.getStack(15, 1), GT_MetaItem_Dust.instance.getStack(15, 1), new ItemStack(GregTech_API.sBlockList[1], 1, 32), null, null, null, null, null, - null, null, null, null });*/ - new GT_ComputercubeDescription(new String[] { - "Implosion Compressor", "You need to turn Dusts back", "into Gems? Or do you just want", "to make Iridium Plates?", "With a bit ITNT you can achieve", "that in this Device!", "", "We strongly recommend to use", "Flint Dust instead of Flints", "for making the ITNT.", - "", "Top = Input", "Explosion Sides = Output", "ITNT Side = ITNT Input", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { - null, null, null, GT_ModHandler.getIC2Item("industrialTnt", 1, new ItemStack(net.minecraft.init.Blocks.tnt, 1)), ItemList.Machine_Multi_ImplosionCompressor.get(1), null, null, null, null, null, - null, null, null, null }); - /* new GT_ComputercubeDescription(new String[] { - "Superconductor", "Expensive, but superconducting", "nearly infinite EU/p and it has", "no Cableloss!", "Do not confuse this with the", "Superconductor Item!", "", "Supercondensator", "This is a special kind of Transformer", "It allows you to convert anything down", - "to 8192 EU/t, what is like a normal HVT.", "But if you apply Redstone to it then it", "outputs friggin 1000000EU/t!!!", "", "You also need it for the Fusion Reactor.", "Some Machines will require that high", "Voltage in a short period of time." }, new ItemStack[] { - null, null, GregTech_API.getGregTechItem(3, 1, 2), new ItemStack(GregTech_API.sBlockList[1], 1, 12), new ItemStack(GregTech_API.sBlockList[1], 1, 15), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Player Detector", "This nice little Device is able", "to detect Players in a Range of", "16-Spherical Meters and a", "EU-Consumption of 2.5EU/t.", "", "It can be switched to 3 Diffrent", "Modes, to detect YOURSELF, OTHERS", "and ALL Players by Rightclicking it.", "", - "It doesnt detect regular Mobs.", "", "", "", "", "", "~This Device has private Access~" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 13), null, null, null, null, null, - null, null, null, null });*/ - new GT_ComputercubeDescription(new String[] { - "Matter Fabricator", "The Matter Fabricator is nothing", "else than a Mass Fabricator, which", "can ONLY run on Scrap and other", "Amplifiers.", "", "With the Default Config it is 100", "times more expensive than normal.", "Of course you can set the Config", "to 166666, to get your normal", - "Massfabricationrate back, or you", "could make Mass Fabrication even", "cheaper, if you really want to", "make Mass Fabrication that easy", "", "", "" }, new ItemStack[] { - null, null, null, GT_Utility.getFluidDisplayStack(FluidUtils.getUUA(1), false), ItemList.Machine_LV_Massfab.get(1), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Electric Autocrafting Tables", "These are Crafting Tables for the", "common need of autocrafting in", "Factories. One Craft needs 5000EU to", "be performed, so you have actually to", "lay Wires to it. This Table is", "unique as its also able, to give you", "the used Capsulecellcontainers, made", "by Industrial Corp, back.", "You may use that behaviour to", - "craft anything releated to chemics,", "like the 2xKNO3-Recipe for Saltpeter.", "The 5 Modes are the following:", "1. Craft Recipe, 2. All 5 Modes", "3. Craft all as single Items", "4. 2x2-Grid and 5. a 3x3-Grid.", "It accepts only 32EU/p as Input." }, new ItemStack[] { - null, null, null, null, GregtechItemList.GT4_Electric_Auto_Workbench_LV.get(1), null, null, null, null, null, - null, null, null, null }); - /* new GT_ComputercubeDescription(new String[] { - "Automation with GregTech", "Translocators and Buffers are the", "newest Way to automate your Machines.", "Screw Buildcraft, these EU-wasting", "Devices are much more awesome.", "They output 32EU/t to their directed", "IN- and OUT-puts, making them usefull", "for things, like saving wires.", "Translocators are taking Stuff from", "the Block at their green Inputfacing", - "and putting it into the Block at the", "red Outputfacing. Buffers do the same,", "but the grab Items from their own", "Inventory, what makes them usefull", "as Pipe-replacement.", "Buffers also have Redstone Intelligence,", "which you can configure in their GUI." }, new ItemStack[] { - null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 19), new ItemStack(GregTech_API.sBlockList[1], 1, 18), new ItemStack(GregTech_API.sBlockList[1], 1, 17), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Silver Ore", "It's rarity is similar to Gold", "Silver can be used, to make", "Circuits cheaper, or you can use", "it for Redpowerstuff.", "", "", "", "", "", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, GT_OreDictUnificator.get("dustSilver", 1), GregTech_API.getGregTechItem(0, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 1), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Sapphires and Rubys", "These spawn exactly like Emeralds.", "But Rubies are found in Deserts,", "while Sapphires can be found in", "Oceans.", "", "They currently make only a cheaper", "Recipe for Energycrystals and", "Lapotroncrystals, but they are", "Redpower Compatible.", - "", "They also sometimes drop random", "other Gems, like Garnet for Ruby", "or green Sapphire for Sapphire", "in addition.", "", "" }, new ItemStack[] { - null, GregTech_API.getGregTechItem(0, 1, 32), new ItemStack(GregTech_API.sBlockList[2], 1, 3), GregTech_API.getGregTechItem(0, 1, 33), new ItemStack(GregTech_API.sBlockList[2], 1, 4), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Bauxite Ore", "The Stuff out of which you can", "produce Aluminium and also", "Titanium.", "You find this Ore in Plains and", "Forests.", "", "If you think Aluminium is useless", "then note, that mobs NEVER spawn", "ontop of an Aluminium Block", - "(Same applies also for Silver-,", "Gem- and Iridium Blocks)", "Production Chain:", "macerating Bauxite Ore", "electrolyzing 24 Bauxite Dust", "smelting Aluminium Dust in a", "Blast Furnace" }, new ItemStack[] { - new ItemStack(GregTech_API.sBlockList[0], 1, 7), GregTech_API.getGregTechItem(0, 1, 18), GregTech_API.getGregTechItem(1, 1, 18), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Titanium", "Produced by centrifuging Bauxitedust", "as a byproduct, this Material can make", "anything much more resistant against", "damage, like Explosions.", "Blocks made of Titaniumingots have a", "large Blastresistance", "", "It can also be used to craft tons of", "mixed Metal Ingots", - "", "", "", "", "", "", "" }, new ItemStack[] { - new ItemStack(GregTech_API.sBlockList[0], 1, 8), GregTech_API.getGregTechItem(0, 1, 19), GregTech_API.getGregTechItem(1, 1, 19), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Iridium Ore", "You can find it only when you", "stripmine very large Areas with", "Quarries and such. There is only", "one in every 5th-10th Chunk.", "It's even more rare in Oceans!", "", "Some people disable the UUM-Recipe", "for Iridium, for making getting it", "an Achievement.", - "", "However Iridium Ore contains traces", "of Platinum, so it's best to use the", "Industrial Grinder for this Ore.", "", "", "" }, new ItemStack[] { - null, null, GT_OreDictUnificator.get("plateAlloyIridium", 1), GT_ModHandler.getIC2Item("iridiumOre", 1), new ItemStack(GregTech_API.sBlockList[2], 1, 2), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Helium Coolant Cell", "These are just cheaper, than the", "Water based Coolant Cells, and can", "also hold six times more Heat.", "", "Helium Cells can also be used for", "making Luminators and Mininglasers", "", "", "", - "", "", "", "", "", "", "" }, new ItemStack[] { - GregTech_API.getGregTechItem(2, 1, 6), GregTech_API.getGregTechItem(2, 1, 3), GregTech_API.getGregTechItem(34, 1, 0), GregTech_API.getGregTechItem(35, 1, 0), GregTech_API.getGregTechItem(36, 1, 0), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Destructopack", "Open its GUI via rightclick and", "dump all the useless Stuff from", "your Inventory into it, instead of", "littering Items into the World.", "", "", "", "", "", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, null, null, GregTech_API.getGregTechItem(33, 1, 0), null, null, null, null, null, - null, null, null, null });*/ - new GT_ComputercubeDescription(new String[] { - "Data Orbs", "They store Data.", "", "Rightclick on a Computer Cube, to", "extract a Reactorplan", "", "Sneak-Rightclick on it, to insert", "a Reactorplan", "", "Works also with Sonictrons", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, null, null, ItemList.Tool_DataOrb.get(1), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Energy Orbs", "10Million EU in one Orb!", "", "This is a Tier-IV-Energystorage", "So a MFSU is not enough for it!", "", "Use it to create a Lapotron Pack,", "which is like an ultimate Lap Pack!", "", "", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, null, ItemList.Energy_LapotronicOrb.get(1), null, null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Iridium Neutron Reflector", "It's used for Fusion Reactor Coils,", "and works like a normal one", "inside a Reactor, but it's also", "INDESTRUCTIBLE*.", "", "", "", "", "", - "", "", "", "", "", "", "* = for weardown" }, new ItemStack[] { - null, null, null, null, ItemList.Neutron_Reflector.get(1), null, null, null, null, null, - null, null, null, null }); - /*new GT_ComputercubeDescription(new String[] { - "Rock Cutter", "You want to get whole Blocks, but", "your Drill is not enchantable?", "The Rock Cutter has an awesome", "SilkTouch-III-Function!", "", "It works like a Drill, but you", "get the whole Block instead of", "'macerated' Ores!", "", - "Put those Blocks into a Macerator", "and double your Diamond Income!", "", "Or better. Use the Industrial", "Grinder to get even more", "Resources!", "" }, new ItemStack[] { - null, null, null, null, GregTech_API.getGregTechItem(46, 1, 0), null, null, null, null, null, - null, null, null, null }); - new GT_ComputercubeDescription(new String[] { - "Tesla Staff", "This completly untested PvP-Weapon", "destroys electric Armor in one hit", "", "The Energy Orb inside it must be", "fully charged to let this work.", "", "We are not responsible for any", "Electrocution Damage to yourself,", "while using it.", - "", "We also dont even know, if this", "Weapon has any effect AT ALL.", "", "", "", "" }, new ItemStack[] { - null, null, null, null, GregTech_API.getGregTechItem(47, 1, 0), null, null, null, null, null, - null, null, null, null });*/ - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Description.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Description.java new file mode 100644 index 0000000000..fedb4e6028 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Description.java @@ -0,0 +1,194 @@ +package gtPlusPlus.xmod.gregtech.common.computer; + +import java.util.ArrayList; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; + +public class GT_Computercube_Description { + public static ArrayList sDescriptions = new ArrayList(); + + public String[] mDescription; + + public ItemStack[] mStacks; + + public GT_Computercube_Description(String[] aDescription, ItemStack[] aStacks) { + this.mDescription = aDescription; + this.mStacks = aStacks; + sDescriptions.add(this); + } + + public static void addStandardDescriptions() { + Logger.INFO("Adding Default Description Set of the Computer Cube"); + new GT_Computercube_Description(new String[] { + "Lightning Rod", "Also known as the Bane of", "Alblaka. The Lightning Rod", "enables you to gain Energy", "from Lightning! To set it up", "you just need the Block", "itself, 4 HV-Transformers", "and a crapton of Ironfences,", "which you then place on top", "of it. After that you have to", + "wait for a Thunderstorm and", "when you are lucky you get", "2.5 MFSU of Energy out of", "it. If a Rod is high enough", "then Rain is also enough to", "get stroke, but with less", "probability ofcourse." }, new ItemStack[] { + GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), ItemList.Machine_IV_LightningRod.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Quantum Chest", "You want to store tons of", "Materials into your Chests", "but you hate the Item limit", "of them? Not anymore! The", "Quantum Chest is able to", "store an INFINITE* amount", "of one single Item type per", "Chest.", "This Chest stores your Items", + "like Data and ever has a", "Stack of the Item ready for", "extraction. It is compatible", "with any Item that doesnt", "have a NBT-Tag. You ask what", "NBT is? I know it, thats enough.", "Up to 2147483391*" }, new ItemStack[] { + ItemList.Quantum_Chest_IV.get(1), ItemList.Quantum_Chest_EV.get(1), ItemList.Quantum_Chest_HV.get(1), ItemList.Quantum_Chest_MV.get(1), ItemList.Quantum_Chest_LV.get(1), null, + null, null, null, null, null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Quantum Tank", "You want to store tons of", "Fluids into your Tanks", "but you hate the capacity", "of them? Not anymore! The", "Quantum Tank is able to", "store an INFINITE* amount", "of one single Fluid type per", "Tank.", "This Tank stores your Fluids", + "like Data and ever has a", "Stack of the Fluid ready for", "extraction. It is compatible", "with any Fluid. ", "You ask what", "NBT is? I know it, thats enough.", "* = 2147483391" }, new ItemStack[] { + ItemList.Quantum_Tank_IV.get(1), ItemList.Quantum_Tank_EV.get(1), ItemList.Quantum_Tank_HV.get(1), ItemList.Quantum_Tank_MV.get(1), ItemList.Quantum_Tank_LV.get(1), null, + null, null, null, null, null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Computer Cube", "The Device you are", "currently using. This Computer", "is running the G.L.A.D.-OS,", "which is containing many", "usefull Apps:", "- Reactor Planner", "- Seedbag Scanner", "- Recipelists for GT-Devices", "- ", + "- ", "- ", "- ", "- ", "And the Description List you", "are currently reading.", "~This Device has private Access~" }, new ItemStack[] { + null, null, null, null, GregtechItemList.Gregtech_Computer_Cube_Machine.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_Computercube_Description(new String[] { + "UUM-Assembler", "It's like an automatic", "Crafting Table just for UUM", "It can store 20 UUM-Recipes", "and produces those on demand", "It costs 512EU per used piece", "of Universal-Usable-Matter(TM).", "The integrated Quantum Chest", "allows it to store all your", "UUM inside it.", + "Top and Bottom are for Input,", "while the Output is on the", "Sides. The Output is designed,", "to work with RP-Managers, so", "build it into your recursive", "Autocraftingsystem.", "" }, new ItemStack[] { + null, null, null, GT_ModHandler.getIC2Item("matter", 1), new ItemStack(GregTech_API.sBlockList[1], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Sonictron", "You like Music? Then the", "Sonictron 9001 is your best", "choice! You can compose Alarms,", "Doorbell Sounds or boring", "Elevator Music, with the 64 Slots", "inside it. Just leftclick them", "to switch the Sound, rightclick", "them to switch the modulation", "and shiftclick to remove it.", + "Then apply Redstone to play", "With the mobile Version you can", "play sounds everywhere, after", "you copied them from a normal", "Sonictron via rightclicking", "Sneakrightclicking pastes", "Emits Redstone when finished." }, new ItemStack[] { + null, null, null, GregTech_API.getGregTechItem(32, 1, 0), new ItemStack(GregTech_API.sBlockList[1], 1, 6), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "L.E.S.U.", "The unlaggiest Multiblock ever!", "One Controllerblock, and as many", "'stupid' Storageblocks as you want.", "To use it, place one Controller", "and then place the LESU-Storages", "adjacent to it or other placed", "LESU-Storages. The Tier (max EU/t)", "of it depends on the amount of", "adjacent Storages. The", + "Storageblocks are NOT TileEntities,", "what means that they cause as much", "Lag as a random Dirtblock. And the", "Controller Block only checks ONCE", "for the Storages, so no", "Blockiterationlag, AT. ALL. Anyone,", "who says that they lag gets murdered!" }, new ItemStack[] { + null, null, null, new ItemStack(GregTech_API.sBlockList[0], 1, 6), new ItemStack(GregTech_API.sBlockList[1], 1, 7), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "I.D.S.U.", "The Interdimensional Storage Unit", "is a Device, which is like a", "wireless, crossdimensional and", "enderchestlike EU-Storage Block", "", "Every Player has one Network of", "these. The ID is determined by", "the Hashcode of the Name from the", "first Player, who opens it's GUI", + "", "It stores up to 1 Billion EU", "and emits EV. But you need at", "least two of them for Energy", "Transfer", "", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 8), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "A.E.S.U.", "The Adjustable Energy Storage Unit", "is like 10 MFSU and has an", "adjustable Output between 0 and", "2048EU/t. You could use it as a", "Transformer. It is Tier-IV, so", "it's basically needed to charge", "Energy Orbs and Lapotron Packs", "", "Not much else to say about it.", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 9), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Charge-O-Mat", "An automatable Charging Bench", "It puts (de-)charged Tools into", "the right Outputslots, which are", "accessible on the Sides of it.", "", "The Energy Orb inside stores enough", "to charge your QSuit almost instantly", "", "This is a Tier-V Charging Station", + "even when the Max-IN/OUT is only", "2048EU/t. It also charges your Armor", "when you are standing close to it.", "", "If you apply Redstone, then it", "decharges instead.", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 10), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Centrifuge", "This is a Machine to seperate", "Isotopes.", "", "It has a maximum Consumption Rate", "of 5EU/t, and its Maxinput is", "32EU/t. The time it needs depends", "on the Recipe you use.", "", "It needs Tin Cells for some Recipes,", + "which you put in the Top Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "", "You can pipe Lava into this Device" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 11), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Electrolyzer", "This is a Machine to seperate", "Molecules and electrolyze", "Watercells.", "", "It has a maximum Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs depends", "on the Recipe you use.", "", + "It needs Tin Cells for some Recipes,", "which you put in the Bottom Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 25), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Grinder", "This Machines purpose is to", "macerate and grind Ores.", "It can ONLY grind Ores, don't", "try regular Macerator Recipes.", "It has a fixed Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs is", "5 seconds per Ore Block", "It needs Water for most Recipes,", + "which you put in the Bottom Left Slot", "Top = Input", "Bottom = Water", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, new ItemStack(Block.field_71943_B, 1), new ItemStack(GregTech_API.sBlockList[0], 1, 14), new ItemStack(GregTech_API.sBlockList[0], 1, 13), new ItemStack(GregTech_API.sBlockList[1], 1, 28), null, null, null, null, null, + null, null, null, null });*/ + new GT_Computercube_Description(new String[] { + "Electric Blast Furnace", "You may know the Blast Furnace", "of Railcraft. This one works", "similar, as it can also produce", "Steel out of Iron and Coal.", "", "Its heat Capacity depends on the", "used Machine Casings for building", "it. The better they are, the more", "Heat it can achieve.", + "", "Top = Input 1", "Bottom = Input 2", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, null, ItemList.Casing_HeatProof.get(1), ItemList.Machine_Multi_BlastFurnace.get(1), ItemList.Casing_Coil_Cupronickel.get(1), ItemList.Casing_Coil_Kanthal.get(1), ItemList.Casing_Coil_Nichrome.get(1), ItemList.Casing_Coil_TungstenSteel.get(1), ItemList.Casing_Coil_HSSG.get(1), + ItemList.Casing_Coil_HSSS.get(1), ItemList.Casing_Coil_Naquadah.get(1), ItemList.Casing_Coil_NaquadahAlloy.get(1), null }); + /* new GT_Computercube_Description(new String[] { + "Sawmill", "This Device turns your Logs", "into more Planks, than a normal", "Steve can produce with his Hands.", "", "Its byproduct, Wood Pulp, can be", "compressed into special Planks,", "which are burning like Charcoal.", "", "It needs Water for most Recipes,", + "which you put in the Bottom Left Slot", "Top = Input", "Water Sides = Water", "Saw Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, GT_MetaItem_Material.instance.getStack(15, 1), GT_MetaItem_Dust.instance.getStack(15, 1), new ItemStack(GregTech_API.sBlockList[1], 1, 32), null, null, null, null, null, + null, null, null, null });*/ + new GT_Computercube_Description(new String[] { + "Implosion Compressor", "You need to turn Dusts back", "into Gems? Or do you just want", "to make Iridium Plates?", "With a bit ITNT you can achieve", "that in this Device!", "", "We strongly recommend to use", "Flint Dust instead of Flints", "for making the ITNT.", + "", "Top = Input", "Explosion Sides = Output", "ITNT Side = ITNT Input", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, null, GT_ModHandler.getIC2Item("industrialTnt", 1, new ItemStack(net.minecraft.init.Blocks.tnt, 1)), ItemList.Machine_Multi_ImplosionCompressor.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_Computercube_Description(new String[] { + "Superconductor", "Expensive, but superconducting", "nearly infinite EU/p and it has", "no Cableloss!", "Do not confuse this with the", "Superconductor Item!", "", "Supercondensator", "This is a special kind of Transformer", "It allows you to convert anything down", + "to 8192 EU/t, what is like a normal HVT.", "But if you apply Redstone to it then it", "outputs friggin 1000000EU/t!!!", "", "You also need it for the Fusion Reactor.", "Some Machines will require that high", "Voltage in a short period of time." }, new ItemStack[] { + null, null, GregTech_API.getGregTechItem(3, 1, 2), new ItemStack(GregTech_API.sBlockList[1], 1, 12), new ItemStack(GregTech_API.sBlockList[1], 1, 15), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Player Detector", "This nice little Device is able", "to detect Players in a Range of", "16-Spherical Meters and a", "EU-Consumption of 2.5EU/t.", "", "It can be switched to 3 Diffrent", "Modes, to detect YOURSELF, OTHERS", "and ALL Players by Rightclicking it.", "", + "It doesnt detect regular Mobs.", "", "", "", "", "", "~This Device has private Access~" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 13), null, null, null, null, null, + null, null, null, null });*/ + new GT_Computercube_Description(new String[] { + "Matter Fabricator", "The Matter Fabricator is nothing", "else than a Mass Fabricator, which", "can ONLY run on Scrap and other", "Amplifiers.", "", "With the Default Config it is 100", "times more expensive than normal.", "Of course you can set the Config", "to 166666, to get your normal", + "Massfabricationrate back, or you", "could make Mass Fabrication even", "cheaper, if you really want to", "make Mass Fabrication that easy", "", "", "" }, new ItemStack[] { + null, null, null, GT_Utility.getFluidDisplayStack(FluidUtils.getUUM(1), false), ItemList.Machine_LV_Massfab.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Electric Autocrafting Tables", "These are Crafting Tables for the", "common need of autocrafting in", "Factories. One Craft needs 5000EU to", "be performed, so you have actually to", "lay Wires to it. This Table is", "unique as its also able, to give you", "the used Capsulecellcontainers, made", "by Industrial Corp, back.", "You may use that behaviour to", + "craft anything releated to chemics,", "like the 2xKNO3-Recipe for Saltpeter.", "The 5 Modes are the following:", "1. Craft Recipe, 2. All 5 Modes", "3. Craft all as single Items", "4. 2x2-Grid and 5. a 3x3-Grid.", "It accepts only 32EU/p as Input." }, new ItemStack[] { + null, null, null, null, GregtechItemList.GT4_Electric_Auto_Workbench_LV.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_Computercube_Description(new String[] { + "Automation with GregTech", "Translocators and Buffers are the", "newest Way to automate your Machines.", "Screw Buildcraft, these EU-wasting", "Devices are much more awesome.", "They output 32EU/t to their directed", "IN- and OUT-puts, making them usefull", "for things, like saving wires.", "Translocators are taking Stuff from", "the Block at their green Inputfacing", + "and putting it into the Block at the", "red Outputfacing. Buffers do the same,", "but the grab Items from their own", "Inventory, what makes them usefull", "as Pipe-replacement.", "Buffers also have Redstone Intelligence,", "which you can configure in their GUI." }, new ItemStack[] { + null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 19), new ItemStack(GregTech_API.sBlockList[1], 1, 18), new ItemStack(GregTech_API.sBlockList[1], 1, 17), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Silver Ore", "It's rarity is similar to Gold", "Silver can be used, to make", "Circuits cheaper, or you can use", "it for Redpowerstuff.", "", "", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, GT_OreDictUnificator.get("dustSilver", 1), GregTech_API.getGregTechItem(0, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 1), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Sapphires and Rubys", "These spawn exactly like Emeralds.", "But Rubies are found in Deserts,", "while Sapphires can be found in", "Oceans.", "", "They currently make only a cheaper", "Recipe for Energycrystals and", "Lapotroncrystals, but they are", "Redpower Compatible.", + "", "They also sometimes drop random", "other Gems, like Garnet for Ruby", "or green Sapphire for Sapphire", "in addition.", "", "" }, new ItemStack[] { + null, GregTech_API.getGregTechItem(0, 1, 32), new ItemStack(GregTech_API.sBlockList[2], 1, 3), GregTech_API.getGregTechItem(0, 1, 33), new ItemStack(GregTech_API.sBlockList[2], 1, 4), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Bauxite Ore", "The Stuff out of which you can", "produce Aluminium and also", "Titanium.", "You find this Ore in Plains and", "Forests.", "", "If you think Aluminium is useless", "then note, that mobs NEVER spawn", "ontop of an Aluminium Block", + "(Same applies also for Silver-,", "Gem- and Iridium Blocks)", "Production Chain:", "macerating Bauxite Ore", "electrolyzing 24 Bauxite Dust", "smelting Aluminium Dust in a", "Blast Furnace" }, new ItemStack[] { + new ItemStack(GregTech_API.sBlockList[0], 1, 7), GregTech_API.getGregTechItem(0, 1, 18), GregTech_API.getGregTechItem(1, 1, 18), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Titanium", "Produced by centrifuging Bauxitedust", "as a byproduct, this Material can make", "anything much more resistant against", "damage, like Explosions.", "Blocks made of Titaniumingots have a", "large Blastresistance", "", "It can also be used to craft tons of", "mixed Metal Ingots", + "", "", "", "", "", "", "" }, new ItemStack[] { + new ItemStack(GregTech_API.sBlockList[0], 1, 8), GregTech_API.getGregTechItem(0, 1, 19), GregTech_API.getGregTechItem(1, 1, 19), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Iridium Ore", "You can find it only when you", "stripmine very large Areas with", "Quarries and such. There is only", "one in every 5th-10th Chunk.", "It's even more rare in Oceans!", "", "Some people disable the UUM-Recipe", "for Iridium, for making getting it", "an Achievement.", + "", "However Iridium Ore contains traces", "of Platinum, so it's best to use the", "Industrial Grinder for this Ore.", "", "", "" }, new ItemStack[] { + null, null, GT_OreDictUnificator.get("plateAlloyIridium", 1), GT_ModHandler.getIC2Item("iridiumOre", 1), new ItemStack(GregTech_API.sBlockList[2], 1, 2), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Helium Coolant Cell", "These are just cheaper, than the", "Water based Coolant Cells, and can", "also hold six times more Heat.", "", "Helium Cells can also be used for", "making Luminators and Mininglasers", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + GregTech_API.getGregTechItem(2, 1, 6), GregTech_API.getGregTechItem(2, 1, 3), GregTech_API.getGregTechItem(34, 1, 0), GregTech_API.getGregTechItem(35, 1, 0), GregTech_API.getGregTechItem(36, 1, 0), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Destructopack", "Open its GUI via rightclick and", "dump all the useless Stuff from", "your Inventory into it, instead of", "littering Items into the World.", "", "", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(33, 1, 0), null, null, null, null, null, + null, null, null, null });*/ + new GT_Computercube_Description(new String[] { + "Data Orbs", "They store Data.", "", "Rightclick on a Computer Cube, to", "extract a Reactorplan", "", "Sneak-Rightclick on it, to insert", "a Reactorplan", "", "Works also with Sonictrons", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, ItemList.Tool_DataOrb.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Energy Orbs", "100 Million EU in one Orb!", "", "This is a Tier-IV-Energystorage", "So a MFSU is not enough for it!", "", "Use it to create a Lapotron Pack,", "which is like an ultimate Lap Pack!", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, ItemList.Energy_LapotronicOrb.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Iridium Neutron Reflector", "It's used for Fusion Reactor Coils,", "and works like a normal one", "inside a Reactor, but it's also", "INDESTRUCTIBLE*.", "", "", "", "", "", + "", "", "", "", "", "", "* = for weardown" }, new ItemStack[] { + null, null, null, null, ItemList.Neutron_Reflector.get(1), null, null, null, null, null, + null, null, null, null }); + /*new GT_Computercube_Description(new String[] { + "Rock Cutter", "You want to get whole Blocks, but", "your Drill is not enchantable?", "The Rock Cutter has an awesome", "SilkTouch-III-Function!", "", "It works like a Drill, but you", "get the whole Block instead of", "'macerated' Ores!", "", + "Put those Blocks into a Macerator", "and double your Diamond Income!", "", "Or better. Use the Industrial", "Grinder to get even more", "Resources!", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(46, 1, 0), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Tesla Staff", "This completly untested PvP-Weapon", "destroys electric Armor in one hit", "", "The Energy Orb inside it must be", "fully charged to let this work.", "", "We are not responsible for any", "Electrocution Damage to yourself,", "while using it.", + "", "We also dont even know, if this", "Weapon has any effect AT ALL.", "", "", "", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(47, 1, 0), null, null, null, null, null, + null, null, null, null });*/ + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java index 59e6e78757..1a66698982 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java @@ -486,7 +486,7 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isOC) { + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { // Based on the Processing Array. A bit overkill, but very flexible. diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java index 5ff8330372..1d6d490fdf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java @@ -1,19 +1,18 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; + import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; -import gregtech.api.metatileentity.implementations.*; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gtPlusPlus.core.lib.CORE; -import org.apache.commons.lang3.ArrayUtils; import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; @@ -21,10 +20,16 @@ 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_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; @@ -233,6 +238,7 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase return super.checkRecipeGeneric(); } + @Override public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, int aEUPercent, diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java index f016288547..99386622a9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java @@ -1,10 +1,17 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + import java.util.ArrayList; import java.util.Collection; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; + import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -13,10 +20,21 @@ 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.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.*; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; @@ -31,10 +49,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; - public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlockBase { public static int sUUAperUUM = 1; @@ -353,13 +367,18 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo return true; } - return super.checkRecipeGeneric(c, getMaxParallelRecipes(), getEuDiscountForParallelism(), aSpeedBonusPercent, aOutputChanceRoll, true); + return super.checkRecipeGeneric(c, getMaxParallelRecipes(), getEuDiscountForParallelism(), aSpeedBonusPercent, aOutputChanceRoll); } //Return normal Recipe handling - return super.checkRecipeGeneric(aItemInputs, aFluidInputs, getMaxParallelRecipes(), getEuDiscountForParallelism(), aSpeedBonusPercent, aOutputChanceRoll, true); + return super.checkRecipeGeneric(aItemInputs, aFluidInputs, getMaxParallelRecipes(), getEuDiscountForParallelism(), aSpeedBonusPercent, aOutputChanceRoll); } + @Override + public boolean hasPerfectOverclock() { + return true; + } + @Override public int getMaxParallelRecipes() { return this.mMode == MODE_SCRAP ? 32 : 2 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 42912c4fa8..fe3ec43011 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -577,7 +577,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isOC) { + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { // Based on the Processing Array. A bit overkill, but very flexible. diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java index 11d5068374..033a5f925b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Collections; import Ic2ExpReactorPlanner.SimulationData; +import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.interfaces.ITexture; @@ -12,37 +13,26 @@ import gregtech.api.metatileentity.MetaTileEntity; 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_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.bartworks.BW_Utils; -import gtPlusPlus.xmod.goodgenerator.GG_Utils; import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_Container_ComputerCube; import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_GUIContainer_ComputerCube; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; +import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Description; import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Simulator; -import ic2.api.reactor.IReactor; -import ic2.api.reactor.IReactorComponent; import ic2.core.Ic2Items; -import ic2.core.init.MainConfig; -import ic2.core.util.ConfigUtil; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; 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.util.ChunkCoordinates; import net.minecraft.world.World; -public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank implements IReactor { +public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank { public static boolean mSeedscanner = true; @@ -56,11 +46,11 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl public int mHeat = 0; - public int mEUOut = 0; + public long mEUOut = 0; public int mMaxHeat = 10000; - public int mEU = 0; + public long mEU = 0; public int mProgress = 0; @@ -90,24 +80,14 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl @Override public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - try { - return new GT_Container_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); - } - catch (Throwable t) { - t.printStackTrace(); - return null; - } + Logger.INFO("CC-Sever ID: "+aID); + return new GT_Container_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); } @Override public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - try { - return new GT_GUIContainer_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); - } - catch (Throwable t) { - t.printStackTrace(); - return null; - } + Logger.INFO("CC-Client ID: "+aID); + return new GT_GUIContainer_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); } @Override @@ -115,9 +95,7 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl if (aBaseMetaTileEntity.isClientSide()) { return true; } - Logger.INFO("Did rmb."); - boolean aDidOpen = aBaseMetaTileEntity.openGUI(aPlayer); - Logger.INFO("Did open? "+aDidOpen); + aBaseMetaTileEntity.openGUI(aPlayer, mMode); return true; } @@ -284,123 +262,123 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl if (this.mMode == 6) { showElectrolyzerRecipe(0); } - //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), (GregTech_API.sBlockList[1]), 10, this.mMode); - //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), (GregTech_API.sBlockList[1]), 11, this.mMaxHeat); + this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 10, this.mMode); + this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 11, this.mMaxHeat); } public void showDescription(int aIndex) { this.mExplosionStrength = 0.0F; - if (GT_ComputercubeDescription.sDescriptions.isEmpty()) { + if (GT_Computercube_Description.sDescriptions.isEmpty()) { return; } - if (aIndex >= GT_ComputercubeDescription.sDescriptions.size() || aIndex < 0) + if (aIndex >= GT_Computercube_Description.sDescriptions.size() || aIndex < 0) aIndex = 0; - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[0] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[0] == null) { this.mInventory[59] = null; } else { - this.mInventory[59] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[0].copy(); + this.mInventory[59] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[0].copy(); } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[1] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[1] == null) { this.mInventory[60] = null; } else { - this.mInventory[60] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[1].copy(); + this.mInventory[60] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[1].copy(); } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[2] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[2] == null) { this.mInventory[61] = null; } else { - this.mInventory[61] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[2].copy(); + this.mInventory[61] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[2].copy(); } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[3] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[3] == null) { this.mInventory[62] = null; } else { - this.mInventory[62] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[3].copy(); + this.mInventory[62] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[3].copy(); } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[4] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[4] == null) { this.mInventory[63] = null; } else { - this.mInventory[63] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[4].copy(); + this.mInventory[63] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[4].copy(); } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[5] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[5] == null) { this.mInventory[64] = null; } else { - this.mInventory[64] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[5].copy(); + this.mInventory[64] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[5].copy(); this.mExplosionStrength = 100.0F; } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[6] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[6] == null) { this.mInventory[65] = null; } else { - this.mInventory[65] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[6].copy(); + this.mInventory[65] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[6].copy(); this.mExplosionStrength = 100.0F; } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[7] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[7] == null) { this.mInventory[66] = null; } else { - this.mInventory[66] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[7].copy(); + this.mInventory[66] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[7].copy(); this.mExplosionStrength = 100.0F; } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[8] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[8] == null) { this.mInventory[67] = null; } else { - this.mInventory[67] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[8].copy(); + this.mInventory[67] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[8].copy(); this.mExplosionStrength = 100.0F; } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[9] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[9] == null) { this.mInventory[68] = null; } else { - this.mInventory[68] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[9].copy(); + this.mInventory[68] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[9].copy(); this.mExplosionStrength = 100.0F; } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[10] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[10] == null) { this.mInventory[69] = null; } else { - this.mInventory[69] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[10].copy(); + this.mInventory[69] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[10].copy(); this.mExplosionStrength = 100.0F; } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[11] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[11] == null) { this.mInventory[70] = null; } else { - this.mInventory[70] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[11].copy(); + this.mInventory[70] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[11].copy(); this.mExplosionStrength = 100.0F; } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[12] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[12] == null) { this.mInventory[71] = null; } else { - this.mInventory[71] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[12].copy(); + this.mInventory[71] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[12].copy(); this.mExplosionStrength = 100.0F; } - if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[13] == null) { + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[13] == null) { this.mInventory[72] = null; } else { - this.mInventory[72] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[13].copy(); + this.mInventory[72] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[13].copy(); this.mExplosionStrength = 100.0F; } this.mMaxHeat = aIndex; - //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockList[1], 11, this.mMaxHeat); + this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 11, this.mMaxHeat); } public void switchDescriptionPageForward() { - if (++this.mMaxHeat >= GT_ComputercubeDescription.sDescriptions.size()) + if (++this.mMaxHeat >= GT_Computercube_Description.sDescriptions.size()) this.mMaxHeat = 0; showDescription(this.mMaxHeat); } public void switchDescriptionPageBackward() { if (--this.mMaxHeat < 0) - this.mMaxHeat = GT_ComputercubeDescription.sDescriptions.size() - 1; + this.mMaxHeat = GT_Computercube_Description.sDescriptions.size() - 1; showDescription(this.mMaxHeat); } @@ -563,7 +541,7 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl this.mHeat = tRecipe.mDuration; this.mMaxHeat = aIndex; } - //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockList[1], 11, this.mMaxHeat); + this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 11, this.mMaxHeat); } public void switchFusionPageForward() { @@ -599,33 +577,42 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl mSimulator.simulate(); } - public void storeAdditionalData(NBTTagCompound aNBT) { + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); aNBT.setInteger("mMode", this.mMode); aNBT.setInteger("mProgress", this.mProgress); aNBT.setBoolean("mStarted", this.mStarted); - aNBT.setInteger("mEU", this.mEU); + int[] aSplitLong1 = MathUtils.splitLongIntoTwoIntegers(mEU); + aNBT.setInteger("mEU1", aSplitLong1[0]); + aNBT.setInteger("mEU2", aSplitLong1[1]); aNBT.setInteger("mHeat", this.mHeat); - aNBT.setInteger("mEUOut", this.mEUOut); + int[] aSplitLong2 = MathUtils.splitLongIntoTwoIntegers(mEUOut); + aNBT.setInteger("mEUOut1", aSplitLong2[0]); + aNBT.setInteger("mEUOut2", aSplitLong2[1]); aNBT.setInteger("mMaxHeat", this.mMaxHeat); aNBT.setFloat("mHEM", this.mHEM); aNBT.setFloat("mExplosionStrength", this.mExplosionStrength); } - public void getAdditionalData(NBTTagCompound aNBT) { + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); this.mMode = aNBT.getInteger("mMode"); this.mProgress = aNBT.getInteger("mProgress"); this.mStarted = aNBT.getBoolean("mStarted"); - this.mEU = aNBT.getInteger("mEU"); + int partA = aNBT.getInteger("mEU1"); + int partB = aNBT.getInteger("mEU2"); + this.mEU = MathUtils.combineTwoIntegersToLong(partA, partB); this.mHeat = aNBT.getInteger("mHeat"); - this.mEUOut = aNBT.getInteger("mEUOut"); + partA = aNBT.getInteger("mEUOut1"); + partB = aNBT.getInteger("mEUOut2"); + this.mEUOut = MathUtils.combineTwoIntegersToLong(partA, partB); this.mMaxHeat = aNBT.getInteger("mMaxHeat"); this.mHEM = aNBT.getFloat("mHEM"); this.mExplosionStrength = aNBT.getFloat("mExplosionStrength"); } - public void onFirstTickUpdate() { - } - @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { super.onFirstTick(aBaseMetaTileEntity); @@ -634,6 +621,7 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); + if (mSimulator == null) { mSimulator = new GT_Computercube_Simulator(this); } @@ -741,16 +729,12 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl this.mEUOut = (this.mEUOut + this.mEULast1 + this.mEULast2 + this.mEULast3 + tEU) / 5; }*/ if (aTick % 20L == 0L) { - //this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 10, this.mMode); - //this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 10, this.mMode); + this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 11, this.mMaxHeat); } } } - private int getReactorEUOutput() { - return MathUtils.roundToClosestInt(getReactorEnergyOutput() * 5.0F * ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear")); - } - @Override public void receiveClientEvent(byte aEventID, byte aValue) { super.receiveClientEvent(aEventID, aValue); @@ -779,150 +763,20 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank impl this.mNeedsUpdate = true; } + @Override public boolean canInsertItem(int i, ItemStack itemstack, int j) { return (this.mMode == 2) ? ((i == 54 || i == 55)) : false; } + @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { return (this.mMode == 2) ? ((i == 56 || i == 57)) : false; } - public String getInvName() { - return "GregTech_Computercube"; - } - - public int getTexture(int aSide, int aMeta) { - switch (this.mMode) { - case 0 : - return 8; - case 1 : - return 46; - case 2 : - return 45; - } - return 48; - } - - @Override - public ChunkCoordinates getPosition() { - return new ChunkCoordinates(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); - } - - @Override - public int getHeat() { - return this.mHeat; - } - - @Override - public void setHeat(int aHeat) { - this.mHeat = aHeat; - } - - @Override - public int addHeat(int aAmount) { - this.mHeat += aAmount; - return this.mHeat; - } - - @Override - public int getMaxHeat() { - return this.mMaxHeat; - } - - @Override - public void setMaxHeat(int aMaxHeat) { - this.mMaxHeat = aMaxHeat; - } - - @Override - public float getHeatEffectModifier() { - return this.mHEM; - } - - @Override - public void setHeatEffectModifier(float aHEM) { - this.mHEM = aHEM; - } - - - public int addOutput(int aEnergy) { - this.mEUOut += aEnergy; - return this.mEUOut; - } - - @Override - public ItemStack getItemAt(int x, int y) { - if (x < 0 || x > 8 || y < 0 || y > 5) - return null; - return getStackInSlot(x + y * 9); - } - - @Override - public void setItemAt(int x, int y, ItemStack aStack) { - setInventorySlotContents(x + y * 9, aStack); - } - - @Override - public void explode() { - stopNuclearReactor(); - } - - @Override - public int getTickRate() { - return 1; - } - - @Override - public boolean produceEnergy() { - return true; - } - - public int getProgress() { - return this.mProgress; - } - - public int getMaxProgress() { - return (this.mProgress > 0) ? 100 : 0; - } - - @Override - public float addOutput(float aEnergy) { - this.mEUOut = (int) (this.mEUOut + aEnergy); - return this.mEUOut; - } - - @Override public World getWorld() { return this.getBaseMetaTileEntity().getWorld(); } - @Override - public void addEmitHeat(int heat) { - - } - - @Override - public float getReactorEnergyOutput() { - return this.mEUOut; - } - - @Override - public double getReactorEUEnergyOutput() { - return 0; - } - - @Override - public void setRedstoneSignal(boolean redstone) { - - } - - @Override - public boolean isFluidCooled() { - return false; - } - - - @Override public boolean doesFillContainers() { return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java index 5c34ce70fe..c4a27079f7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java @@ -5,7 +5,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; +import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Description; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricAutoWorkbench; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; -- cgit From bfbd1eb3123fefeb5dc66f29eb3b8ae18af6bb88 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 20 Jan 2022 17:17:04 +0000 Subject: Fixed Industrial Forge Hammer structure check. Fixed Creative Energy Buffer some more. Fixed Redstone Circuit Block output. Did a little work on breaker boxes. --- .../transformers/ClassTransformer_GT_Client.java | 35 +++++------ .../api/interfaces/IBaseCustomMetaTileEntity.java | 7 +++ .../api/metatileentity/BaseCustomTileEntity.java | 17 +++++- .../custom/power/BaseCustomPower_MTE.java | 36 ++++++----- .../custom/power/GTPP_MTE_TieredMachineBlock.java | 1 - .../custom/power/MetaTileEntityCustomPower.java | 19 +++--- .../GT_MetaTileEntity_BasicBreaker.java | 70 +++++++++++----------- .../implementations/base/CustomMetaTileBase.java | 36 ++++++++++- .../xmod/gregtech/common/Meta_GT_Proxy.java | 8 ++- .../creative/GregtechMetaCreativeEnergyBuffer.java | 20 +++++-- ...egtechMetaTileEntity_IndustrialForgeHammer.java | 43 ++++++++----- .../redstone/GT_MetaTileEntity_RedstoneBase.java | 2 +- .../GT_MetaTileEntity_RedstoneCircuitBlock.java | 48 +++++++++++++-- .../storage/GregtechMetaEnergyBuffer.java | 2 +- .../gregtech/GregtechPowerBreakers.java | 5 +- 15 files changed, 240 insertions(+), 109 deletions(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IBaseCustomMetaTileEntity.java (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java b/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java index e2d34c38e7..25ec9a8338 100644 --- a/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java +++ b/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java @@ -383,23 +383,24 @@ public class ClassTransformer_GT_Client { * GT_Client's onPostLoad */ - public static void onPostLoad() { - try { - for (int i = 0; i < GregTech_API.METATILEENTITIES.length; i++) { - try { - if (GregTech_API.METATILEENTITIES[i] != null) { - GregTech_API.METATILEENTITIES[i].getStackForm(1L).getTooltip((EntityPlayer) null, true); - } - } - catch (Throwable t) { - GT_Log.err.println("Error in MetaTileEntity with ID of "+i); - t.printStackTrace(GT_Log.err); - } - } - } catch (Throwable var2) { - var2.printStackTrace(); - } - } + public static void onPostLoad() { + try { + for (int i = 0; i < GregTech_API.METATILEENTITIES.length; i++) { + try { + if (GregTech_API.METATILEENTITIES[i] != null) { + GregTech_API.METATILEENTITIES[i].getStackForm(1L).getTooltip((EntityPlayer) null, true); + } + } + catch (Throwable t) { + GT_Log.err.println("Error in MetaTileEntity with ID of " + i); + t.printStackTrace(GT_Log.err); + } + } + } + catch (Throwable var2) { + var2.printStackTrace(); + } + } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IBaseCustomMetaTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IBaseCustomMetaTileEntity.java new file mode 100644 index 0000000000..71d15e6e77 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IBaseCustomMetaTileEntity.java @@ -0,0 +1,7 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces; + +public interface IBaseCustomMetaTileEntity { + + public boolean doesExplode(); + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index 6967c8eb33..5ccbd8cb2d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -15,6 +15,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.interfaces.IBaseCustomMetaTileEntity; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import ic2.api.Direction; @@ -22,7 +23,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class BaseCustomTileEntity extends BaseMetaTileEntity { +public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCustomMetaTileEntity { protected NBTTagCompound mRecipeStuff2; private static final Field ENTITY_ITEM_HEALTH_FIELD_2; @@ -49,6 +50,10 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { super(); Logger.MACHINE_INFO("Created new BaseCustomTileEntity"); } + + public boolean doesExplode() { + return true; + } public void writeToNBT(NBTTagCompound aNBT) { try { @@ -70,6 +75,10 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { } public void doEnergyExplosion() { + if (!doesExplode()) { + Logger.INFO("Machine tried to explode, let's stop that. xo [doEnergyExplosion]"); + return; + } if (this.getUniversalEnergyCapacity() > 0L && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) { this.doExplosion( @@ -83,6 +92,12 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { } public void doExplosion(long aAmount) { + + if (!doesExplode()) { + Logger.INFO("Machine tried to explode, let's stop that. xo [doExplosion]"); + return; + } + if (this.canAccessData()) { if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { try { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java index a4440114e8..d600d0baca 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java @@ -10,34 +10,38 @@ public class BaseCustomPower_MTE extends BaseCustomTileEntity { public BaseCustomPower_MTE() { super(); - Logger.MACHINE_INFO("Created new BaseCustomPower_MTE"); + Logger.INFO("Created new BaseCustomPower_MTE"); + } + + public boolean doesExplode() { + return false; } public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { if (mMetaTileEntity == null) { - Logger.MACHINE_INFO("Bad Tile"); + Logger.INFO("Bad Tile"); } if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.inputEnergyFrom(aSide) && aAmperage > 0L && aVoltage > 0L && this.getStoredEU() < this.getEUCapacity() && this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage()) { - Logger.MACHINE_INFO("Injecting Energy Units"); + Logger.INFO("Injecting Energy Units"); return super.injectEnergyUnits(aSide, aVoltage, aAmperage); } else { - Logger.MACHINE_INFO("canAccessData(): "+canAccessData()); - Logger.MACHINE_INFO("isElectric(): "+this.mMetaTileEntity.isElectric()); - Logger.MACHINE_INFO("InputEnergyFromSide("+aSide+"): "+this.inputEnergyFrom(aSide)); - Logger.MACHINE_INFO("aAmperage: "+aAmperage); - Logger.MACHINE_INFO("aVoltage: "+aVoltage); - Logger.MACHINE_INFO("this.getStoredEU() < this.getEUCapacity(): "+(this.getStoredEU() < this.getEUCapacity())); - Logger.MACHINE_INFO("this.mMetaTileEntity.maxAmperesIn() >= this.mAcceptedAmperes: "+(this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage())); - Logger.MACHINE_INFO("this.mMetaTileEntity.maxAmperesIn(): "+(this.mMetaTileEntity.maxAmperesIn())); - Logger.MACHINE_INFO("this.mAcceptedAmperes: "+(this.getInputAmperage())); + Logger.INFO("canAccessData(): "+canAccessData()); + Logger.INFO("isElectric(): "+this.mMetaTileEntity.isElectric()); + Logger.INFO("InputEnergyFromSide("+aSide+"): "+this.inputEnergyFrom(aSide)); + Logger.INFO("aAmperage: "+aAmperage); + Logger.INFO("aVoltage: "+aVoltage); + Logger.INFO("this.getStoredEU() < this.getEUCapacity(): "+(this.getStoredEU() < this.getEUCapacity())); + Logger.INFO("this.mMetaTileEntity.maxAmperesIn() >= this.mAcceptedAmperes: "+(this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage())); + Logger.INFO("this.mMetaTileEntity.maxAmperesIn(): "+(this.mMetaTileEntity.maxAmperesIn())); + Logger.INFO("this.mAcceptedAmperes: "+(this.getInputAmperage())); return 0L; } } public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - Logger.MACHINE_INFO("Draining Energy Units 4"); + Logger.INFO("Draining Energy Units 4"); if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.outputsEnergyTo(aSide) && this.getStoredEU() - aVoltage * aAmperage >= this.mMetaTileEntity.getMinimumStoredEU()) { if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { @@ -54,7 +58,7 @@ public class BaseCustomPower_MTE extends BaseCustomTileEntity { @Override public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { - Logger.MACHINE_INFO("Draining Energy Units 3"); + Logger.INFO("Draining Energy Units 3"); // TODO Auto-generated method stub return super.decreaseStoredEnergyUnits(aEnergy, aIgnoreTooLessEnergy); } @@ -73,7 +77,7 @@ public class BaseCustomPower_MTE extends BaseCustomTileEntity { @Override public boolean outputsEnergyTo(byte aSide) { - Logger.MACHINE_INFO("Draining Energy Units 2"); + Logger.INFO("Draining Energy Units 2"); // TODO Auto-generated method stub return super.outputsEnergyTo(aSide); } @@ -134,7 +138,7 @@ public class BaseCustomPower_MTE extends BaseCustomTileEntity { @Override public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { - Logger.MACHINE_INFO("Draining Energy Units 1"); + Logger.INFO("Draining Energy Units 1"); // TODO Auto-generated method stub return super.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java index 785c4698db..8110037c46 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java @@ -79,7 +79,6 @@ public abstract class GTPP_MTE_TieredMachineBlock extends MetaTileEntityCustomPo @Override public String[] getDescription() { - AutoMap aTooltip = new AutoMap(); String []s1 = null; s1 = new String[aTooltip.size()]; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java index 8b7ccc202a..31d24ff343 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java @@ -4,7 +4,6 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.CustomMetaTileBase; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.entity.Entity; @@ -16,6 +15,7 @@ public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase { public MetaTileEntityCustomPower(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { super(aID, aBasicName, aRegionalName, aInvSlotCount); this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower()); + this.getBaseMetaTileEntity().setMetaTileID((short) aID); } public MetaTileEntityCustomPower(String aStack, int aInvSlotCount) { @@ -25,11 +25,17 @@ public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase { public long getMinimumStoredEU() { return 0L; } + + public boolean doesExplode() { + return this.getBaseCustomMetaTileEntity().doesExplode(); + } + + public void doExplosion(long aExplosionPower) { - if (MathUtils.randInt(1, 10) > 0) { - //Logger.INFO("Machine tried to explode, let's stop that. xo"); + if (!doesExplode()) { + Logger.INFO("Machine tried to explode, let's stop that. xo [doExplosion]"); return; } @@ -68,12 +74,10 @@ public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase { @Override public void onExplosion() { - - if (MathUtils.randInt(1, 10) > 0) { - //Logger.INFO("Machine tried to explode, let's stop that. xo"); + if (!doesExplode()) { + Logger.INFO("Machine tried to explode, let's stop that. xo [onExplosion]"); return; } - // TODO Auto-generated method stub super.onExplosion(); } @@ -84,7 +88,6 @@ public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase { @Override public long getEUVar() { - // TODO Auto-generated method stub return super.getEUVar(); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java index e6bf4b8486..3821b2a95c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java @@ -9,8 +9,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.GTPP_MTE_TieredMachineBlock; import ic2.api.item.ElectricItem; @@ -19,9 +17,10 @@ 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.util.EnumChatFormatting; public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock { - + public boolean mCharge = false; public boolean mDecharge = false; public int mBatteryCount = 0; @@ -30,53 +29,50 @@ public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock private long mStored = 0L; private long mMax = 0L; - public GT_MetaTileEntity_BasicBreaker(int aID, String aName, String aNameRegional, int aTier, - String aDescription, int aSlotCount) { + public GT_MetaTileEntity_BasicBreaker(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription, new ITexture[0]); } - public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String aDescription, ITexture[][][] aTextures, - int aSlotCount) { + public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { super(aName, aTier, aSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String[] aDescription, - ITexture[][][] aTextures, int aSlotCount) { + public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { super(aName, aTier, aSlotCount, aDescription, aTextures); } public String[] getDescription() { - String []s1 = super.getDescription(); - s1 = new String[0]; - return s1; + final String[] desc = new String[6]; + int tTier = this.mTier; + desc[0] = "" + EnumChatFormatting.BOLD + "16 Fuse Slots"; + desc[1] = "Per each fuse, you may insert " + EnumChatFormatting.YELLOW + (GT_Values.V[tTier]) + EnumChatFormatting.GRAY + " EU/t"; + desc[2] = "However this " + EnumChatFormatting.ITALIC + EnumChatFormatting.RED + "MUST" + EnumChatFormatting.GRAY + " be in a single Amp"; + desc[3] = "This machine can accept upto a single amp of " + GT_Values.VN[Math.min(tTier + 2, 15)] + " as a result"; + desc[4] = "Breaker Loss: " + EnumChatFormatting.RED + "" + (GT_Values.V[tTier] / 16) + EnumChatFormatting.GRAY + " EU/t"; + desc[5] = CORE.GT_Tooltip; + return desc; } public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[2][17][]; for (byte i = -1; i < 16; ++i) { - rTextures[0][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], - this.mInventory.length > 4 - ? BlockIcons.OVERLAYS_ENERGY_IN_MULTI[Math.min(12, mTier)] - : BlockIcons.OVERLAYS_ENERGY_IN[Math.min(12, mTier)]}; - - rTextures[1][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], - this.mInventory.length > 4 - ? BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] - : BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + rTextures[0][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i + + 1], this.mInventory.length > 4 ? BlockIcons.OVERLAYS_ENERGY_IN_MULTI[Math.min(12, mTier)] : BlockIcons.OVERLAYS_ENERGY_IN[Math.min(12, mTier)]}; + + rTextures[1][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i + + 1], this.mInventory.length > 4 ? BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] : BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; } return rTextures; } - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; } public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_BasicBreaker(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, - this.mInventory.length); + return new GT_MetaTileEntity_BasicBreaker(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mInventory.length); } public boolean isSimpleMachine() { @@ -132,11 +128,11 @@ public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock } public long maxAmperesIn() { - return (long) (1); + return 16; } public long maxAmperesOut() { - return (long) 16; + return 16; } public int rechargerSlotStartIndex() { @@ -176,7 +172,8 @@ public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) { return true; - } else { + } + else { aBaseMetaTileEntity.openGUI(aPlayer); return true; } @@ -199,14 +196,14 @@ public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock this.mChargeableCount = 0; ItemStack[] arg3 = this.mInventory; int arg4 = arg3.length; - + for (int arg5 = 0; arg5 < arg4; ++arg5) { ItemStack tStack = arg3[arg5]; if (GT_ModHandler.isElectricItem(tStack, this.mTier)) { if (GT_ModHandler.isChargerItem(tStack)) { ++this.mBatteryCount; } - + ++this.mChargeableCount; } }*/ @@ -254,7 +251,8 @@ public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock tStored += tStep; } - } else if (aStack.getItem() instanceof IElectricItem) { + } + else if (aStack.getItem() instanceof IElectricItem) { tStored += (long) ElectricItem.manager.getCharge(aStack); tScale += (long) ((IElectricItem) aStack.getItem()).getMaxCharge(aStack); } @@ -273,11 +271,15 @@ public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock return new long[]{tStored, tScale}; } - public String[] getInfoData() { - return new String[]{}; + public String[] getInfoData() { + return new String[]{"Tile Type: " + this.getTileEntityBaseType()}; } public boolean isGivingInformation() { return true; } -} \ No newline at end of file + + public boolean doesExplode() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java index 422837fa46..fdc8a7777b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java @@ -2,20 +2,52 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; import java.util.Locale; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.util.GT_LanguageManager; -import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.interfaces.IBaseCustomMetaTileEntity; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.item.ItemStack; public abstract class CustomMetaTileBase extends MetaTileEntity { + + private IBaseCustomMetaTileEntity mBaseCustomMetaTileEntity2; + + /** + * accessibility to this Field is no longer given, see below + */ + private IGregTechTileEntity mBaseCustomMetaTileEntity; + public CustomMetaTileBase(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { super(aID, aBasicName, aRegionalName, aInvSlotCount); GT_LanguageManager.addStringLocalization("gtpp.blockmachines." + aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH) + ".name", aRegionalName); this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntity()); - this.getBaseMetaTileEntity().setMetaTileID((short) aID); + this.getBaseMetaTileEntity().setMetaTileID((short) aID); + mBaseCustomMetaTileEntity2 = (IBaseCustomMetaTileEntity) getBaseMetaTileEntity(); } + + @Override + public IGregTechTileEntity getBaseMetaTileEntity() { + return mBaseCustomMetaTileEntity; + } + + public IBaseCustomMetaTileEntity getBaseCustomMetaTileEntity() { + return mBaseCustomMetaTileEntity2; + } + + @Override + public void setBaseMetaTileEntity(IGregTechTileEntity aBaseMetaTileEntity) { + super.setBaseMetaTileEntity(aBaseMetaTileEntity); + if (mBaseCustomMetaTileEntity != null && aBaseMetaTileEntity == null) { + mBaseCustomMetaTileEntity.getMetaTileEntity().inValidate(); + mBaseCustomMetaTileEntity.setMetaTileEntity(null); + } + mBaseCustomMetaTileEntity = aBaseMetaTileEntity; + if (mBaseCustomMetaTileEntity != null) { + mBaseCustomMetaTileEntity.setMetaTileEntity(this); + } + } public CustomMetaTileBase(String aName, int aInvSlotCount) { super(aName, aInvSlotCount); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 091ee734e6..fe0be2f126 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -90,8 +90,8 @@ public class Meta_GT_Proxy { GT_Log.out.println("GT++ Mod: Testing BaseMetaTileEntity."); if (tBaseMetaTileEntity == null || tBaseMetaTileEntity2 == null) { - GT_Log.out.println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); - throw new RuntimeException(""); + GT_Log.err.println("GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); + CORE.crash("GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); } //Gotta set it here so that we don't try call gregtech too early. @@ -104,7 +104,7 @@ public class Meta_GT_Proxy { StaticFields59.mGT6StylePipes = false; } - GT_Log.out.println("GT++ Mod: Registering the BaseMetaTileEntity."); + GT_Log.out.println("GT++ Mod: Registering custom BaseMetaTileEntities."); GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntity_GTPP"); GameRegistry.registerTileEntity(tBaseMetaTileEntity2.getClass(), "BaseMetaTileEntity_GTPP2"); CoverManager.generateCustomCovers(); @@ -361,6 +361,7 @@ public class Meta_GT_Proxy { GT_Log.err .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); e.printStackTrace(GT_Log.err); + CORE.crash("GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); throw new RuntimeException(e); } } @@ -396,6 +397,7 @@ public class Meta_GT_Proxy { GT_Log.err .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); e.printStackTrace(GT_Log.err); + CORE.crash("GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); throw new RuntimeException(e); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java index 2e4e1ce7dd..087da7465d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java @@ -11,6 +11,7 @@ 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_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; @@ -25,6 +26,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -59,13 +61,13 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { CustomIcon h = TexturesGtBlock.Casing_Material_RedSteel; CustomIcon g = TexturesGtBlock.Casing_Material_Grisium; CustomIcon k; - boolean j = MathUtils.isNumberEven(this.mTier); + boolean j = MathUtils.isNumberEven(this.mVoltageTier); final ITexture[][][] rTextures = new ITexture[2][17][]; k = j ? g : h; for (byte i = -1; i < 16; i++) { rTextures[0][i + 1] = new ITexture[]{new GT_RenderedTexture(k)}; rTextures[1][i - + 1] = new ITexture[]{new GT_RenderedTexture(k), this.mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + + 1] = new ITexture[]{new GT_RenderedTexture(k), this.mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mVoltageTier] : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mVoltageTier]}; } return rTextures; } @@ -75,6 +77,16 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; } + @Override + protected void showEnergy(final World worldIn, final EntityPlayer playerIn){ + final long tempStorage = this.getBaseMetaTileEntity().getStoredEU(); + final double c = ((double) tempStorage / this.maxEUStore()) * 100; + final double roundOff = Math.round(c * 100.00) / 100.00; + PlayerUtils.messagePlayer(playerIn, "Energy: " + GT_Utility.formatNumbers(tempStorage) + " EU at "+V[this.mVoltageTier]+"v ("+roundOff+"%)"); + PlayerUtils.messagePlayer(playerIn, "Amperage: " + GT_Utility.formatNumbers(maxAmperesOut())+"A"); + + } + @Override public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { return new GregtechMetaCreativeEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); @@ -153,7 +165,7 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { @Override public String[] getInfoData() { String[] infoData = super.getInfoData(); - return new String[]{infoData[0], "THIS IS A CREATIVE ITEM - FOR TESTING | Tier: " + this.mTier, infoData[1], infoData[2]}; + return new String[]{infoData[0], "THIS IS A CREATIVE ITEM - FOR TESTING | Tier: " + this.mVoltageTier, infoData[1], infoData[2]}; } @Override @@ -214,7 +226,7 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { t.printStackTrace(); Logger.REFLECTION("Bad mTextures setter."); } - PlayerUtils.messagePlayer(aPlayer, "Now running at " + GT_Values.VOLTAGE_NAMES[this.mTier] + "."); + PlayerUtils.messagePlayer(aPlayer, "Now running at " + GT_Values.VOLTAGE_NAMES[this.mVoltageTier] + "."); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java index b354d55a83..2b0345af78 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java @@ -3,7 +3,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -import java.util.ArrayList; +import java.util.*; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -44,6 +44,7 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends GregtechMeta_M @Override public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + setAnvilBlocks(); return new GregtechMetaTileEntity_IndustrialForgeHammer(this.mName); } @@ -85,7 +86,19 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends GregtechMeta_M @Override public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { + if (STRUCTURE_DEFINITION == null) { + Map aBlockMap = new HashMap(); + aBlockMap.put(sAnvil, 0); + if (LoadedMods.Railcraft) { + aBlockMap.put(sSteelAnvil, 0); + } + if (LoadedMods.EnderIO) { + aBlockMap.put(sDarkSteelAnvil, 0); + } + if (LoadedMods.ThaumicBases) { + aBlockMap.put(sThaumiumAnvil, 0); + aBlockMap.put(sVoidAnvil, 0); + } STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape(mName, transpose(new String[][]{ {"CCC", "CCC", "CCC"}, @@ -93,21 +106,12 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends GregtechMeta_M {"CCC", "CCC", "CCC"}, })) .addElement('C', ofChain( - ofHatchAdder(GregtechMetaTileEntity_IndustrialForgeHammer::addIndustrialForgeHammerList, TAE.getIndexFromPage(1, 11), 1 ), - onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 6) - ) + ofHatchAdder(GregtechMetaTileEntity_IndustrialForgeHammer::addIndustrialForgeHammerList, TAE.getIndexFromPage(1, 11), 1 ), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 6) ) ) - .addElement('A', ofChain( - onElementPass(x -> ++x.mAnvil, ofBlock(sAnvil, 1)), - onElementPass(x -> ++x.mAnvil, ofBlock(sSteelAnvil, 1)), - onElementPass(x -> ++x.mAnvil, ofBlock(sDarkSteelAnvil, 1)), - onElementPass(x -> ++x.mAnvil, ofBlock(sThaumiumAnvil, 1)), - onElementPass(x -> ++x.mAnvil, ofBlock(sVoidAnvil, 1)) ) - ) - //.addElement('A', ofBlockAdder(GregtechMetaTileEntity_IndustrialForgeHammer::isBlockAnvil, Blocks.anvil, 1)) - + .addElement('A', onElementPass(x -> ++x.mAnvil, ofBlocksFlat(aBlockMap, sAnvil, 0))) .build(); } return STRUCTURE_DEFINITION; @@ -115,11 +119,13 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends GregtechMeta_M @Override public void construct(ItemStack stackSize, boolean hintsOnly) { + setAnvilBlocks(); buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + setAnvilBlocks(); mCasing = 0; return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); } @@ -137,7 +143,8 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends GregtechMeta_M return addToMachineList(aTileEntity, aBaseCasingIndex); } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { return addToMachineList(aTileEntity, aBaseCasingIndex); } } @@ -303,4 +310,10 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends GregtechMeta_M return 0; } + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + setAnvilBlocks(); + super.onFirstTick(aBaseMetaTileEntity); + } + } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java index e15b0b6426..9bb2443683 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java @@ -88,7 +88,7 @@ public abstract class GT_MetaTileEntity_RedstoneBase extends GT_MetaTileEntity_T mOpenerCount--; } - public final boolean hasRedstoneSignal() { + public boolean hasRedstoneSignal() { if (getBaseMetaTileEntity().getStrongestRedstone() > 0) { return true; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java index 180091b2eb..379345ec6a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java @@ -4,6 +4,8 @@ import java.util.*; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.IRedstoneCircuitBlock; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -67,7 +69,7 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re @Override public boolean isInputFacing(byte aSide) { - return true; + return !this.isOutputFacing(aSide); } @Override @@ -87,7 +89,7 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re @Override public boolean isOutputFacing(byte aSide) { - return true; + return aSide == this.getOutputFacing(); } @Override @@ -286,6 +288,36 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re } } } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + //Only Calc server-side + if (!this.getBaseMetaTileEntity().isServerSide()) { + return; + } + //Emit Redstone + for (byte i=0;i<6;i++) { + byte aRedstone = getBaseMetaTileEntity().getOutputRedstoneSignal(i); + this.getBaseMetaTileEntity().setInternalOutputRedstoneSignal(i, aRedstone); + } + + } + + @Override + public final boolean hasRedstoneSignal() { + for (byte i=0;i<6;i++) { + if (getBaseMetaTileEntity().getOutputRedstoneSignal(i) > 0) { + return true; + } + } + return false; + } + + @Override + public boolean allowGeneralRedstoneOutput() { + return true; + } /** The Item List for Covers */ public static final Map sCoversItems = new HashMap(); @@ -408,12 +440,12 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re final ITexture[][][] rTextures = new ITexture[10][17][]; for (byte i = -1; i < 16; i++) { rTextures[0][i + 1] = this.getSides(i); - rTextures[1][i + 1] = this.getSides(i); + rTextures[1][i + 1] = this.getBack(i); rTextures[2][i + 1] = this.getBottom(i); rTextures[3][i + 1] = this.getTop(i); rTextures[4][i + 1] = this.getSides(i); rTextures[5][i + 1] = this.getSidesActive(i); - rTextures[6][i + 1] = this.getSidesActive(i); + rTextures[6][i + 1] = this.getBackActive(i); rTextures[7][i + 1] = this.getBottomActive(i); rTextures[8][i + 1] = this.getTopActive(i); rTextures[9][i + 1] = this.getSidesActive(i); @@ -438,6 +470,14 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re public ITexture[] getTopActive(final byte aColor) { return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On)}; } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off), new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red)}; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On), new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red_Redstone)}; + } public ITexture[] getBottom(final byte aColor) { return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off)}; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java index 5c7cfed334..e18f5d4bfc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java @@ -250,7 +250,7 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { return true; } - private void showEnergy(final World worldIn, final EntityPlayer playerIn){ + protected void showEnergy(final World worldIn, final EntityPlayer playerIn){ final long tempStorage = this.getBaseMetaTileEntity().getStoredEU(); final double c = ((double) tempStorage / this.maxEUStore()) * 100; final double roundOff = Math.round(c * 100.00) / 100.00; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerBreakers.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerBreakers.java index 3e9582b80a..7a71707f24 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerBreakers.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerBreakers.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import gregtech.api.enums.GT_Values; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBreaker; @@ -26,7 +27,7 @@ public class GregtechPowerBreakers { GregtechItemList.BreakerBox_HV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.03", "High Voltage Breaker Box", 3, "", 16)).getStackForm(1L)); GregtechItemList.BreakerBox_EV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.04", - "Extreme Voltage Breaker Box", 16, "", 16)).getStackForm(1L)); + "Extreme Voltage Breaker Box", 4, "", 16)).getStackForm(1L)); GregtechItemList.BreakerBox_IV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.05", "Insane Voltage Breaker Box", 5, "", 16)).getStackForm(1L)); GregtechItemList.BreakerBox_LuV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.06", @@ -36,7 +37,7 @@ public class GregtechPowerBreakers { GregtechItemList.BreakerBox_UV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.08", "Ultimate Voltage Breaker Box", 8, "", 16)).getStackForm(1L)); GregtechItemList.BreakerBox_MAX.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.09", - "MAX Voltage Breaker Box", 9, "", 16)).getStackForm(1L)); + GT_Values.VN[9]+" Breaker Box", 9, "", 16)).getStackForm(1L)); } } \ No newline at end of file -- cgit