diff --git a/gradle.properties b/gradle.properties index 1f6d91a..86a7349 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.9.3+build.207 # Mod Properties - mod_version = 1.16.3.1 + mod_version = 1.16.3.2 maven_group = de.jottyfan.minecraft archives_base_name = quickiefabric diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java index 7c33295..e44e05a 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java @@ -65,11 +65,11 @@ public class EventBlockBreak { range = range.addXYZ(level); } if (QuickieTools.SPEEDPOWDERAXE.equals(tool)) { - breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS, player); + breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS, player, true); } else if (QuickieTools.SPEEDPOWDERPICKAXE.equals(tool)) { - breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player); + breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player, false); } else if (QuickieTools.SPEEDPOWDERSHOVEL.equals(tool)) { - breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player); + breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player, false); } } @@ -94,7 +94,7 @@ public class EventBlockBreak { * the player */ private void breakBlockRecursive(List visitedBlocks, World world, List validBlocks, BlockPos pos, ToolRangeable tool, HarvestRange range, BlockBreakDirection blockBreakDirection, - PlayerEntity player) { + PlayerEntity player, boolean breakLeaves) { if (visitedBlocks.contains(pos.toString())) { return; // reduce loops } else if (validBlocks == null) { @@ -103,26 +103,41 @@ public class EventBlockBreak { visitedBlocks.add(pos.toString()); } BlockState blockState = world.getBlockState(pos); - if (tool.canBreakNeigbbors(blockState)) { + if (tool.canBreakNeighbors(blockState)) { Block currentBlock = blockState.getBlock(); if (validBlocks.contains(currentBlock)) { Block.dropStacks(blockState, world, pos); // includes xorbs world.setBlockState(pos, Blocks.AIR.getDefaultState()); if (range == null || range.getxRange() > 1 || range.getyRange() > 1 || range.getzRange() > 1) { HarvestRange nextRadius = range == null ? null : range.addXYZ(-1); - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north(), tool, nextRadius, blockBreakDirection, player); - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north().east(), tool, nextRadius, blockBreakDirection, player); - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north().west(), tool, nextRadius, blockBreakDirection, player); - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south(), tool, nextRadius, blockBreakDirection, player); - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south().east(), tool, nextRadius, blockBreakDirection, player); - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south().west(), tool, nextRadius, blockBreakDirection, player); - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.east(), tool, nextRadius, blockBreakDirection, player); - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.west(), tool, nextRadius, blockBreakDirection, player); - - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up(), tool, nextRadius, blockBreakDirection, player); - + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + if (BlockBreakDirection.ALL.equals(blockBreakDirection)) { - breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down(), tool, nextRadius, blockBreakDirection, player); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); + breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); } } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java index 346b753..c3ca01a 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java @@ -9,6 +9,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import de.jottyfan.minecraft.quickiefabric.tools.externalmods.Byg; +import de.jottyfan.minecraft.quickiefabric.tools.externalmods.IdentifierGroups; import de.jottyfan.minecraft.quickiefabric.tools.externalmods.IdentifierGroup; import de.jottyfan.minecraft.quickiefabric.tools.externalmods.Terrestria; import net.minecraft.block.Block; @@ -49,24 +50,14 @@ public interface ToolRangeable { Arrays.asList(Blocks.POTTED_RED_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM, Blocks.MUSHROOM_STEM)); public static final Set AXE_EFFECTIVE_ON_EXTERNAL = mergeGroupSets( - Terrestria.createFromGroups(new IdentifierGroup("redwood", "log", "quarter_log", "log_bare", "log_top", "wood"), - new IdentifierGroup("hemlock", "log", "quarter_log", "log_bare", "log_top", "wood"), - new IdentifierGroup("rubber", "log", "quarter_log", "log_bare", "log_top", "wood"), - new IdentifierGroup("cypress", "log", "quarter_log", "log_bare", "log_top", "wood"), - new IdentifierGroup("willow", "log", "quarter_log", "log_bare", "log_top", "wood"), - new IdentifierGroup("japanese_maple", "log", "quarter_log", "log_bare", "log_top", "wood"), - new IdentifierGroup("rainbow_eucalyptus", "log", "quarter_log", "log_bare", "log_top", "wood"), - new IdentifierGroup("sakura", "log", "quarter_log", "log_bare", "log_top", "wood"), - new IdentifierGroup("yucca_palm", "log", "quarter_log", "log_bare", "log_top", "wood")), - Byg.createFromGroups(new IdentifierGroup("aspen", "log", "wood"), new IdentifierGroup("baobab", "log", "wood"), - new IdentifierGroup("blue_enchanted", "log", "wood"), new IdentifierGroup("cherry", "log", "wood"), - new IdentifierGroup("cika", "log", "wood"), new IdentifierGroup("cypress", "log", "wood"), - new IdentifierGroup("ebony", "log", "wood"), new IdentifierGroup("fir", "log", "wood"), - new IdentifierGroup("green_enchanted", "log", "wood"), new IdentifierGroup("holly", "log", "wood"), - new IdentifierGroup("jacaranda", "log", "wood"), new IdentifierGroup("mahogany", "log", "wood"), - new IdentifierGroup("mangrove", "log", "wood"), new IdentifierGroup("willow", "log", "wood"), - new IdentifierGroup("witch_hazel", "log", "wood"), new IdentifierGroup("zelkova", "log", "wood"), - new IdentifierGroup("pine", "log", "wood"))); + Terrestria.createFromSet( + new IdentifierGroups("cypress", "hemlock", "japanese_maple", "rainbow_eucalyptus", "redwood", "rubber", + "sakura", "willow", "yucca_palm").getGroups("log", "quarter_log", "log_bare", "log_top", "wood")), + Byg.createFromSet(new IdentifierGroups("aspen", "baobab", "blue_enchanted", "cherry", "cika", "cypress", "ebony", + "fir", "green_enchanted", "holly", "jacaranda", "mahogany", "mangrove", "pine", "rainbow_eucalyptus", + "redwood", "skyris", "willow", "witch_hazel", "zelkova").getGroups("log", "wood")), + Byg.createFromSet( + new IdentifierGroups("blue_glowshroom", "purple_glowshroom", "red_glowshroom", "yellow_glowshroom").getGroups("block", "stem"))); public static final Set PICKAXE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.GLOWSTONE }); @@ -112,7 +103,7 @@ public interface ToolRangeable { * @param blockState the block state of the current block * @return true or false */ - public boolean canBreakNeigbbors(BlockState blockState); + public boolean canBreakNeighbors(BlockState blockState); /** * get list of blocks that belong together diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java index 822a6e6..83adbe8 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java @@ -7,6 +7,7 @@ import com.google.common.collect.Lists; import de.jottyfan.minecraft.quickiefabric.tools.externalmods.IdentifierGroup; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.LeavesBlock; import net.minecraft.item.AxeItem; import net.minecraft.item.ItemStack; import net.minecraft.item.ToolMaterial; @@ -26,7 +27,7 @@ public class ToolRangeableAxe extends AxeItem implements ToolRangeable { @Override public HarvestRange getRange() { - return null; // no limit + return new HarvestRange(64, 128, 64); // trees bigger than that are too heavy for one small axe... } @Override @@ -35,7 +36,7 @@ public class ToolRangeableAxe extends AxeItem implements ToolRangeable { } @Override - public boolean canBreakNeigbbors(BlockState blockIn) { + public boolean canBreakNeighbors(BlockState blockIn) { return getBlockList(blockIn.getBlock()) != null; } @@ -54,6 +55,9 @@ public class ToolRangeableAxe extends AxeItem implements ToolRangeable { } } } + if (block instanceof LeavesBlock) { + return Lists.newArrayList(block); + } return null; } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderPickaxe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderPickaxe.java index f816fc5..b7d7bde 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderPickaxe.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderPickaxe.java @@ -32,7 +32,7 @@ public class ToolSpeedpowderPickaxe extends PickaxeItem implements ToolRangeable } @Override - public boolean canBreakNeigbbors(BlockState blockIn) { + public boolean canBreakNeighbors(BlockState blockIn) { return super.isEffectiveOn(blockIn) || PICKAXE_EFFECTIVE_ON.contains(blockIn.getBlock()); } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java index 5f398fe..b034366 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java @@ -37,7 +37,7 @@ public class ToolSpeedpowderShovel extends ShovelItem implements ToolRangeable { } @Override - public boolean canBreakNeigbbors(BlockState blockState) { + public boolean canBreakNeighbors(BlockState blockState) { boolean result = SHOVEL_EFFECTIVE_ON.contains(blockState.getBlock()) || checkExternalBlock(blockState.getBlock()); if (!result) { if (!blockState.isAir()) { diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java index b3874be..a0f646e 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java @@ -39,7 +39,7 @@ public class Byg extends Identifier { * create from groups * * @param groups the groups - * @return the list of indentifier groups + * @return the set of indentifier groups */ public static final Set createFromGroups(IdentifierGroup... groups) { Set set = new HashSet<>(); @@ -49,4 +49,18 @@ public class Byg extends Identifier { } return set; } + + /** + * create from set + * + * @param set the set + * @return the set of idenfifier groups + */ + public static final Set createFromSet(Set set){ + for (IdentifierGroup group : set) + { + group.setModId("byg"); + } + return set; + } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/IdentifierGroups.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/IdentifierGroups.java new file mode 100644 index 0000000..b38934e --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/IdentifierGroups.java @@ -0,0 +1,31 @@ +package de.jottyfan.minecraft.quickiefabric.tools.externalmods; + +import java.util.HashSet; +import java.util.Set; + +/** + * + * @author jotty + * + */ +public class IdentifierGroups { + + private final Set groups; + private final String[] prefixes; + + public IdentifierGroups(String... prefixes) { + this.prefixes = prefixes; + groups = new HashSet<>(); + } + + private void fillGroups(String... suffixes) { + for (String prefix : prefixes) { + groups.add(new IdentifierGroup(prefix, suffixes)); + } + } + + public Set getGroups(String... suffixes){ + fillGroups(suffixes); + return groups; + } +} diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java index 261b124..6824805 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java @@ -49,4 +49,20 @@ public class Terrestria extends Identifier { } return set; } + + + /** + * create from set + * + * @param set the set + * @return the set of idenfifier groups + */ + public static final Set createFromSet(Set set){ + for (IdentifierGroup group : set) + { + group.setModId("terrestria"); + } + return set; + } + }