diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-20 17:17:04 +0000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-20 17:17:04 +0000 |
commit | bfbd1eb3123fefeb5dc66f29eb3b8ae18af6bb88 (patch) | |
tree | 76bf3e2f76be046a1f2a52f23111af73aab3ff91 /src | |
parent | 185f91e25a64c3832f8287cf70a3c3a01a1dd90c (diff) | |
download | GT5-Unofficial-bfbd1eb3123fefeb5dc66f29eb3b8ae18af6bb88.tar.gz GT5-Unofficial-bfbd1eb3123fefeb5dc66f29eb3b8ae18af6bb88.tar.bz2 GT5-Unofficial-bfbd1eb3123fefeb5dc66f29eb3b8ae18af6bb88.zip |
Fixed Industrial Forge Hammer structure check.
Fixed Creative Energy Buffer some more.
Fixed Redstone Circuit Block output.
Did a little work on breaker boxes.
Diffstat (limited to 'src')
15 files changed, 240 insertions, 109 deletions
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<String> aTooltip = new AutoMap<String>(); 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; } @@ -76,6 +78,16 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { } @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<GregtechMetaTileEntity_IndustrialForgeHammer> getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { + if (STRUCTURE_DEFINITION == null) { + Map<Block, Integer> aBlockMap = new HashMap<Block, Integer>(); + 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.<GregtechMetaTileEntity_IndustrialForgeHammer>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<Integer, ItemStack> sCoversItems = new HashMap<Integer, ItemStack>(); @@ -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 |