From e3a5a93c6f4e0eb1a1ef2528766205d6ab2dda28 Mon Sep 17 00:00:00 2001 From: Waterpicker Date: Sat, 5 Jun 2021 07:03:56 -0500 Subject: [PATCH] Fix for https://trello.com/c/X4YxywOi/23-no-rifts-when-breaking-doors --- .../block/door/DimensionalDoorBlock.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/dimdev/dimdoors/block/door/DimensionalDoorBlock.java b/src/main/java/org/dimdev/dimdoors/block/door/DimensionalDoorBlock.java index 46fffff9..95e9e20b 100644 --- a/src/main/java/org/dimdev/dimdoors/block/door/DimensionalDoorBlock.java +++ b/src/main/java/org/dimdev/dimdoors/block/door/DimensionalDoorBlock.java @@ -1,5 +1,6 @@ package org.dimdev.dimdoors.block.door; +import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; import org.dimdev.dimdoors.DimensionalDoorsInitializer; import org.dimdev.dimdoors.api.util.math.MathUtil; import org.dimdev.dimdoors.api.util.math.TransformationMatrix3d; @@ -93,17 +94,6 @@ public class DimensionalDoorBlock extends WaterLoggableDoorBlock implements Rift return new EntranceRiftBlockEntity(pos, state); } - @Override - public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState blockState, BlockEntity entity, ItemStack stack) { - if (player.isCreative() && !DimensionalDoorsInitializer.getConfig().getDoorsConfig().placeRiftsInCreativeMode) { - return; - } - if (entity instanceof EntranceRiftBlockEntity && blockState.get(HALF) == DoubleBlockHalf.LOWER) { - world.setBlockState(pos, ModBlocks.DETACHED_RIFT.getDefaultState()); - ((DetachedRiftBlockEntity) world.getBlockEntity(pos)).setData(((EntranceRiftBlockEntity) entity).getData()); - } - } - @Override public EntranceRiftBlockEntity getRift(World world, BlockPos pos, BlockState state) { BlockEntity bottomEntity; @@ -158,4 +148,16 @@ public class DimensionalDoorBlock extends WaterLoggableDoorBlock implements Rift public boolean isTall(BlockState cachedState) { return true; } + + static { + PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> { + if (player.isCreative() && !DimensionalDoorsInitializer.getConfig().getDoorsConfig().placeRiftsInCreativeMode) { + return; + } + if (blockEntity instanceof EntranceRiftBlockEntity && state.get(HALF) == DoubleBlockHalf.LOWER) { + world.setBlockState(pos, ModBlocks.DETACHED_RIFT.getDefaultState()); + ((DetachedRiftBlockEntity) world.getBlockEntity(pos)).setData(((EntranceRiftBlockEntity) blockEntity).getData()); + } + }); + } }