diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-12-04 21:26:49 +0100 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-12-04 21:26:49 +0100 |
commit | 76dd576d44e6230d06ddf940bd66175b4c5ff0f4 (patch) | |
tree | d1ecfbda225d32e14b6e63b4e23f63d9fe0e85c7 /src/main | |
parent | 1d3caaf08b6be1f545dce06656f61c1d132efc1c (diff) | |
download | GT5-Unofficial-76dd576d44e6230d06ddf940bd66175b4c5ff0f4.tar.gz GT5-Unofficial-76dd576d44e6230d06ddf940bd66175b4c5ff0f4.tar.bz2 GT5-Unofficial-76dd576d44e6230d06ddf940bd66175b4c5ff0f4.zip |
Rebalanced Fortune on Miners
+rebalanced Fortune to scale linear with tier
+made circuit config wrapping
+rewrote a bit of code to be more readable
Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>
Diffstat (limited to 'src/main')
3 files changed, 44 insertions, 34 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index ed699d618d..5f4c60ca1f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -45,7 +45,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { "Use Screwdriver to regulate work area", ENERGY[aTier] + " EU/t, " + SPEED[aTier] / 20 + " sec per block", "Maximum work area " + (RADIUS[aTier] * 2 + 1) + "x" + (RADIUS[aTier] * 2 + 1), - "Fortune bonus of " + aTier * 2}, + "Fortune bonus of " + aTier}, 2, 2, "Miner.png", "", new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE")), @@ -151,7 +151,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { int blockMeta = aBaseMetaTileEntity.getMetaIDOffset(drillX, drillY, drillZ); if (block instanceof GT_Block_Ores_Abstract) { TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(drillX, drillY, drillZ); - if (tTileEntity != null && tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural) { + if (tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural) { mineBlock(aBaseMetaTileEntity, drillX, drillY, drillZ); return; } @@ -226,7 +226,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { private ArrayList<ItemStack> getBlockDrops(final Block oreBlock, int posX, int posY, int posZ) { final int blockMeta = getBaseMetaTileEntity().getMetaID(posX, posY, posZ); - return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, mTier*2 + 1); + return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, mTier); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index c33dca9d97..109bcf91c3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -13,7 +13,6 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import java.lang.Math; //Java was written by idiots import static gregtech.api.enums.GT_Values.VN; import static gregtech.api.enums.GT_Values.debugDriller; @@ -79,13 +78,17 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); if (aPlayer.isSneaking()) { - if (chunkRangeConfig > 1) { + if (chunkRangeConfig > 0) { chunkRangeConfig--; } + if (chunkRangeConfig == 0) + chunkRangeConfig = getRangeInChunks(); } else { - if (chunkRangeConfig < getRangeInChunks()) { + if (chunkRangeConfig <= getRangeInChunks()) { chunkRangeConfig++; } + if (chunkRangeConfig > getRangeInChunks()) + chunkRangeConfig = 1; } GT_Utility.sendChatToPlayer(aPlayer, "Set to work on " + chunkRangeConfig + "x" + chunkRangeConfig + " chunks");//TODO Add translation support } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index 77f69946de..c621452a44 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -22,6 +22,9 @@ import net.minecraft.world.ChunkPosition; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; import static gregtech.api.enums.GT_Values.VN; @@ -32,11 +35,11 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile private int chunkRadiusConfig = getRadiusInChunks(); - public GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) { + GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GT_MetaTileEntity_OreDrillingPlantBase(String aName) { + GT_MetaTileEntity_OreDrillingPlantBase(String aName) { super(aName); } @@ -61,13 +64,17 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); if (aPlayer.isSneaking()) { - if (chunkRadiusConfig > 1) { + if (chunkRadiusConfig > 0) { chunkRadiusConfig--; } + if (chunkRadiusConfig == 0) + chunkRadiusConfig = getRadiusInChunks(); } else { - if (chunkRadiusConfig < getRadiusInChunks()) { + if (chunkRadiusConfig <= getRadiusInChunks()) { chunkRadiusConfig++; } + if (chunkRadiusConfig > getRadiusInChunks()) + chunkRadiusConfig = 1; } GT_Utility.sendChatToPlayer(aPlayer, "Set to mine in a " + (chunkRadiusConfig << 4) + " radius");//TODO Add translation support } @@ -101,7 +108,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile return false; } if (oreBlock != null && oreBlock != Blocks.air) { - ArrayList<ItemStack> oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); + Collection<ItemStack> oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); mOutputItems = getOutputByDrops(oreBlockDrops); } @@ -124,30 +131,26 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); } - private ItemStack[] getOutputByDrops(ArrayList<ItemStack> oreBlockDrops) { + private ItemStack[] getOutputByDrops(Collection<ItemStack> oreBlockDrops) { long voltage = getMaxInputVoltage(); - ArrayList<ItemStack> outputItems = new ArrayList<>(); - while (!oreBlockDrops.isEmpty()) { - ItemStack currentItem = oreBlockDrops.remove(0).copy(); + Collection<ItemStack> outputItems = new HashSet<>(); + oreBlockDrops.forEach(currentItem -> { if (!doUseMaceratorRecipe(currentItem)) { - multiplyStackSize(currentItem); - outputItems.add(currentItem); - continue; + outputItems.add(multiplyStackSize(currentItem)); + return; } - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, voltage, null, currentItem); if (tRecipe == null) { outputItems.add(currentItem); - continue; + return; } - for (int i = 0; i < tRecipe.mOutputs.length; i++) { ItemStack recipeOutput = tRecipe.mOutputs[i].copy(); if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) multiplyStackSize(recipeOutput); outputItems.add(recipeOutput); } - } + }); return outputItems.toArray(new ItemStack[0]); } @@ -160,17 +163,17 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile && itemData.mMaterial.mMaterial != Materials.Oilsands; } - private void multiplyStackSize(ItemStack itemStack) { + private ItemStack multiplyStackSize(ItemStack itemStack) { itemStack.stackSize *= getBaseMetaTileEntity().getRandomNumber(4) + 1; + return itemStack; } - private ArrayList<ItemStack> getBlockDrops(final Block oreBlock, int posX, int posY, int posZ) { + private Collection<ItemStack> getBlockDrops(final Block oreBlock, int posX, int posY, int posZ) { final int blockMeta = getBaseMetaTileEntity().getMetaID(posX, posY, posZ); if (oreBlock.canSilkHarvest(getBaseMetaTileEntity().getWorld(), null, posX, posY, posZ, blockMeta)) { - return new ArrayList<ItemStack>() {{ - add(new ItemStack(oreBlock, 1, blockMeta)); - }}; - } else return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, mTier*5+1); + return Collections.singleton(new ItemStack(oreBlock, 1, blockMeta)); + } else + return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, mTier + 3); } private boolean tryConsumeDrillingFluid() { @@ -182,12 +185,15 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile } private void fillMineListIfEmpty(int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead) { - if (!oreBlockPositions.isEmpty()) return; + if (!oreBlockPositions.isEmpty()) + return; tryAddOreBlockToMineList(xPipe, yHead - 1, zPipe); - if (yHead == yDrill) return; //skip controller block layer + if (yHead == yDrill) + return; //skip controller block layer + + int radius = Math.min(Math.max(chunkRadiusConfig << 4, 1), getRadiusInChunks()); - int radius = chunkRadiusConfig << 4; for (int xOff = -radius; xOff <= radius; xOff++) for (int zOff = -radius; zOff <= radius; zOff++) tryAddOreBlockToMineList(xDrill + xOff, yHead, zDrill + zOff); @@ -197,10 +203,11 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile Block block = getBaseMetaTileEntity().getBlock(x, y, z); int blockMeta = getBaseMetaTileEntity().getMetaID(x, y, z); ChunkPosition blockPos = new ChunkPosition(x, y, z); - if (oreBlockPositions.contains(blockPos)) return; + if (oreBlockPositions.contains(blockPos)) + return; if (block instanceof GT_Block_Ores_Abstract) { TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(x, y, z); - if (tTileEntity != null && tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural) + if (tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural) oreBlockPositions.add(blockPos); } else { ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta)); @@ -228,6 +235,6 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", "Use Screwdriver to configure block radius", "Maximum radius is " + (getRadiusInChunks() << 4) + " blocks", - "Fortune bonus of " + mTier * 5}; + "Fortune bonus of " + (mTier + 3)}; } }
\ No newline at end of file |