diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-02-07 14:10:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-07 14:10:19 +0000 |
commit | cabfbdb4dbe91553c23ba1baf60d25ae446d250f (patch) | |
tree | 886f99f3655ad6505a210d7043edcaa1cc87afec /src/main/java/gtPlusPlus/xmod | |
parent | 9464ce77d28a9c51c2b9fc11bdc1ae6ffb16df04 (diff) | |
download | GT5-Unofficial-cabfbdb4dbe91553c23ba1baf60d25ae446d250f.tar.gz GT5-Unofficial-cabfbdb4dbe91553c23ba1baf60d25ae446d250f.tar.bz2 GT5-Unofficial-cabfbdb4dbe91553c23ba1baf60d25ae446d250f.zip |
Minor Things (#114)
Added some foils for @GTNH-Colen.
Fixed scanner output on LRE.
Formatting~
Fix Crop Manager giving stacks > 64.
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod')
2 files changed, 346 insertions, 327 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java index 01d5ef88c8..400b48b4e5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java @@ -1,32 +1,25 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; +import java.util.*; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Textures; +import gregtech.api.enums.*; 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.objects.*; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.gui.basic.GT_Container_CropHarvestor; -import gtPlusPlus.xmod.gregtech.api.gui.basic.GT_GUIContainer_CropHarvestor; +import gtPlusPlus.xmod.gregtech.api.gui.basic.*; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import ic2.api.crops.CropCard; -import ic2.api.crops.ICropTile; +import ic2.api.crops.*; import ic2.core.item.DamageHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.entity.player.*; +import net.minecraft.item.*; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -44,12 +37,12 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank public GT_MetaTileEntity_CropHarvestor(final int aID, final int aTier, final String aDescription) { super(aID, "basicmachine.cropharvester.0"+aTier, "Crop Manager ("+GT_Values.VN[aTier]+")", aTier, 21, aDescription); - mLocalName = "Crop Manager ("+GT_Values.VN[aTier]+")"; + this.mLocalName = "Crop Manager ("+GT_Values.VN[aTier]+")"; } public GT_MetaTileEntity_CropHarvestor(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { super(aName, aTier, 21, aDescription, aTextures); - mLocalName = "Crop Manager ("+GT_Values.VN[aTier]+")"; + this.mLocalName = "Crop Manager ("+GT_Values.VN[aTier]+")"; } @Override @@ -59,7 +52,7 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank @Override public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_CropHarvestor(aPlayerInventory, aBaseMetaTileEntity, mLocalName); + return new GT_GUIContainer_CropHarvestor(aPlayerInventory, aBaseMetaTileEntity, this.mLocalName); } @Override @@ -75,7 +68,7 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank @Override public boolean isSimpleMachine() { return true; - } + } @Override public boolean isAccessAllowed(EntityPlayer aPlayer) { @@ -114,12 +107,12 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank @Override public long maxEUInput() { - return GT_Values.V[mTier]; + return GT_Values.V[this.mTier]; } @Override public int getCapacity() { - return 32000 * mTier; + return 32000 * this.mTier; } @Override @@ -148,26 +141,26 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank private static final int getRange(int aTier) { switch(aTier) { - case 1: - return 1; - case 2: - return 5; - case 3: - return 9; - case 4: - return 13; - case 5: - return 17; - case 6: - return 21; - case 7: - return 25; - case 8: - return 29; - case 9: - return 33; - default: - return 0; + case 1: + return 1; + case 2: + return 5; + case 3: + return 9; + case 4: + return 13; + case 5: + return 17; + case 6: + return 21; + case 7: + return 25; + case 8: + return 29; + case 9: + return 33; + default: + return 0; } } @@ -182,15 +175,45 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank } return false; } - + public long powerUsage() { return this.maxEUInput() / 8; } - + public long powerUsageSecondary() { return this.maxEUInput() / 32; } + + public static AutoMap<ItemStack> splitOutputStacks(ItemStack aOutput) { + return splitOutputStacks(new ItemStack[] {aOutput}); + } + + public static AutoMap<ItemStack> splitOutputStacks(ItemStack[] aOutputs) { + AutoMap<ItemStack> aOutputMap = new AutoMap<ItemStack>(); + for (ItemStack aStack : aOutputs) { + if (aStack != null) { + if (aStack.stackSize <= 64) { + aOutputMap.add(aStack); + } else { + int aStacks = 0; + int aExcess = 0; + int aOriginalSize = aStack.stackSize; + while (aOriginalSize >= 64) { + aStacks += 1; + aOriginalSize -= 64; + } + aExcess = aOriginalSize; + for (int i = 0; i < aStacks; i++) { + aOutputMap.add(ItemUtils.getSimpleStack(aStack, 64)); + } + aOutputMap.add(ItemUtils.getSimpleStack(aStack, aExcess)); + } + } + } + return aOutputMap; + } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); @@ -201,33 +224,33 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank int aTileY = this.getBaseMetaTileEntity().getXCoord(); int aTileZ = this.getBaseMetaTileEntity().getXCoord(); - int aRadius = 10 + getRange(mTier); - int aSide = (aRadius-1)/2; - ArrayList<ItemStack> aAllDrops = new ArrayList<ItemStack>(); + int aRadius = 10 + getRange(this.mTier); + int aSide = (aRadius-1)/2; + ArrayList<ItemStack> aAllDrops = new ArrayList<ItemStack>(); - if (mCropCache.isEmpty() || aTick % 1200 == 0 || mInvalidCache) { - if (!mCropCache.isEmpty()) { - mCropCache.clear(); + if (this.mCropCache.isEmpty() || aTick % 1200 == 0 || this.mInvalidCache) { + if (!this.mCropCache.isEmpty()) { + this.mCropCache.clear(); } //Logger.INFO("Looking for crops."); - for (int y = 0; y <= 2; y++) { + for (int y = 0; y <= 2; y++) { for (int x = (-aSide); x <= aSide; x++) { for (int z = (-aSide); z <= aSide; z++) { TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(x, y, z); if (tTileEntity != null && tTileEntity instanceof ICropTile) { ICropTile tCrop = (ICropTile) tTileEntity; - mCropCache.add(tCrop); + this.mCropCache.add(tCrop); } - } - } + } + } } } - //Process Cache + //Process Cache if (doesInventoryHaveSpace()) { - for (ICropTile tCrop : mCropCache) { + for (ICropTile tCrop : this.mCropCache) { if (tCrop == null) { - mInvalidCache = true; + this.mInvalidCache = true; break; } CropCard aCrop = tCrop.getCrop(); @@ -236,16 +259,16 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank if (!aCrop.canGrow(tCrop) && aCrop.canBeHarvested(tCrop)) { if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsage(), true)) { ItemStack[] aHarvest = tCrop.harvest_automated(true); - if (aHarvest != null && aHarvest.length > 0) { + if (aHarvest != null && aHarvest.length > 0) { for (ItemStack aStack : aHarvest) { if (aStack.stackSize > 0) { - if (mTier * 5 > MathUtils.randInt(1, 100)) { + if (this.mTier * 5 > MathUtils.randInt(1, 100)) { aStack.stackSize += Math.floor(tCrop.getGain()/10); Logger.INFO("Bonus output given for "+aCrop.displayName()); } Logger.INFO("Harvested "+aCrop.displayName()); - aAllDrops.add(aStack); - } + aAllDrops.addAll(splitOutputStacks(aStack)); + } } } } @@ -254,32 +277,32 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank processSecondaryFunctions(tCrop); } } - } + } if (!aAllDrops.isEmpty()) { Logger.INFO("Handling "+aAllDrops.size()+" Harvests"); Iterator<ItemStack> iter = aAllDrops.iterator(); while (iter.hasNext()) { - ItemStack aDrop = iter.next(); + ItemStack aDrop = iter.next(); if (ItemUtils.checkForInvalidItems(aDrop)) { for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { if (this.mInventory[i] != null) { //Logger.INFO("Slot "+i+" contains "+this.mInventory[i].getDisplayName()); - if (GT_Utility.areStacksEqual(aDrop, mInventory[i], false)) { + if (GT_Utility.areStacksEqual(aDrop, this.mInventory[i], false)) { //Same - if (mInventory[i].stackSize < 64 && (mInventory[i].stackSize + aDrop.stackSize <= 64)) { + if (this.mInventory[i].stackSize < 64 && (this.mInventory[i].stackSize + aDrop.stackSize <= 64)) { //can merge //Logger.INFO("Slot "+i+" size: "+mInventory[i].stackSize+" + Drop Size: "+aDrop.stackSize+" = "+(mInventory[i].stackSize + aDrop.stackSize)); - mInventory[i].stackSize += aDrop.stackSize; + this.mInventory[i].stackSize += aDrop.stackSize; break; } - else if (mInventory[i].stackSize < 64 && (mInventory[i].stackSize + aDrop.stackSize > 64)) { + else if (this.mInventory[i].stackSize < 64 && (this.mInventory[i].stackSize + aDrop.stackSize > 64)) { //can merge //Logger.INFO("Slot "+i+" size: "+mInventory[i].stackSize+" + Drop Size: "+aDrop.stackSize+" = "+(mInventory[i].stackSize + aDrop.stackSize)); - int aRemainder = mInventory[i].stackSize + aDrop.stackSize - 64; + int aRemainder = this.mInventory[i].stackSize + aDrop.stackSize - 64; Logger.INFO("Remainder: "+aRemainder+", Continuing."); - mInventory[i].stackSize = 64; + this.mInventory[i].stackSize = 64; aDrop.stackSize = aRemainder; continue; } @@ -335,7 +358,7 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank } public boolean consumeWeedEX(boolean aSimulate) { - if (hasWeedEX()) { + if (hasWeedEX()) { for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { if (this.mInventory[i] != null) { damage(i, 1, aSimulate); @@ -347,7 +370,7 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank } public void processSecondaryFunctions(ICropTile aCrop) { - if (!mModeAlternative) { + if (!this.mModeAlternative) { return; } if (hasFertilizer() && consumeFertilizer(true) && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) && applyFertilizer(aCrop)) { @@ -373,18 +396,18 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank triggerDecline = aCrop.getWorld().rand.nextInt(3) == 0; if (aCrop.getCrop() != null && aCrop.getCrop().isWeed(aCrop) && aCrop.getWeedExStorage() >= 75 && triggerDecline) { switch (aCrop.getWorld().rand.nextInt(5)) { - case 0 : - if (aCrop.getGrowth() > 0) { - aCrop.setGrowth((byte) (aCrop.getGrowth() - 1)); - } - case 1 : - if (aCrop.getGain() > 0) { - aCrop.setGain((byte) (aCrop.getGain() - 1)); - } - default : - if (aCrop.getResistance() > 0) { - aCrop.setResistance((byte) (aCrop.getResistance() - 1)); - } + case 0 : + if (aCrop.getGrowth() > 0) { + aCrop.setGrowth((byte) (aCrop.getGrowth() - 1)); + } + case 1 : + if (aCrop.getGain() > 0) { + aCrop.setGain((byte) (aCrop.getGain() - 1)); + } + default : + if (aCrop.getResistance() > 0) { + aCrop.setResistance((byte) (aCrop.getResistance() - 1)); + } } } return true; @@ -422,7 +445,7 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank this.mFluid = null; } //Logger.INFO("Did Hydrate"); - aCrop.setHydrationStorage(aCrop.getHydrationStorage() + drain); + aCrop.setHydrationStorage(aCrop.getHydrationStorage() + drain); return true; } else { @@ -433,23 +456,23 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank } public boolean consume(int aSlot, int amount, boolean simulate) { - ItemStack stack = this.mInventory[aSlot]; - if (stack != null && stack.stackSize >= amount) { - int currentAmount = Math.min(amount, stack.stackSize); - amount -= currentAmount; - if (!simulate) { - if (stack.stackSize == currentAmount) { - this.mInventory[aSlot] = null; - } else { - stack.stackSize -= currentAmount; - } - } - else { - return amount >= 0; - } - return true; - } - return false; + ItemStack stack = this.mInventory[aSlot]; + if (stack != null && stack.stackSize >= amount) { + int currentAmount = Math.min(amount, stack.stackSize); + amount -= currentAmount; + if (!simulate) { + if (stack.stackSize == currentAmount) { + this.mInventory[aSlot] = null; + } else { + stack.stackSize -= currentAmount; + } + } + else { + return amount >= 0; + } + return true; + } + return false; } public ItemStack damage(int aSlot, int amount, boolean simulate) { @@ -480,7 +503,7 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank if (stack.stackSize == 0 && !simulate) { this.mInventory[aSlot] = null; } - } + } if (ret != null) { int i = DamageHandler.getMaxDamage(ret); @@ -489,39 +512,39 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank } return ret; } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aStack != null && aIndex >= SLOT_OUTPUT_START && aIndex < this.getSizeInventory(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aStack != null) { - if (aStack.getItem().getUnlocalizedName().equals("ic2.itemFertilizer")) { - return aIndex >= SLOT_FERT_1 && aIndex <= SLOT_FERT_4; - } - else if (aStack.getItem().getUnlocalizedName().equals("ic2.itemWeedEx")) { - return aIndex >= SLOT_WEEDEX_1 && aIndex <= SLOT_WEEDEX_2; - } - } - return false; - } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aStack != null && aIndex >= SLOT_OUTPUT_START && aIndex < this.getSizeInventory(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aStack != null) { + if (aStack.getItem().getUnlocalizedName().equals("ic2.itemFertilizer")) { + return aIndex >= SLOT_FERT_1 && aIndex <= SLOT_FERT_4; + } + else if (aStack.getItem().getUnlocalizedName().equals("ic2.itemWeedEx")) { + return aIndex >= SLOT_WEEDEX_1 && aIndex <= SLOT_WEEDEX_2; + } + } + return false; + } @Override public String[] getDescription() { - int aRadius = 10 + getRange(mTier); - int aSide = (aRadius-1)/2; + int aRadius = 10 + getRange(this.mTier); + int aSide = (aRadius-1)/2; return new String[] { - this.mDescription, + this.mDescription, "Secondary mode can Hydrate/Fertilize/Weed-EX", "Consumes "+powerUsage()+"eu per harvest", "Consumes "+powerUsageSecondary()+"eu per secondary operation", "Can harvest 2 blocks above", "Radius: "+aSide+" each side ("+aRadius+"x3x"+aRadius+")", - "Has "+(mTier * 5)+"% chance for extra drops", + "Has "+(this.mTier * 5)+"% chance for extra drops", "Holds "+this.getCapacity()+"L of Water", - CORE.GT_Tooltip + CORE.GT_Tooltip }; } @@ -592,36 +615,36 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { if (aSide == 0 || aSide == 1) { return this.mTextures[3][aColorIndex + 1]; } else { - return this.mTextures[4][aColorIndex + 1]; - } + return this.mTextures[4][aColorIndex + 1]; + } /*return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1];*/ } public ITexture[] getFront(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; } public ITexture[] getBack(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; } public ITexture[] getBottom(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes)}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes)}; } public ITexture[] getTop(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes)}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes)}; } public ITexture[] getSides(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; } @Override @@ -657,13 +680,13 @@ public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("mModeAlternative", mModeAlternative); + aNBT.setBoolean("mModeAlternative", this.mModeAlternative); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - mModeAlternative = aNBT.getBoolean("mModeAlternative"); + this.mModeAlternative = aNBT.getBoolean("mModeAlternative"); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java index 6ff34f405a..5d6ba7f2eb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java @@ -4,10 +4,8 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; 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 com.gtnewhorizon.structurelib.structure.*; import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; @@ -19,20 +17,17 @@ import gregtech.api.util.*; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.chemistry.RocketFuels; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.lib.*; import gtPlusPlus.core.material.MISC_MATERIALS; import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_AirIntake; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler_Adv; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.*; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.*; public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_LargeRocketEngine> { @@ -49,7 +44,7 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi public static String mCasingName = "Turbodyne Casing"; public static String mIntakeHatchName = "Tungstensteel Turbine Casing"; public static String mGearboxName = "Inconel Reinforced Casing"; - + private static Fluid sAirFluid = null; private static FluidStack sAirFluidStack = null; @@ -80,105 +75,105 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Large Rocket Engine") - .addInfo("Supply Rocket Fuels and 1000L of " + mLubricantName + " per hour") - .addInfo("Produces as much energy as you put fuel in, with optional boosting") - .addInfo("Supply 4L of " + mCoolantName + " per second, per 2100 EU/t to boost") - .addInfo("Takes 3x the amount of fuel and " + mLubricantName + "to run 3x faster") - .addInfo("Consumes 2000L/s of air and pollutes 1500 gibbl/s per 16384 eu/t produced") - .addInfo("If producing more than 18.4k EU/t, fuel will be consumed less efficiently:") - .addInfo("- 75% of max fuel efficiency at 44k EU/t output energy") - .addInfo("- 50% of max fuel efficiency at 105k EU/t output energy") - .addInfo("- 25% of max fuel efficiency at 294k EU/t output energy") - .addInfo("(These thresholds are 3x higher when boosted)") - .addInfo("formula: x = input of energy (10K^(1/3)/ x^(1/3)) * (40K^(1/3)/ x^(1/3))") - .addSeparator() - .beginStructureBlock(3, 3, 10, false) - .addController("Front Center") - .addCasingInfo(mCasingName, 64) - .addCasingInfo(mGearboxName, 8) - .addStructureHint("Air Intake Hatch", 1) - .addInputBus("Side center line", 1) - .addInputHatch("Side center line", 1) - .addMaintenanceHatch("Any Block Touching Inconel Reinforced Casing", 1) - .addDynamoHatch("Top center line", 2) - .addMufflerHatch("Back Center", 3) - .toolTipFinisher(CORE.GT_Tooltip_Builder); + .addInfo("Controller Block for the Large Rocket Engine") + .addInfo("Supply Rocket Fuels and 1000L of " + mLubricantName + " per hour") + .addInfo("Produces as much energy as you put fuel in, with optional boosting") + .addInfo("Supply 4L of " + mCoolantName + " per second, per 2100 EU/t to boost") + .addInfo("Takes 3x the amount of fuel and " + mLubricantName + "to run 3x faster") + .addInfo("Consumes 2000L/s of air and pollutes 1500 gibbl/s per 16384 eu/t produced") + .addInfo("If producing more than 18.4k EU/t, fuel will be consumed less efficiently:") + .addInfo("- 75% of max fuel efficiency at 44k EU/t output energy") + .addInfo("- 50% of max fuel efficiency at 105k EU/t output energy") + .addInfo("- 25% of max fuel efficiency at 294k EU/t output energy") + .addInfo("(These thresholds are 3x higher when boosted)") + .addInfo("formula: x = input of energy (10K^(1/3)/ x^(1/3)) * (40K^(1/3)/ x^(1/3))") + .addSeparator() + .beginStructureBlock(3, 3, 10, false) + .addController("Front Center") + .addCasingInfo(mCasingName, 64) + .addCasingInfo(mGearboxName, 8) + .addStructureHint("Air Intake Hatch", 1) + .addInputBus("Side center line", 1) + .addInputHatch("Side center line", 1) + .addMaintenanceHatch("Any Block Touching Inconel Reinforced Casing", 1) + .addDynamoHatch("Top center line", 2) + .addMufflerHatch("Back Center", 3) + .toolTipFinisher(CORE.GT_Tooltip_Builder); return tt; } @Override public IStructureDefinition<GregtechMetaTileEntity_LargeRocketEngine> getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_LargeRocketEngine>builder() - .addShape(mName, transpose(new String[][]{ - {"CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC"}, - {"C~C", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "CMC"}, - {"CCC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CCC"}, + if (this.STRUCTURE_DEFINITION == null) { + this.STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_LargeRocketEngine>builder() + .addShape(this.mName, transpose(new String[][]{ + {"CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC"}, + {"C~C", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "CMC"}, + {"CCC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CCC"}, })) .addElement( 'C', ofBlock( getCasingBlock(), getCasingMeta() + ) ) - ) .addElement( 'I', ofBlock( getGearboxBlock(), getGearboxMeta() + ) ) - ) .addElement( 'T', ofChain( ofHatchAdder( GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineTopList, getCasingTextureIndex(), 2 - ), + ), onElementPass( x -> ++x.mCasing, ofBlock( getCasingBlock(), getCasingMeta() + ) ) ) ) - ) .addElement( 'S', ofChain( ofHatchAdder( GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineSideList, getCasingTextureIndex(), 1 - ), + ), onElementPass( x -> ++x.mCasing, ofBlock( getCasingBlock(), getCasingMeta() + ) ) ) ) - ) .addElement( 'M', ofHatchAdder( GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineBackList, getCasingTextureIndex(), 3 + ) ) - ) .build(); } - return STRUCTURE_DEFINITION; + return this.STRUCTURE_DEFINITION; } @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + buildPiece(this.mName , stackSize, hintsOnly, 1, 1, 0); } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; + this.mCasing = 0; this.mTecTechDynamoHatches.clear(); this.mAllDynamoHatches.clear(); this.mAirIntakes.clear(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 64 - 48 && mAirIntakes.size() >= 8 && checkHatch(); + return checkPiece(this.mName, 1, 1, 0) && this.mCasing >= 64 - 48 && this.mAirIntakes.size() >= 8 && checkHatch(); } public final boolean addLargeRocketEngineTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { @@ -256,7 +251,7 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { return super.getClientGUI(aID, aPlayerInventory, aBaseMetaTileEntity); } - + public static void setAir() { if (sAirFluidStack == null) { sAirFluidStack = FluidUtils.getFluidStack("air", 1); @@ -283,96 +278,96 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi } } return totalAir; - } + } } @Override public GT_Recipe_Map getRecipeMap() { return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; } - + @Override public boolean checkRecipe(final ItemStack aStack) { final ArrayList<FluidStack> tFluids = this.getStoredFluids(); int aircount = getAir() ; - if (aircount < euProduction/100) { + if (aircount < this.euProduction/100) { //log("Not Enough Air to Run "+aircount); return false; } - else { - boolean hasIntakeAir = this.depleteInput(FluidUtils.getFluidStack(sAirFluid, euProduction/100)); + else { + boolean hasIntakeAir = this.depleteInput(FluidUtils.getFluidStack(sAirFluid, this.euProduction/100)); if (!hasIntakeAir) { //log("Could not consume Air to run "+aircount); - freeFuelTicks = 0; + this.freeFuelTicks = 0; return false; - } + } } // reste fuel ticks incase it does not reset when it stops - if (freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) - freeFuelTicks = 0; - + if (this.freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) + this.freeFuelTicks = 0; + //log("Running "+aircount); log("looking at hatch"); - - + + if (tFluids.size() > 0 && getRecipeMap() != null) { - + if (tFluids.contains(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) || tFluids.contains(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) { if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { if (!consumeCO2()) { - freeFuelTicks = 0; + this.freeFuelTicks = 0; return false; } } } else { - freeFuelTicks = 0; + this.freeFuelTicks = 0; return false; } - - if (freeFuelTicks == 0) + + if (this.freeFuelTicks == 0) this.boostEu = consumeLOH(); - + for (final FluidStack hatchFluid1 : tFluids) { if (hatchFluid1.isFluidEqual(sAirFluidStack)) { continue; } - - if (freeFuelTicks == 0) { + + if (this.freeFuelTicks == 0) { for (final GT_Recipe aFuel : getRecipeMap().mRecipeList) { final FluidStack tLiquid; tLiquid = aFuel.mFluidInputs[0]; if (hatchFluid1.isFluidEqual(tLiquid)) { if (!consumeFuel(aFuel,hatchFluid1.amount)) { continue; - } - this.fuelValue = aFuel.mSpecialValue; + } + this.fuelValue = aFuel.mSpecialValue * 3; this.fuelRemaining = hatchFluid1.amount; this.mEUt = (int) ((this.mEfficiency < 2000) ? 0 : GT_Values.V[5]<<1); this.mProgresstime = 1; this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = euProduction/2000; + this.mEfficiencyIncrease = this.euProduction/2000; return true; //log(""); } } - + } else { - this.mEfficiencyIncrease = euProduction/2000; - freeFuelTicks--; + this.mEfficiencyIncrease = this.euProduction/2000; + this.freeFuelTicks--; this.mEUt = (int) ((this.mEfficiency < 1000) ? 0 : GT_Values.V[5]<<1); this.mProgresstime = 1; this.mMaxProgresstime = 1; return true; } - + } } this.mEUt = 0; this.mEfficiency = 0; - freeFuelTicks = 0; + this.freeFuelTicks = 0; return false; } @@ -381,23 +376,23 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi * @param aFuel * @return */ - public boolean consumeFuel(GT_Recipe aFuel,int amount) { - amount *= this.boostEu ? 0.3 : 0.9; - freeFuelTicks = 0; - int value = aFuel.mSpecialValue * 3; - int energy = value * amount; - if (amount < 5) - return false; - FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], (this.boostEu ? amount * 3 : amount)); - if (!this.depleteInput(tLiquid)) { - return false; - } - else { - this.fuelConsumption = this.boostEu ? amount * 3 : amount; - this.freeFuelTicks = 20; - setEUProduction(energy); - return true; - } + public boolean consumeFuel(GT_Recipe aFuel,int amount) { + amount *= this.boostEu ? 0.3 : 0.9; + this.freeFuelTicks = 0; + int value = aFuel.mSpecialValue * 3; + int energy = value * amount; + if (amount < 5) + return false; + FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], (this.boostEu ? amount * 3 : amount)); + if (!this.depleteInput(tLiquid)) { + return false; + } + else { + this.fuelConsumption = this.boostEu ? amount * 3 : amount; + this.freeFuelTicks = 20; + setEUProduction(energy); + return true; + } } public void setEUProduction(int energy){ @@ -405,19 +400,19 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi double energyEfficiency; double tDevideEnergy = Math.cbrt(energy); if (energy > 10000) { - //cbrt(10 000) / - energyEfficiency = ((double) 21.5443469/tDevideEnergy); + //cbrt(10 000) / + energyEfficiency = (21.5443469/tDevideEnergy); if (energy >= 40000) //cbrt(40 000) / - energyEfficiency *= ((double)34.19951893/tDevideEnergy); + energyEfficiency *= (34.19951893/tDevideEnergy); energyEfficiency *= energy; - } + } else { energyEfficiency = energy; } - euProduction = (int) ((double) energyEfficiency * 1.84); + this.euProduction = (int) (energyEfficiency * 1.84); if (this.boostEu) - euProduction *= 3; + this.euProduction *= 3; } public boolean consumeCO2() { @@ -430,93 +425,94 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi } public boolean consumeLOH() { - int LOHamount = (3 * euProduction)/1000; + int LOHamount = (3 * this.euProduction)/1000; return this.depleteInput(FluidUtils.getFluidStack(RocketFuels.Liquid_Hydrogen, LOHamount)); //(40 * ((long) euProduction / 10000)) } - + + @Override + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) { + return true; + } + if (this.mAllDynamoHatches.size() > 0) { + return addEnergyOutputMultipleDynamos(aEU, true); + } + return false; + } + + @Override - public boolean addEnergyOutput(long aEU) { - if (aEU <= 0) { - return true; - } - if (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 { - /** - * Calcualtes overclocked ness using long integers - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? - */ - //Long time calculation - if (aFirstVoltageFound != aVoltage) { - aFoundMixedDynamos = true; - } - } - totalOutput += aTotal; - } - } - - if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { - explodeMultiblock(); - return false; - } - - long leftToInject; - //Long EUt calculation - long aVoltage; - //Isnt too low EUt check? - int aAmpsToInject; - int aRemainder; - - //xEUt *= 4;//this is effect of everclocking - for (GT_MetaTileEntity_Hatch aDynamo : mAllDynamoHatches) { - if (isValidMetaTileEntity(aDynamo)) { - leftToInject = aEU - injected; - aVoltage = aDynamo.maxEUOutput(); - aAmpsToInject = (int) (leftToInject / aVoltage); - aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); - long powerGain; - for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject + 1); i++) { - if (i == Math.min(aDynamo.maxAmperesOut(), aAmpsToInject)){ - powerGain = aRemainder; - }else{ - powerGain = aVoltage; - } - aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(powerGain, false); - injected += powerGain; - } - } - } - return injected > 0; - } - + int injected = 0; + long totalOutput = 0; + long aFirstVoltageFound = -1; + boolean aFoundMixedDynamos = false; + for (GT_MetaTileEntity_Hatch aDynamo : this.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 { + /** + * Calcualtes overclocked ness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + */ + //Long time calculation + if (aFirstVoltageFound != aVoltage) { + aFoundMixedDynamos = true; + } + } + totalOutput += aTotal; + } + } + + if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { + explodeMultiblock(); + return false; + } + + long leftToInject; + //Long EUt calculation + long aVoltage; + //Isnt too low EUt check? + int aAmpsToInject; + int aRemainder; + + //xEUt *= 4;//this is effect of everclocking + for (GT_MetaTileEntity_Hatch aDynamo : this.mAllDynamoHatches) { + if (isValidMetaTileEntity(aDynamo)) { + leftToInject = aEU - injected; + aVoltage = aDynamo.maxEUOutput(); + aAmpsToInject = (int) (leftToInject / aVoltage); + aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); + long powerGain; + for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject + 1); i++) { + if (i == Math.min(aDynamo.maxAmperesOut(), aAmpsToInject)){ + powerGain = aRemainder; + }else{ + powerGain = aVoltage; + } + aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(powerGain, false); + injected += powerGain; + } + } + } + return injected > 0; + } + @Override public boolean onRunningTick(ItemStack aStack) { if (this.mRuntime%20 == 0) { - if (mMufflerHatches.size() == 1 && mMufflerHatches.get(0) instanceof GT_MetaTileEntity_Hatch_Muffler_Adv) { - GT_MetaTileEntity_Hatch_Muffler_Adv tMuffler = (GT_MetaTileEntity_Hatch_Muffler_Adv) mMufflerHatches.get(0); + if (this.mMufflerHatches.size() == 1 && this.mMufflerHatches.get(0) instanceof GT_MetaTileEntity_Hatch_Muffler_Adv) { + GT_MetaTileEntity_Hatch_Muffler_Adv tMuffler = (GT_MetaTileEntity_Hatch_Muffler_Adv) this.mMufflerHatches.get(0); if (!tMuffler.hasValidFilter()) { ArrayList<ItemStack> tInputs = getStoredInputs(); for (ItemStack tItem : tInputs) { @@ -561,16 +557,16 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi @Override public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("freeFuelTicks", freeFuelTicks); - aNBT.setInteger("euProduction", euProduction); + aNBT.setInteger("freeFuelTicks", this.freeFuelTicks); + aNBT.setInteger("euProduction", this.euProduction); super.saveNBTData(aNBT); } @Override public void loadNBTData(final NBTTagCompound aNBT) { super.loadNBTData(aNBT); - freeFuelTicks = aNBT.getInteger("freeFuelTicks"); - euProduction = aNBT.getInteger("euProduction"); + this.freeFuelTicks = aNBT.getInteger("freeFuelTicks"); + this.euProduction = aNBT.getInteger("euProduction"); } @Override @@ -580,12 +576,12 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi @Override public int getMaxEfficiency(final ItemStack aStack) { - return euProduction; + return this.euProduction; } @Override public int getPollutionPerTick(final ItemStack aStack) { - return 75 * ( euProduction / 10000); + return 75 * ( this.euProduction / 10000); } @Override @@ -595,16 +591,16 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi @Override public String[] getExtraInfoData() { - return new String[] { + return new String[] { "Rocket Engine", "Current Air: "+getAir(), "Current Pollution: " + getPollutionPerTick(null), - "Time until next fuel consumption: "+freeFuelTicks, + "Time until next fuel consumption: "+this.freeFuelTicks, "Current Output: " + this.mEUt * this.mEfficiency / 10000 + " EU/t", "Fuel Consumption: " + (this.fuelConsumption) + "L/s", - "Fuel Value: " + this.fuelValue*3 + " EU/L", + "Fuel Value: " + this.fuelValue + " EU/L", "Fuel Remaining: " + this.fuelRemaining + " Litres", - "Current Efficiency: " + this.mEfficiency / 100 + "%", + "Current Efficiency: " + this.mEfficiency / 100 + "%", (this.getIdealStatus() == this.getRepairStatus()) ? "No Maintainance issues" : "Needs Maintainance" }; } |