From 9ed45df5b7cfdec66d904eee3d95979f4649aaa5 Mon Sep 17 00:00:00 2001 From: Logan Perkins Date: Fri, 24 Jun 2016 16:18:03 -0700 Subject: [PATCH 1/4] Update GT_MetaTileEntity_AdvMiner2.java --- .../multi/GT_MetaTileEntity_AdvMiner2.java | 69 +++++++++++++------ 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java index 3ea1ff7b..a2f6259e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java @@ -71,15 +71,15 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas ArrayList tItems = getStoredInputs(); for (ItemStack tStack : tItems) { if (tStack.isItemEqual(GT_ModHandler.getIC2Item("miningPipe", 1L))) { - tStack.stackSize--; + tStack.stackSize--; if (tStack.stackSize < 1) { tStack = null; } - if (mInventory[1] == null) { - mInventory[1] = GT_ModHandler.getIC2Item("miningPipe", 1L); - } else { - mInventory[1].stackSize++; - } + if (mInventory[1] == null) { + mInventory[1] = GT_ModHandler.getIC2Item("miningPipe", 1L); + } else { + mInventory[1].stackSize++; + } } } @@ -103,12 +103,22 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas for (int i = -48; i < 49; i++) { for (int f = -48; f < 49; f++) { Block tBlock = getBaseMetaTileEntity().getBlockOffset(i, yLevel - getBaseMetaTileEntity().getYCoord(), f); + int tMetaID = getBaseMetaTileEntity().getMetaIDOffset(i, yLevel - getBaseMetaTileEntity().getYCoord(), f); if (tBlock == GregTech_API.sBlockOres1) { TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(i, yLevel - getBaseMetaTileEntity().getYCoord(), f); if ((tTileEntity instanceof GT_TileEntity_Ores) && ((GT_TileEntity_Ores) tTileEntity).mNatural == true && !mMineList.contains(new ChunkPosition(i, yLevel - getBaseMetaTileEntity().getYCoord(), f))) { mMineList.add(new ChunkPosition(i, yLevel - getBaseMetaTileEntity().getYCoord(), f)); } } + else { + ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); + if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + ChunkPosition cp = new ChunkPosition(i, yLevel - getBaseMetaTileEntity().getYCoord(), f); + if (!mMineList.contains(cp)) { + mMineList.add(cp); + } + } + } } } } @@ -117,26 +127,44 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas if (mEnergyHatches.size() > 0 && mEnergyHatches.get(0).getEUVar() > (512 + getMaxInputVoltage() * 4)) { moveOneDown(); } - }else{return false;} - } - if (!mMineList.isEmpty()) { - ChunkPosition oreBlockOffsetPos = mMineList.get(0); - ArrayList tDrops = new ArrayList(); - GT_TileEntity_Ores oreBlockTileEntity = (GT_TileEntity_Ores) getBaseMetaTileEntity().getTileEntityOffset(oreBlockOffsetPos.chunkPosX, oreBlockOffsetPos.chunkPosY, oreBlockOffsetPos.chunkPosZ); - if (oreBlockTileEntity != null) { - tDrops = oreBlockTileEntity.getDrops(1); + }else{ + return false; } + } + ArrayList tDrops = new ArrayList(); + if (!mMineList.isEmpty()) { + + ChunkPosition mle = mMineList.get(0); + mMineList.remove(0); + Block tMineBlock = getBaseMetaTileEntity().getBlockOffset(mle.chunkPosX, mle.chunkPosY, mle.chunkPosZ); + int metadata = getBaseMetaTileEntity().getMetaIDOffset(mle.chunkPosX, mle.chunkPosY, mle.chunkPosZ); + boolean silkTouch = tMineBlock.canSilkHarvest(getBaseMetaTileEntity().getWorld(), null, mle.chunkPosX, mle.chunkPosY, mle.chunkPosZ, metadata); + if (silkTouch){ + ItemStack IS = new ItemStack(tMineBlock); + IS.setItemDamage(metadata); + IS.stackSize=1; + tDrops.add(IS); + } + else{ + tDrops = tMineBlock.getDrops(getBaseMetaTileEntity().getWorld(), mle.chunkPosX, mle.chunkPosY, mle.chunkPosZ, metadata, 1); + } + + getBaseMetaTileEntity().getWorld().setBlockToAir(mle.chunkPosX + getBaseMetaTileEntity().getXCoord(), mle.chunkPosY + getBaseMetaTileEntity().getYCoord(), mle.chunkPosZ + getBaseMetaTileEntity().getZCoord()); if (!tDrops.isEmpty()) { ItemData tData = GT_OreDictUnificator.getItemData(tDrops.get(0).copy()); - if (tData.mPrefix != OrePrefixes.crushed&& tData.mMaterial.mMaterial != Materials.Oilsands) { + if (tData.mPrefix != OrePrefixes.crushed && tData.mMaterial.mMaterial != Materials.Oilsands) { + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, tVoltage, null, tDrops.get(0).copy()); if (tRecipe != null) { this.mOutputItems = new ItemStack[tRecipe.mOutputs.length]; for (int g = 0; g < mOutputItems.length; g++) { mOutputItems[g] = tRecipe.mOutputs[g].copy(); - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(g)) { - mOutputItems[g].stackSize *= getBaseMetaTileEntity().getRandomNumber(4) + 1; - } + mOutputItems[g].stackSize = mOutputItems[g].stackSize * (getBaseMetaTileEntity().getRandomNumber(4) + 1); + } + } else { + this.mOutputItems = new ItemStack[tDrops.size()]; + for (int g = 0; g < mOutputItems.length; g++) { + mOutputItems[g] = tDrops.get(g).copy(); } } } else { @@ -149,8 +177,7 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas mOutputItems = tStack; } } - getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockOffsetPos.chunkPosX + getBaseMetaTileEntity().getXCoord(), oreBlockOffsetPos.chunkPosY + getBaseMetaTileEntity().getYCoord(), oreBlockOffsetPos.chunkPosZ + getBaseMetaTileEntity().getZCoord()); - mMineList.remove(0); + } } @@ -297,4 +324,4 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas return new GT_MetaTileEntity_AdvMiner2(this.mName); } -} \ No newline at end of file +} From 577ea17e656dc92ff3e2bcd584b068b328e39b7a Mon Sep 17 00:00:00 2001 From: Logan Perkins Date: Fri, 24 Jun 2016 20:45:04 -0700 Subject: [PATCH 2/4] Update GT_MetaTileEntity_AdvMiner2.java --- .../machines/multi/GT_MetaTileEntity_AdvMiner2.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java index a2f6259e..dc3de74c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java @@ -159,7 +159,9 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas this.mOutputItems = new ItemStack[tRecipe.mOutputs.length]; for (int g = 0; g < mOutputItems.length; g++) { mOutputItems[g] = tRecipe.mOutputs[g].copy(); - mOutputItems[g].stackSize = mOutputItems[g].stackSize * (getBaseMetaTileEntity().getRandomNumber(4) + 1); + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(g)) { + mOutputItems[g].stackSize *= getBaseMetaTileEntity().getRandomNumber(4) + 1; + } } } else { this.mOutputItems = new ItemStack[tDrops.size()]; From 1fe2787532405f835846bd7cf7afa83e9f00ee2c Mon Sep 17 00:00:00 2001 From: Logan Perkins Date: Fri, 24 Jun 2016 20:50:10 -0700 Subject: [PATCH 3/4] Update GT_MetaTileEntity_AdvMiner2.java --- .../machines/multi/GT_MetaTileEntity_AdvMiner2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java index dc3de74c..6fe83918 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java @@ -106,7 +106,7 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas int tMetaID = getBaseMetaTileEntity().getMetaIDOffset(i, yLevel - getBaseMetaTileEntity().getYCoord(), f); if (tBlock == GregTech_API.sBlockOres1) { TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(i, yLevel - getBaseMetaTileEntity().getYCoord(), f); - if ((tTileEntity instanceof GT_TileEntity_Ores) && ((GT_TileEntity_Ores) tTileEntity).mNatural == true && !mMineList.contains(new ChunkPosition(i, yLevel - getBaseMetaTileEntity().getYCoord(), f))) { + if ((tTileEntity!=null) && (tTileEntity instanceof GT_TileEntity_Ores) && ((GT_TileEntity_Ores) tTileEntity).mNatural == true && !mMineList.contains(new ChunkPosition(i, yLevel - getBaseMetaTileEntity().getYCoord(), f))) { mMineList.add(new ChunkPosition(i, yLevel - getBaseMetaTileEntity().getYCoord(), f)); } } From dfb263e7ddef03421d2f1f84d67c92e01dd5994d Mon Sep 17 00:00:00 2001 From: Logan Perkins Date: Sat, 25 Jun 2016 15:43:13 -0700 Subject: [PATCH 4/4] Update GT_MetaTileEntity_AdvMiner2.java --- .../machines/multi/GT_MetaTileEntity_AdvMiner2.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java index 6fe83918..77fe8331 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java @@ -133,10 +133,12 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas } ArrayList tDrops = new ArrayList(); if (!mMineList.isEmpty()) { - - ChunkPosition mle = mMineList.get(0); - mMineList.remove(0); - Block tMineBlock = getBaseMetaTileEntity().getBlockOffset(mle.chunkPosX, mle.chunkPosY, mle.chunkPosZ); + Block tMineBlock = null; + while ((tMineBlock==null || tMineBlock == Blocks.air) && !mMineList.isEmpty()) { + ChunkPosition mle = mMineList.get(0); + mMineList.remove(0); + tMineBlock = getBaseMetaTileEntity().getBlockOffset(mle.chunkPosX, mle.chunkPosY, mle.chunkPosZ); + } int metadata = getBaseMetaTileEntity().getMetaIDOffset(mle.chunkPosX, mle.chunkPosY, mle.chunkPosZ); boolean silkTouch = tMineBlock.canSilkHarvest(getBaseMetaTileEntity().getWorld(), null, mle.chunkPosX, mle.chunkPosY, mle.chunkPosZ, metadata); if (silkTouch){