diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-05-12 16:04:15 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-05-12 16:04:15 +1000 |
commit | d30f18947a5c5e275ef7f17323ac837939cb0135 (patch) | |
tree | a46120eaace0b136e056e55d53add6129d8e877b /src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations | |
parent | 3615baf8ffb7a2efc44d4770da97ce1337f7801e (diff) | |
download | GT5-Unofficial-d30f18947a5c5e275ef7f17323ac837939cb0135.tar.gz GT5-Unofficial-d30f18947a5c5e275ef7f17323ac837939cb0135.tar.bz2 GT5-Unofficial-d30f18947a5c5e275ef7f17323ac837939cb0135.zip |
% More work on Advanced Mufflers.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java | 118 |
1 files changed, 90 insertions, 28 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java index 0479914115..4052a5c266 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -10,6 +11,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.general.ItemAirFilter; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_Hatch_Muffler_Advanced; import gtPlusPlus.xmod.gregtech.api.gui.GUI_Hatch_Muffler_Advanced; import gtPlusPlus.xmod.gregtech.common.StaticFields59; @@ -44,26 +46,30 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch public GT_MetaTileEntity_Hatch_Muffler_Adv(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription[0], aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public String[] getDescription() { if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { String[] mDescArray = StaticFields59.getDescriptionArray(this); - String[] desc = new String[mDescArray.length + 5]; + String[] desc = new String[mDescArray.length + 6]; System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length); desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; desc[mDescArray.length + 1] = "Requires 3 Air on the exhaust face"; desc[mDescArray.length + 2] = "Requires Air Filters"; - desc[mDescArray.length + 3] = "Reduces Pollution to " + this.calculatePollutionReduction(100) + "%"; - desc[mDescArray.length + 4] = "Recovers " + (105 - this.calculatePollutionReduction(100)) + desc[mDescArray.length + 3] = "Mufflers require T2 Filters from IV-"+GT_Values.VN[9]; + desc[mDescArray.length + 4] = "Reduces Pollution to " + this.calculatePollutionReductionForTooltip(100) + "%"; + desc[mDescArray.length + 5] = "Recovers " + (105 - this.calculatePollutionReductionForTooltip(100)) + "% of CO2/CO/SO2"; return desc; } @@ -81,7 +87,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public boolean isValidSlot(int aIndex) { - return false; + return aIndex == SLOT_FILTER; } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -104,7 +110,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "machine_Charger.png"); + return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, "Advanced Muffler", "machine_Charger.png"); } private boolean airCheck() { @@ -119,7 +125,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public boolean polluteEnvironment() { - if (airCheck()) { + if (airCheck() && damageAirFilter()) { int aEmission = this.calculatePollutionReduction(10000); PollutionUtils.addPollution(this.getBaseMetaTileEntity(), aEmission); //Logger.INFO("Outputting "+aEmission+"gbl"); @@ -130,6 +136,11 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } } + + public int calculatePollutionReductionForTooltip(int aPollution) { + return (int) (aPollution * Math.pow(0.64D, (double) (this.mTier - 1))); + } + public int calculatePollutionReduction(int aPollution) { double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1)); int aVal2 = (int) aVal1; @@ -148,21 +159,69 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch return false; } + private ItemStack getInventoryStack() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length-1 >= this.SLOT_FILTER) { + return this.mInventory[this.SLOT_FILTER]; + } + } + return null; + } + + private void breakAirFilter() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length-1 >= this.SLOT_FILTER) { + Logger.INFO("Breaking Filter"); + this.mInventory[this.SLOT_FILTER] = null; + } + } + } + public boolean hasValidFilter() { - return isAirFilter(this.mInventory[this.SLOT_FILTER]); + return isAirFilter(getInventoryStack()); } - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + + //Logger.INFO("A1"); + super.onPostTick(aBaseMetaTileEntity, aTick); - String aParticleName; - if (hasValidFilter()) { - aParticleName = "cloud"; - } else { - aParticleName = "smoke"; + + //Logger.INFO("A2"); + + String aParticleName; + if ((aTick % 2) == 0){ + aParticleName = "cloud"; } - if (aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) { - this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); + else { + aParticleName = "smoke"; + } + + //Logger.INFO("A3"); + + if (aBaseMetaTileEntity.isClientSide()) { + //Logger.INFO("B1"); + if (this.getBaseMetaTileEntity().isActive()) { + //Logger.INFO("C1"); + this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); + } + //return; + } + else { + //Logger.INFO("B2"); + if (this.getInventoryStack() == null) { + //Logger.INFO("D1"); + //Logger.INFO("Empty - "+this.mInventory.length); + } + else { + //Logger.INFO("D2"); + Logger.INFO("Has Item"); + } } + //Logger.INFO("A4"); + + + } public boolean isAirFilter(ItemStack filter){ @@ -170,39 +229,42 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch return false; } if (filter.getItem() instanceof ItemAirFilter){ - return true; + + if (this.mTier < 5) { + return true; + } + else { + if (filter.getItemDamage() == 1) { + return true; + } + } } return false; } - public boolean damageAirFilter(){ - ItemStack filter = this.mInventory[this.SLOT_FILTER]; + public boolean damageAirFilter(){ + ItemStack filter = getInventoryStack(); if (filter == null) { return false; } if (isAirFilter(filter)){ long currentUse = ItemAirFilter.getFilterDamage(filter); + Logger.INFO("Filter Damage: "+currentUse); //Remove broken Filter - if (filter.getItemDamage() == 0 && currentUse >= 50-1){ - this.mInventory[this.SLOT_FILTER] = null; + if ((filter.getItemDamage() == 0 && currentUse >= 50-1) || (filter.getItemDamage() == 1 && currentUse >= 2500-1)){ + breakAirFilter(); return false; - } - else if (filter.getItemDamage() == 1 && currentUse >= 2500-1){ - this.mInventory[this.SLOT_FILTER] = null; - return false; - } + } else { //Do Damage ItemAirFilter.setFilterDamage(filter, currentUse+1); - Logger.WARNING("Filter Damage: "+currentUse); + Logger.INFO("Filter Damage now: "+currentUse); return true; } } return false; } - - public void pollutionParticles(World aWorld, String name) { float ran1 = CORE.RANDOM.nextFloat(); |