mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-26 18:39:20 +00:00
fix(block): 修复只放了下半边的问题
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -194,4 +194,9 @@ public abstract class AbstractCustomBlock implements CustomBlock {
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(BlockPlaceContext context, ImmutableBlockState state) {
|
||||
this.behavior.setPlacedBy(context, state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,9 @@ public abstract class BlockBehavior {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setPlacedBy(BlockPlaceContext context, ImmutableBlockState state) {
|
||||
}
|
||||
|
||||
public InteractionResult useOnBlock(UseOnContext context, ImmutableBlockState state) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ public interface CustomBlock {
|
||||
|
||||
ImmutableBlockState getStateForPlacement(BlockPlaceContext context);
|
||||
|
||||
void setPlacedBy(BlockPlaceContext context, ImmutableBlockState state);
|
||||
|
||||
interface Builder {
|
||||
|
||||
Builder events(Map<EventTrigger, List<Function<PlayerOptionalContext>>> events);
|
||||
|
||||
Reference in New Issue
Block a user