fixes bug with recreation of block
This commit is contained in:
parent
06db4df2cb
commit
4ae1e998b0
@ -9,7 +9,7 @@ yarn_mappings=1.21.4+build.1
|
|||||||
loader_version=0.16.9
|
loader_version=0.16.9
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.21.4.0
|
mod_version=1.21.4.1
|
||||||
maven_group=de.jottyfan.quickiemod
|
maven_group=de.jottyfan.quickiemod
|
||||||
archives_base_name=quickiemod
|
archives_base_name=quickiemod
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import de.jottyfan.quickiemod.feature.ModFeatures;
|
|||||||
import de.jottyfan.quickiemod.item.ModItems;
|
import de.jottyfan.quickiemod.item.ModItems;
|
||||||
import de.jottyfan.quickiemod.itemgroup.ModItemGroup;
|
import de.jottyfan.quickiemod.itemgroup.ModItemGroup;
|
||||||
import net.fabricmc.api.ModInitializer;
|
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.event.player.PlayerBlockBreakEvents;
|
||||||
import net.fabricmc.fabric.api.loot.v3.LootTableEvents;
|
import net.fabricmc.fabric.api.loot.v3.LootTableEvents;
|
||||||
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
|
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.LootPool;
|
||||||
import net.minecraft.loot.condition.SurvivesExplosionLootCondition;
|
import net.minecraft.loot.condition.SurvivesExplosionLootCondition;
|
||||||
import net.minecraft.loot.entry.ItemEntry;
|
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();
|
registerComposterItems();
|
||||||
registerLootTableChanges();
|
registerLootTableChanges();
|
||||||
ModItemGroup.registerItemGroup(items, blocks);
|
ModItemGroup.registerItemGroup(items, blocks);
|
||||||
PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> {
|
PlayerBlockBreakEvents.BEFORE.register((world, player, pos, state, blockEntity) -> {
|
||||||
Block oldBlock = state.getBlock();
|
Block oldBlock = state.getBlock();
|
||||||
new EventBlockBreak().doBreakBlock(world, pos, state, player, oldBlock);
|
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);
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,10 +35,12 @@ public class EventBlockBreak {
|
|||||||
Item item = mainHandItemStack.getItem();
|
Item item = mainHandItemStack.getItem();
|
||||||
if (item instanceof ToolRangeable) {
|
if (item instanceof ToolRangeable) {
|
||||||
ToolRangeable tool = (ToolRangeable) item;
|
ToolRangeable tool = (ToolRangeable) item;
|
||||||
if (!world.getBlockState(blockPos).getBlock().equals(oldBlock)) {
|
// not needed when added to before block break
|
||||||
// recreate old block to make it breakable; otherwise, the recursive algorithm stops directly
|
// if (!world.getBlockState(blockPos).getBlock().equals(oldBlock)) {
|
||||||
world.setBlockState(blockPos, oldBlock.getDefaultState());
|
// // 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);
|
int handled = handleRangeableTools(tool, mainHandItemStack, world, oldBlock, blockPos, playerEntity);
|
||||||
if (handled >= 255) {
|
if (handled >= 255) {
|
||||||
// reward for using rangeable tool very successful
|
// reward for using rangeable tool very successful
|
||||||
|
Loading…
x
Reference in New Issue
Block a user