mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 02:49:15 +00:00
修复一些bug
This commit is contained in:
@@ -78,15 +78,15 @@ public class ItemEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInteractAir(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR) return;
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR)
|
||||
return;
|
||||
Player bukkitPlayer = event.getPlayer();
|
||||
BukkitServerPlayer player = this.plugin.adapt(bukkitPlayer);
|
||||
InteractionHand hand = event.getHand() == EquipmentSlot.HAND ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND;
|
||||
if (cancelEventIfHasInteraction(event, player, hand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isSpectatorMode() || player.isAdventureMode()) {
|
||||
if (player.isSpectatorMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,9 +149,8 @@ public class ItemEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO We need to further investigate how to handle adventure mode
|
||||
// no spectator interactions
|
||||
if (player.isSpectatorMode() || player.isAdventureMode()) {
|
||||
if (player.isSpectatorMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@ public class AxeItemBehavior extends ItemBehavior {
|
||||
}
|
||||
|
||||
Player player = context.getPlayer();
|
||||
// no adventure mode
|
||||
if (player.isAdventureMode()) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
Item<ItemStack> offHandItem = (Item<ItemStack>) player.getItemInHand(InteractionHand.OFF_HAND);
|
||||
// is using a shield
|
||||
|
||||
@@ -90,6 +90,8 @@ public class BlockItemBehavior extends ItemBehavior {
|
||||
Block againstBlock = world.getBlockAt(againstPos.x(), againstPos.y(), againstPos.z());
|
||||
org.bukkit.entity.Player bukkitPlayer = (org.bukkit.entity.Player) player.platformPlayer();
|
||||
|
||||
// todo adventure check
|
||||
|
||||
// trigger event
|
||||
CustomBlockAttemptPlaceEvent attemptPlaceEvent = new CustomBlockAttemptPlaceEvent(bukkitPlayer, placeLocation.clone(), blockStateToPlace,
|
||||
DirectionUtils.toBlockFace(context.getClickedFace()), bukkitBlock, context.getHand());
|
||||
|
||||
@@ -26,6 +26,10 @@ public class BoneMealItemBehavior extends ItemBehavior {
|
||||
|
||||
@Override
|
||||
public InteractionResult useOnBlock(UseOnContext context) {
|
||||
if (context.getPlayer().isAdventureMode()) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
BukkitWorldBlock clicked = (BukkitWorldBlock) context.getLevel().getBlockAt(context.getClickedPos());
|
||||
Block block = clicked.block();
|
||||
ImmutableBlockState state = BukkitBlockManager.instance().getImmutableBlockState(BlockStateUtils.blockDataToId(block.getBlockData()));
|
||||
|
||||
@@ -34,6 +34,7 @@ public class BucketItemBehavior extends ItemBehavior {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public InteractionResult useOnBlock(UseOnContext context) {
|
||||
if (context.getPlayer().isAdventureMode()) return InteractionResult.PASS;
|
||||
BukkitWorldBlock clicked = (BukkitWorldBlock) context.getLevel().getBlockAt(context.getClickedPos());
|
||||
Block block = clicked.block();
|
||||
ImmutableBlockState state = BukkitBlockManager.instance().getImmutableBlockState(BlockStateUtils.blockDataToId(block.getBlockData()));
|
||||
|
||||
@@ -67,6 +67,9 @@ public class FurnitureItemBehavior extends ItemBehavior {
|
||||
}
|
||||
|
||||
Player player = context.getPlayer();
|
||||
|
||||
// todo adventure check
|
||||
|
||||
int gameTicks = player.gameTicks();
|
||||
if (!player.updateLastSuccessfulInteractionTick(gameTicks)) {
|
||||
return InteractionResult.FAIL;
|
||||
|
||||
@@ -31,6 +31,7 @@ public class WaterBucketItemBehavior extends ItemBehavior {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public InteractionResult useOnBlock(UseOnContext context) {
|
||||
if (context.getPlayer().isAdventureMode()) return InteractionResult.PASS;
|
||||
BlockPos pos = context.getClickedPos();
|
||||
BukkitWorldBlock clicked = (BukkitWorldBlock) context.getLevel().getBlockAt(pos);
|
||||
Block block = clicked.block();
|
||||
|
||||
@@ -1566,9 +1566,11 @@ public class PacketConsumers {
|
||||
if (actionType == null) return;
|
||||
Location location = furniture.baseEntity().getLocation();
|
||||
BukkitServerPlayer serverPlayer = (BukkitServerPlayer) user;
|
||||
if (serverPlayer.isSpectatorMode() || serverPlayer.isAdventureMode()) return;
|
||||
if (serverPlayer.isSpectatorMode()) return;
|
||||
BukkitCraftEngine.instance().scheduler().sync().run(() -> {
|
||||
if (actionType == Reflections.instance$ServerboundInteractPacket$ActionType$ATTACK) {
|
||||
// todo 冒险模式破坏工具白名单
|
||||
if (serverPlayer.isAdventureMode()) return;
|
||||
if (furniture.isValid()) {
|
||||
if (!BukkitCraftEngine.instance().antiGrief().canBreak(player, location)) {
|
||||
return;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BukkitWorldBlock implements WorldBlock {
|
||||
Object serverLevel = FastNMS.INSTANCE.field$CraftWorld$ServerLevel(block.getWorld());
|
||||
Object fluidData = Reflections.method$Level$getFluidState.invoke(serverLevel, LocationUtils.toBlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||
if (fluidData == null) return false;
|
||||
return (boolean) Reflections.method$FluidState$isSource.invoke(fluidData);
|
||||
return Reflections.method$FluidState$getType.invoke(fluidData) == Reflections.instance$Fluids$WATER;
|
||||
} catch (ReflectiveOperationException e) {
|
||||
CraftEngine.instance().logger().warn("Failed to check if water source is available", e);
|
||||
return false;
|
||||
|
||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=0.0.47.1
|
||||
project_version=0.0.47.2
|
||||
config_version=25
|
||||
lang_version=4
|
||||
project_group=net.momirealms
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.momirealms.craftengine.mod.util.NoteBlockUtils;
|
||||
import net.momirealms.craftengine.shared.ObjectHolder;
|
||||
import net.momirealms.craftengine.shared.block.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CraftEngineBlock
|
||||
|
||||
Reference in New Issue
Block a user