This commit is contained in:
parent
63f75c0012
commit
e3a5a93c6f
1 changed files with 13 additions and 11 deletions
|
@ -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());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue