From 930c3185eb3437a78ce380229579a3295c5c0953 Mon Sep 17 00:00:00 2001 From: avlad171 Date: Sun, 29 May 2022 23:31:21 +0300 Subject: [PATCH] Fixed issue #3 (hopefully) --- build.gradle | 3 +-- gradle.properties | 1 - .../com/myuki69/enderquarry/InitBlocks.java | 20 +++++++-------- .../myuki69/enderquarry/TileEnderQuarry.java | 25 ++++++++++++++++--- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index 98506a9..a4010e4 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,6 @@ buildscript { repositories { jcenter() maven { url = "https://files.minecraftforge.net/maven" } - } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' @@ -22,7 +21,7 @@ compileJava { } minecraft { - version = "1.12.2-14.23.5.2824" + version = "1.12.2-14.23.5.2847" runDir = "run" // the mappings can be changed at any time, and must be in the following format. diff --git a/gradle.properties b/gradle.properties index 878bf1f..e9b9fd5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false \ No newline at end of file diff --git a/src/main/java/com/myuki69/enderquarry/InitBlocks.java b/src/main/java/com/myuki69/enderquarry/InitBlocks.java index d0a6c2f..14a4b26 100644 --- a/src/main/java/com/myuki69/enderquarry/InitBlocks.java +++ b/src/main/java/com/myuki69/enderquarry/InitBlocks.java @@ -43,23 +43,23 @@ public class InitBlocks { private static void init_upgrades() { upgradeVoid = new UpgradeBlock("upgradevoid", 1); - ForgeRegistries.BLOCKS.register(upgradeVoid); + //ForgeRegistries.BLOCKS.register(upgradeVoid); upgradeSilk = new UpgradeBlock("upgradesilk", 2); - ForgeRegistries.BLOCKS.register(upgradeSilk); + //ForgeRegistries.BLOCKS.register(upgradeSilk); upgradeFortune1 = new UpgradeBlock("upgradefortunei", 3); - ForgeRegistries.BLOCKS.register(upgradeFortune1); + //ForgeRegistries.BLOCKS.register(upgradeFortune1); upgradeFortune2 = new UpgradeBlock("upgradefortuneii", 4); - ForgeRegistries.BLOCKS.register(upgradeFortune2); + //ForgeRegistries.BLOCKS.register(upgradeFortune2); upgradeFortune3 = new UpgradeBlock("upgradefortuneiii", 5); - ForgeRegistries.BLOCKS.register(upgradeFortune3); + //ForgeRegistries.BLOCKS.register(upgradeFortune3); upgradeSpeed1 = new UpgradeBlock("upgradespeedi", 6); - ForgeRegistries.BLOCKS.register(upgradeSpeed1); + //ForgeRegistries.BLOCKS.register(upgradeSpeed1); upgradeSpeed2 = new UpgradeBlock("upgradespeedii", 7); - ForgeRegistries.BLOCKS.register(upgradeSpeed2); + //ForgeRegistries.BLOCKS.register(upgradeSpeed2); upgradeSpeed3 = new UpgradeBlock("upgradespeediii", 8); - ForgeRegistries.BLOCKS.register(upgradeSpeed3); + //ForgeRegistries.BLOCKS.register(upgradeSpeed3); upgradePump = new UpgradeBlock("upgradepump", 9); - ForgeRegistries.BLOCKS.register(upgradePump); + //ForgeRegistries.BLOCKS.register(upgradePump); itemUpgradeVoid = new ItemBlock(upgradeVoid); itemUpgradeVoid.setRegistryName(upgradeVoid.getRegistryName()); @@ -102,7 +102,6 @@ public class InitBlocks { @SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { - //event.getRegistry().registerAll(tutorialBlock); ForgeRegistries.BLOCKS.register(enderQuarry); ForgeRegistries.BLOCKS.register(enderMarker); ForgeRegistries.BLOCKS.register(upgradeVoid); @@ -119,7 +118,6 @@ public class InitBlocks { @SubscribeEvent public static void registerItemBlocks(RegistryEvent.Register event) { - //event.getRegistry().registerAll(new ItemBlock(tutorialBlock).setRegistryName(tutorialBlock.getRegistryName())); ForgeRegistries.ITEMS.register(itemEnderQuarry); ForgeRegistries.ITEMS.register(itemEnderMarker); ForgeRegistries.ITEMS.register(itemUpgradeVoid); diff --git a/src/main/java/com/myuki69/enderquarry/TileEnderQuarry.java b/src/main/java/com/myuki69/enderquarry/TileEnderQuarry.java index 59ec10d..d9f5f72 100644 --- a/src/main/java/com/myuki69/enderquarry/TileEnderQuarry.java +++ b/src/main/java/com/myuki69/enderquarry/TileEnderQuarry.java @@ -449,6 +449,9 @@ public class TileEnderQuarry if(toBeMined == Blocks.BEDROCK) return true; + if (replaceWithDirt && toBeMined == Blocks.DIRT) + return true; + if (replaceWithDirt && (toBeMined.isLeaves(toBeMinedState, this.world, miningPos) || toBeMined.isFoliage(this.world, miningPos) || toBeMined.isWood(this.world, miningPos) || (toBeMined instanceof IPlantable) || (toBeMined instanceof IGrowable))) { return true; @@ -493,17 +496,31 @@ public class TileEnderQuarry try { boolean flag; - + Object i = new ArrayList(); + //check if item has inventory storage capability //if so, extract items TileEntity tile = this.world.getTileEntity(miningPos); - System.out.println("Tile at " + miningPos + ": " + tile); - if(tile != null && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP)) + if(tile != null && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { System.out.println("Found inventory containing tile at " + miningPos); + + //list inventory entries + IItemHandler inv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); + for (int j = 0; j < inv.getSlots(); ++j) + { + if (inv.getStackInSlot(j).isEmpty()) + continue; + + System.out.println("[Ender quarry] Extracting from inventory slot " + j + " " + inv.getStackInSlot(j)); + int cnt = inv.getStackInSlot(j).getCount(); + + //add the items in inventory to the quarry + ((ArrayList)i).add(inv.extractItem(j, cnt, false)); + } } - Object i = new ArrayList(); + if ((digType.isSilkTouch()) && (toBeMined.canSilkHarvest(this.world, miningPos, toBeMinedState, fakePlayer))) { int j = 0;