9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-30 12:29:15 +00:00

fix(block): 修复只放了下半边的问题

This commit is contained in:
jhqwqmc
2025-06-19 11:08:22 +08:00
parent ef14147a0a
commit a71754c64a
5 changed files with 18 additions and 1 deletions

View File

@@ -111,6 +111,12 @@ public class DoorBlockBehavior extends BukkitBlockBehavior {
}
}
@Override
public void setPlacedBy(BlockPlaceContext context, ImmutableBlockState state) {
BlockPos pos = context.getClickedPos();
context.getLevel().setBlockAt(pos.x(), pos.y() + 1, pos.z(), state.with(this.halfProperty, DoubleBlockHalf.UPPER).customBlockState(), 3);
}
@Override
public ImmutableBlockState updateStateForPlacement(BlockPlaceContext context, ImmutableBlockState state) {
World world = context.getLevel();
@@ -191,7 +197,6 @@ public class DoorBlockBehavior extends BukkitBlockBehavior {
@Override
public InteractionResult useOnBlock(UseOnContext context, ImmutableBlockState state) {
if (!this.canOpenWithHand) {
if (!this.canOpenWithHand || context.getPlayer().isSecondaryUseActive()) {
return InteractionResult.PASS;
}

View File

@@ -159,6 +159,8 @@ public class BlockItemBehavior extends ItemBehavior {
item.load();
}
block.setPlacedBy(context, blockStateToPlace);
player.swingHand(context.getHand());
context.getLevel().playBlockSound(position, blockStateToPlace.sounds().placeSound());
world.sendGameEvent(bukkitPlayer, GameEvent.BLOCK_PLACE, new Vector(pos.x(), pos.y(), pos.z()));