diff --git a/gradle.properties b/gradle.properties index 65e0a60..3f83bfa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.21.4+build.1 loader_version=0.16.9 # Mod Properties -mod_version=1.21.4.0 +mod_version=1.21.4.1 maven_group=de.jottyfan.quickiemod archives_base_name=quickiemod diff --git a/src/main/java/de/jottyfan/quickiemod/Quickiemod.java b/src/main/java/de/jottyfan/quickiemod/Quickiemod.java index c719053..8881a63 100644 --- a/src/main/java/de/jottyfan/quickiemod/Quickiemod.java +++ b/src/main/java/de/jottyfan/quickiemod/Quickiemod.java @@ -12,6 +12,7 @@ import de.jottyfan.quickiemod.feature.ModFeatures; import de.jottyfan.quickiemod.item.ModItems; import de.jottyfan.quickiemod.itemgroup.ModItemGroup; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.event.player.AttackBlockCallback; import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; import net.fabricmc.fabric.api.loot.v3.LootTableEvents; import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; @@ -21,6 +22,8 @@ import net.minecraft.item.Items; import net.minecraft.loot.LootPool; import net.minecraft.loot.condition.SurvivesExplosionLootCondition; import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Identifier; /** * @@ -65,9 +68,14 @@ public class Quickiemod implements ModInitializer { registerComposterItems(); registerLootTableChanges(); ModItemGroup.registerItemGroup(items, blocks); - PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> { + PlayerBlockBreakEvents.BEFORE.register((world, player, pos, state, blockEntity) -> { Block oldBlock = state.getBlock(); new EventBlockBreak().doBreakBlock(world, pos, state, player, oldBlock); + return false; }); +// PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> { +// Block oldBlock = state.getBlock(); +// new EventBlockBreak().doBreakBlock(world, pos, state, player, oldBlock); +// }); } } \ No newline at end of file diff --git a/src/main/java/de/jottyfan/quickiemod/event/EventBlockBreak.java b/src/main/java/de/jottyfan/quickiemod/event/EventBlockBreak.java index 53ccc44..856af90 100644 --- a/src/main/java/de/jottyfan/quickiemod/event/EventBlockBreak.java +++ b/src/main/java/de/jottyfan/quickiemod/event/EventBlockBreak.java @@ -35,10 +35,12 @@ public class EventBlockBreak { Item item = mainHandItemStack.getItem(); if (item instanceof ToolRangeable) { ToolRangeable tool = (ToolRangeable) item; - if (!world.getBlockState(blockPos).getBlock().equals(oldBlock)) { - // recreate old block to make it breakable; otherwise, the recursive algorithm stops directly - world.setBlockState(blockPos, oldBlock.getDefaultState()); - } + // not needed when added to before block break +// if (!world.getBlockState(blockPos).getBlock().equals(oldBlock)) { +// // recreate old block to make it breakable; otherwise, the recursive algorithm stops directly +// // this leads to the BUG that blocks with no neighbour will respawn and drop -> unlimited items. +// world.setBlockState(blockPos, oldBlock.getDefaultState()); +// } int handled = handleRangeableTools(tool, mainHandItemStack, world, oldBlock, blockPos, playerEntity); if (handled >= 255) { // reward for using rangeable tool very successful