From 7d073371cbf74bad6641461fe6405ebc80da19be Mon Sep 17 00:00:00 2001 From: xSkewer <43712386+xSkewer@users.noreply.github.com> Date: Sun, 19 Jun 2022 15:34:16 -0400 Subject: Allow wire cutters to toggle cobblestone replacing on MBM (#1083) * Allow wire cutters to toggle cobblestone replacing * Add NBT saving --- .../GT_MetaTileEntity_OreDrillingPlantBase.java | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') 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 fce4e3758c..9e910574c4 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 @@ -37,6 +37,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile private final ArrayList oreBlockPositions = new ArrayList<>(); protected int mTier = 1; private int chunkRadiusConfig = getRadiusInChunks(); + private boolean replaceWithCobblestone = true; GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -50,13 +51,18 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setInteger("chunkRadiusConfig", chunkRadiusConfig); + aNBT.setBoolean("replaceWithCobblestone", replaceWithCobblestone); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - if (aNBT.hasKey("chunkRadiusConfig")) + if (aNBT.hasKey("chunkRadiusConfig")) { chunkRadiusConfig = aNBT.getInteger("chunkRadiusConfig"); + } + if (aNBT.hasKey("replaceWithCobblestone")) { + replaceWithCobblestone = aNBT.getBoolean("replaceWithCobblestone"); + } } @Override @@ -83,6 +89,13 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.machines.workareaset") + " " + (chunkRadiusConfig << 4) + " " + StatCollector.translateToLocal("GT5U.machines.radius")); } + @Override + public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + replaceWithCobblestone = !replaceWithCobblestone; + GT_Utility.sendChatToPlayer(aPlayer, "Replace with cobblestone " + replaceWithCobblestone); + return true; + } + @Override protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { if (yHead != oldYHead) @@ -133,7 +146,11 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile Collection oreBlockDrops = getBlockDrops(oreBlock, x, y, z); ItemStack cobble = GT_Utility.getCobbleForOre(oreBlock, metaData); - getBaseMetaTileEntity().getWorld().setBlock(x, y, z, Block.getBlockFromItem(cobble.getItem()), cobble.getItemDamage(), 3); + if (replaceWithCobblestone) { + getBaseMetaTileEntity().getWorld().setBlock(x, y, z, Block.getBlockFromItem(cobble.getItem()), cobble.getItemDamage(), 3); + } else { + getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); + } mOutputItems = getOutputByDrops(oreBlockDrops); } return true; @@ -220,7 +237,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile GT_ChunkManager.requestChunkLoad((TileEntity)getBaseMetaTileEntity(), new ChunkCoordIntPair(nextChunkX, nextChunkZ)); return true; } - + @Override protected boolean checkHatches(){ return !mMaintenanceHatches.isEmpty() && !mInputHatches.isEmpty() && !mOutputBusses.isEmpty() && !mEnergyHatches.isEmpty(); @@ -349,13 +366,14 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile protected GT_Multiblock_Tooltip_Builder createTooltip(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); - + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Miner") .addInfo("Controller Block for the Ore Drilling Plant " + (tierSuffix != null ? tierSuffix : "")) .addInfo("Use a Screwdriver to configure block radius") .addInfo("Maximum radius is " + (getRadiusInChunks() << 4) + " blocks") .addInfo("Use Soldering iron to turn off chunk mode") + .addInfo("Use Wire Cutter to toggle replacing mined blocks with cobblestone") .addInfo("In chunk mode, working area center is the chunk corner nearest to the drill") .addInfo("Gives ~3x as much crushed ore vs normal processing") .addInfo("Fortune bonus of " + (mTier + 3) + ". Only works on small ores") -- cgit