mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 12:29:15 +00:00
完善slab行为
This commit is contained in:
@@ -42,7 +42,7 @@ public class SlabBlockBehavior extends BukkitBlockBehavior {
|
||||
public boolean canBeReplaced(BlockPlaceContext context, ImmutableBlockState state) {
|
||||
SlabType type = state.get(this.typeProperty);
|
||||
Item<ItemStack> item = (Item<ItemStack>) context.getItem();
|
||||
if (type == SlabType.DOUBLE) return false;
|
||||
if (type == SlabType.DOUBLE || item == null) return false;
|
||||
Optional<CustomItem<ItemStack>> itemInHand = item.getCustomItem();
|
||||
if (itemInHand.isEmpty()) return false;
|
||||
CustomItem<ItemStack> customItem = itemInHand.get();
|
||||
@@ -57,8 +57,8 @@ public class SlabBlockBehavior extends BukkitBlockBehavior {
|
||||
boolean upper = context.getClickLocation().y - (double) context.getClickedPos().y() > (double) 0.5F;
|
||||
Direction clickedFace = context.getClickedFace();
|
||||
return type == SlabType.BOTTOM ?
|
||||
clickedFace == Direction.UP || upper && clickedFace.axis().isHorizontal() :
|
||||
clickedFace == Direction.DOWN || !upper && clickedFace.axis().isHorizontal();
|
||||
clickedFace == Direction.UP || (upper && clickedFace.axis().isHorizontal()) :
|
||||
clickedFace == Direction.DOWN || (!upper && clickedFace.axis().isHorizontal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,8 +119,7 @@ public class SlabBlockBehavior extends BukkitBlockBehavior {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
Property<SlabType> type = (Property<SlabType>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("type"), "warning.config.block.behavior.trapdoor.missing_type");
|
||||
|
||||
Property<SlabType> type = (Property<SlabType>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("type"), "warning.config.block.behavior.slab.missing_type");
|
||||
return new SlabBlockBehavior(block, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,26 +2,17 @@ package net.momirealms.craftengine.bukkit.world;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.api.CraftEngineBlocks;
|
||||
import net.momirealms.craftengine.bukkit.block.BukkitBlockManager;
|
||||
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
||||
import net.momirealms.craftengine.bukkit.item.behavior.BlockItemBehavior;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MFluids;
|
||||
import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
import net.momirealms.craftengine.core.item.CustomItem;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
||||
import net.momirealms.craftengine.core.item.context.BlockPlaceContext;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.world.BlockInWorld;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BukkitBlockInWorld implements BlockInWorld {
|
||||
private final Block block;
|
||||
|
||||
Reference in New Issue
Block a user