mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 02:49:15 +00:00
更新nbt库适配1.21.5组件变化
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
# Stores something that has not been implemented yet
|
||||
|
||||
########################################################################################################################################################################################################################
|
||||
# If you want to create more doors, you can use doors of other materials, such as birch. You can only create one custom door from each vanilla door.
|
||||
# Oak Door
|
||||
minecraft:oak_door[facing=north,half=lower,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=north,half=lower,hinge=right,open=false,powered=false]
|
||||
minecraft:oak_door[facing=south,half=lower,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=south,half=lower,hinge=right,open=false,powered=false]
|
||||
minecraft:oak_door[facing=east,half=lower,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=east,half=lower,hinge=right,open=false,powered=false]
|
||||
minecraft:oak_door[facing=west,half=lower,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=west,half=lower,hinge=right,open=false,powered=false]
|
||||
minecraft:oak_door[facing=north,half=lower,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=north,half=lower,hinge=right,open=true,powered=false]
|
||||
minecraft:oak_door[facing=south,half=lower,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=south,half=lower,hinge=right,open=true,powered=false]
|
||||
minecraft:oak_door[facing=east,half=lower,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=east,half=lower,hinge=right,open=true,powered=false]
|
||||
minecraft:oak_door[facing=west,half=lower,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=west,half=lower,hinge=right,open=true,powered=false]
|
||||
minecraft:oak_door[facing=north,half=lower,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=north,half=lower,hinge=left,open=false,powered=false]
|
||||
minecraft:oak_door[facing=south,half=lower,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=south,half=lower,hinge=left,open=false,powered=false]
|
||||
minecraft:oak_door[facing=east,half=lower,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=east,half=lower,hinge=left,open=false,powered=false]
|
||||
minecraft:oak_door[facing=west,half=lower,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=west,half=lower,hinge=left,open=false,powered=false]
|
||||
minecraft:oak_door[facing=north,half=lower,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=north,half=lower,hinge=left,open=true,powered=false]
|
||||
minecraft:oak_door[facing=south,half=lower,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=south,half=lower,hinge=left,open=true,powered=false]
|
||||
minecraft:oak_door[facing=east,half=lower,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=east,half=lower,hinge=left,open=true,powered=false]
|
||||
minecraft:oak_door[facing=west,half=lower,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=west,half=lower,hinge=left,open=true,powered=false]
|
||||
minecraft:oak_door[facing=north,half=upper,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=north,half=upper,hinge=right,open=false,powered=false]
|
||||
minecraft:oak_door[facing=south,half=upper,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=south,half=upper,hinge=right,open=false,powered=false]
|
||||
minecraft:oak_door[facing=east,half=upper,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=east,half=upper,hinge=right,open=false,powered=false]
|
||||
minecraft:oak_door[facing=west,half=upper,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=west,half=upper,hinge=right,open=false,powered=false]
|
||||
minecraft:oak_door[facing=north,half=upper,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=north,half=upper,hinge=right,open=true,powered=false]
|
||||
minecraft:oak_door[facing=south,half=upper,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=south,half=upper,hinge=right,open=true,powered=false]
|
||||
minecraft:oak_door[facing=east,half=upper,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=east,half=upper,hinge=right,open=true,powered=false]
|
||||
minecraft:oak_door[facing=west,half=upper,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=west,half=upper,hinge=right,open=true,powered=false]
|
||||
minecraft:oak_door[facing=north,half=upper,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=north,half=upper,hinge=left,open=false,powered=false]
|
||||
minecraft:oak_door[facing=south,half=upper,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=south,half=upper,hinge=left,open=false,powered=false]
|
||||
minecraft:oak_door[facing=east,half=upper,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=east,half=upper,hinge=left,open=false,powered=false]
|
||||
minecraft:oak_door[facing=west,half=upper,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=west,half=upper,hinge=left,open=false,powered=false]
|
||||
minecraft:oak_door[facing=north,half=upper,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=north,half=upper,hinge=left,open=true,powered=false]
|
||||
minecraft:oak_door[facing=south,half=upper,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=south,half=upper,hinge=left,open=true,powered=false]
|
||||
minecraft:oak_door[facing=east,half=upper,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=east,half=upper,hinge=left,open=true,powered=false]
|
||||
minecraft:oak_door[facing=west,half=upper,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=west,half=upper,hinge=left,open=true,powered=false]
|
||||
# You can create more trapdoor if you don't care the facing.
|
||||
# Oak Trapdoor
|
||||
minecraft:oak_trapdoor[facing=north,open=false,powered=true,waterlogged=false]: minecraft:oak_trapdoor[facing=north,open=false,powered=false,waterlogged=false]
|
||||
minecraft:oak_trapdoor[facing=north,open=false,powered=true,waterlogged=true]: minecraft:oak_trapdoor[facing=north,open=false,powered=false,waterlogged=true]
|
||||
minecraft:oak_trapdoor[facing=north,open=true,powered=true,waterlogged=false]: minecraft:oak_trapdoor[facing=north,open=true,powered=false,waterlogged=false]
|
||||
minecraft:oak_trapdoor[facing=north,open=true,powered=true,waterlogged=true]: minecraft:oak_trapdoor[facing=north,open=true,powered=false,waterlogged=true]
|
||||
minecraft:oak_trapdoor[facing=south,open=false,powered=true,waterlogged=false]: minecraft:oak_trapdoor[facing=south,open=false,powered=false,waterlogged=false]
|
||||
minecraft:oak_trapdoor[facing=south,open=false,powered=true,waterlogged=true]: minecraft:oak_trapdoor[facing=south,open=false,powered=false,waterlogged=true]
|
||||
minecraft:oak_trapdoor[facing=south,open=true,powered=true,waterlogged=false]: minecraft:oak_trapdoor[facing=south,open=true,powered=false,waterlogged=false]
|
||||
minecraft:oak_trapdoor[facing=south,open=true,powered=true,waterlogged=true]: minecraft:oak_trapdoor[facing=south,open=true,powered=false,waterlogged=true]
|
||||
minecraft:oak_trapdoor[facing=east,open=false,powered=true,waterlogged=false]: minecraft:oak_trapdoor[facing=east,open=false,powered=false,waterlogged=false]
|
||||
minecraft:oak_trapdoor[facing=east,open=false,powered=true,waterlogged=true]: minecraft:oak_trapdoor[facing=east,open=false,powered=false,waterlogged=true]
|
||||
minecraft:oak_trapdoor[facing=east,open=true,powered=true,waterlogged=false]: minecraft:oak_trapdoor[facing=east,open=true,powered=false,waterlogged=false]
|
||||
minecraft:oak_trapdoor[facing=east,open=true,powered=true,waterlogged=true]: minecraft:oak_trapdoor[facing=east,open=true,powered=false,waterlogged=true]
|
||||
minecraft:oak_trapdoor[facing=west,open=false,powered=true,waterlogged=false]: minecraft:oak_trapdoor[facing=west,open=false,powered=false,waterlogged=false]
|
||||
minecraft:oak_trapdoor[facing=west,open=false,powered=true,waterlogged=true]: minecraft:oak_trapdoor[facing=west,open=false,powered=false,waterlogged=true]
|
||||
minecraft:oak_trapdoor[facing=west,open=true,powered=true,waterlogged=false]: minecraft:oak_trapdoor[facing=west,open=true,powered=false,waterlogged=false]
|
||||
minecraft:oak_trapdoor[facing=west,open=true,powered=true,waterlogged=true]: minecraft:oak_trapdoor[facing=west,open=true,powered=false,waterlogged=true]
|
||||
# fence_gate
|
||||
minecraft:oak_fence_gate[facing=north,open=false,powered=true,in_wall=false]: minecraft:oak_fence_gate[facing=north,open=false,powered=false,in_wall=false]
|
||||
minecraft:oak_fence_gate[facing=north,open=false,powered=true,in_wall=true]: minecraft:oak_fence_gate[facing=north,open=false,powered=false,in_wall=true]
|
||||
minecraft:oak_fence_gate[facing=north,open=true,powered=true,in_wall=false]: minecraft:oak_fence_gate[facing=north,open=true,powered=false,in_wall=false]
|
||||
minecraft:oak_fence_gate[facing=north,open=true,powered=true,in_wall=true]: minecraft:oak_fence_gate[facing=north,open=true,powered=false,in_wall=true]
|
||||
minecraft:oak_fence_gate[facing=south,open=false,powered=true,in_wall=false]: minecraft:oak_fence_gate[facing=south,open=false,powered=false,in_wall=false]
|
||||
minecraft:oak_fence_gate[facing=south,open=false,powered=true,in_wall=true]: minecraft:oak_fence_gate[facing=south,open=false,powered=false,in_wall=true]
|
||||
minecraft:oak_fence_gate[facing=south,open=true,powered=true,in_wall=false]: minecraft:oak_fence_gate[facing=south,open=true,powered=false,in_wall=false]
|
||||
minecraft:oak_fence_gate[facing=south,open=true,powered=true,in_wall=true]: minecraft:oak_fence_gate[facing=south,open=true,powered=false,in_wall=true]
|
||||
minecraft:oak_fence_gate[facing=east,open=false,powered=true,in_wall=false]: minecraft:oak_fence_gate[facing=east,open=false,powered=false,in_wall=false]
|
||||
minecraft:oak_fence_gate[facing=east,open=false,powered=true,in_wall=true]: minecraft:oak_fence_gate[facing=east,open=false,powered=false,in_wall=true]
|
||||
minecraft:oak_fence_gate[facing=east,open=true,powered=true,in_wall=false]: minecraft:oak_fence_gate[facing=east,open=true,powered=false,in_wall=false]
|
||||
minecraft:oak_fence_gate[facing=east,open=true,powered=true,in_wall=true]: minecraft:oak_fence_gate[facing=east,open=true,powered=false,in_wall=true]
|
||||
minecraft:oak_fence_gate[facing=west,open=false,powered=true,in_wall=false]: minecraft:oak_fence_gate[facing=west,open=false,powered=false,in_wall=false]
|
||||
minecraft:oak_fence_gate[facing=west,open=false,powered=true,in_wall=true]: minecraft:oak_fence_gate[facing=west,open=false,powered=false,in_wall=true]
|
||||
minecraft:oak_fence_gate[facing=west,open=true,powered=true,in_wall=false]: minecraft:oak_fence_gate[facing=west,open=true,powered=false,in_wall=false]
|
||||
minecraft:oak_fence_gate[facing=west,open=true,powered=true,in_wall=true]: minecraft:oak_fence_gate[facing=west,open=true,powered=false,in_wall=true]
|
||||
@@ -3,8 +3,8 @@ package net.momirealms.craftengine.bukkit.api;
|
||||
import net.momirealms.craftengine.bukkit.entity.BukkitEntity;
|
||||
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
||||
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
|
||||
import net.momirealms.craftengine.bukkit.world.BukkitWorld;
|
||||
import net.momirealms.craftengine.bukkit.world.BukkitBlockInWorld;
|
||||
import net.momirealms.craftengine.bukkit.world.BukkitWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class BukkitEntity extends Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public World level() {
|
||||
public World world() {
|
||||
return new BukkitWorld(literalObject().getWorld());
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ItemEventListener implements Listener {
|
||||
|
||||
if (optionalItemBehaviors.isPresent()) {
|
||||
for (ItemBehavior itemBehavior : optionalItemBehaviors.get()) {
|
||||
InteractionResult result = itemBehavior.use(player.level(), player, hand);
|
||||
InteractionResult result = itemBehavior.use(player.world(), player, hand);
|
||||
if (result == InteractionResult.SUCCESS_AND_CANCEL) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -167,7 +167,7 @@ public class ItemEventListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
int maxY = player.level().worldHeight().getMaxBuildHeight() - 1;
|
||||
int maxY = player.world().worldHeight().getMaxBuildHeight() - 1;
|
||||
if (direction == Direction.UP
|
||||
&& result != InteractionResult.SUCCESS
|
||||
&& pos.y() >= maxY
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package net.momirealms.craftengine.bukkit.plugin.command.feature;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
||||
import com.saicone.rtag.util.ChatComponent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.bukkit.plugin.command.BukkitCommandFeature;
|
||||
import net.momirealms.craftengine.bukkit.util.ComponentUtils;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.parser.standard.StringParser;
|
||||
|
||||
public class TestCommand extends BukkitCommandFeature<CommandSender> {
|
||||
|
||||
@@ -19,9 +22,12 @@ public class TestCommand extends BukkitCommandFeature<CommandSender> {
|
||||
public Command.Builder<? extends CommandSender> assembleCommand(org.incendo.cloud.CommandManager<CommandSender> manager, Command.Builder<CommandSender> builder) {
|
||||
return builder
|
||||
.senderType(Player.class)
|
||||
.required("text", StringParser.greedyStringParser())
|
||||
.handler(context -> {
|
||||
Player player = context.sender();
|
||||
player.getInventory().addItem(BukkitItemManager.instance().createWrappedItem(Key.from("default:topaz"), null).getItem());
|
||||
plugin().senderFactory().wrap(context.sender()).sendMessage(Component.text(
|
||||
ChatComponent.toTag(ComponentUtils.adventureToMinecraft(AdventureHelper.miniMessage().deserialize(context.get("text")))).toString()
|
||||
));
|
||||
plugin().senderFactory().wrap(context.sender()).sendMessage(AdventureHelper.miniMessage().deserialize(context.get("text")));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1349,7 +1349,7 @@ public class PacketConsumers {
|
||||
} catch (Exception e) {
|
||||
CraftEngine.instance().logger().warn("Failed to handle ServerboundSetCreativeModeSlotPacket", e);
|
||||
}
|
||||
}, (World) player.level().platformWorld(), (MCUtils.fastFloor(player.x())) >> 4, (MCUtils.fastFloor(player.z())) >> 4);
|
||||
}, (World) player.world().platformWorld(), (MCUtils.fastFloor(player.x())) >> 4, (MCUtils.fastFloor(player.z())) >> 4);
|
||||
} else {
|
||||
handleSetCreativeSlotPacketOnMainThread(player, packet);
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ public class BukkitServerPlayer extends Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public World level() {
|
||||
public World world() {
|
||||
return new BukkitWorld(platformPlayer().getWorld());
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ParticleUtils {
|
||||
} catch (IllegalArgumentException e) {
|
||||
return switch (particle) {
|
||||
case "REDSTONE" -> Particle.valueOf("DUST");
|
||||
case "VILLAGER_HAPPY" -> Particle.valueOf(VersionHelper.isOrAbove1_20_5() ? "HAPPY_VILLAGER" : "VILLAGER_HAPPY");
|
||||
case "VILLAGER_HAPPY", "HAPPY_VILLAGER" -> Particle.valueOf(VersionHelper.isOrAbove1_20_5() ? "HAPPY_VILLAGER" : "VILLAGER_HAPPY");
|
||||
default -> Particle.valueOf(particle);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ import net.momirealms.craftengine.core.item.CustomItem;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.context.BlockPlaceContext;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.text.minimessage.NamedArgumentTag;
|
||||
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;
|
||||
@@ -80,6 +80,11 @@ public class BukkitBlockInWorld implements BlockInWorld {
|
||||
return this.block.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World world() {
|
||||
return new BukkitWorld(this.block.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsString() {
|
||||
ImmutableBlockState state = CraftEngineBlocks.getCustomBlockState(this.block);
|
||||
|
||||
@@ -6,9 +6,9 @@ import net.momirealms.craftengine.bukkit.util.ItemUtils;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.BlockInWorld;
|
||||
import net.momirealms.craftengine.core.world.Vec3d;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
import net.momirealms.craftengine.core.world.BlockInWorld;
|
||||
import net.momirealms.craftengine.core.world.WorldHeight;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.SoundCategory;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package net.momirealms.craftengine.core.block;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.util.context.ContextHolder;
|
||||
import net.momirealms.craftengine.core.util.context.PlayerOptionalContext;
|
||||
import net.momirealms.craftengine.core.world.BlockInWorld;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerBlockActionContext extends PlayerOptionalContext {
|
||||
private BlockInWorld block;
|
||||
|
||||
public PlayerBlockActionContext(@NotNull Player player, @NotNull ContextHolder contexts) {
|
||||
super(player, contexts);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public abstract class Entity {
|
||||
|
||||
public abstract float getYRot();
|
||||
|
||||
public abstract World level();
|
||||
public abstract World world();
|
||||
|
||||
public abstract Direction getDirection();
|
||||
|
||||
|
||||
@@ -170,7 +170,8 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
PlayerOptionalContext.of(player, ContextHolder.builder()
|
||||
.withOptionalParameter(EmojiParameters.EMOJI, emoji.emojiImage())
|
||||
.withParameter(EmojiParameters.KEYWORD, emoji.keywords().get(0))
|
||||
.build()).tagResolvers())
|
||||
.build())
|
||||
.tagResolvers())
|
||||
);
|
||||
if (emojis.size() >= maxTimes) break;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package net.momirealms.craftengine.core.font;
|
||||
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.context.ContextKey;
|
||||
|
||||
public class EmojiParameters {
|
||||
public static final ContextKey<String> KEYWORD = new ContextKey<>(Key.of("keyword"));
|
||||
public static final ContextKey<String> EMOJI = new ContextKey<>(Key.of("emoji"));
|
||||
public final class EmojiParameters {
|
||||
private EmojiParameters() {}
|
||||
|
||||
public static final ContextKey<String> KEYWORD = ContextKey.of("keyword");
|
||||
public static final ContextKey<String> EMOJI = ContextKey.of("emoji");
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class UseOnContext {
|
||||
private final Item<?> itemStack;
|
||||
|
||||
public UseOnContext(Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
this(player.level(), player, hand, player.getItemInHand(hand), hit);
|
||||
this(player.world(), player, hand, player.getItemInHand(hand), hit);
|
||||
}
|
||||
|
||||
public UseOnContext(World world, Player player, InteractionHand hand, Item<?> stack, BlockHitResult hit) {
|
||||
|
||||
@@ -4,18 +4,19 @@ import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
import net.momirealms.craftengine.core.entity.Entity;
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.context.ContextKey;
|
||||
import net.momirealms.craftengine.core.world.Vec3d;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
|
||||
public class LootParameters {
|
||||
public static final ContextKey<Vec3d> LOCATION = new ContextKey<>(Key.of("craftengine:location"));
|
||||
public static final ContextKey<World> WORLD = new ContextKey<>(Key.of("craftengine:world"));
|
||||
public static final ContextKey<Entity> ENTITY = new ContextKey<>(Key.of("craftengine:entity"));
|
||||
public static final ContextKey<Boolean> FALLING_BLOCK = new ContextKey<>(Key.of("craftengine:falling_block"));
|
||||
public static final ContextKey<Float> EXPLOSION_RADIUS = new ContextKey<>(Key.of("craftengine:explosion_radius"));
|
||||
public static final ContextKey<Player> PLAYER = new ContextKey<>(Key.of("craftengine:player"));
|
||||
public static final ContextKey<Item<?>> TOOL = new ContextKey<>(Key.of("craftengine:tool"));
|
||||
public static final ContextKey<ImmutableBlockState> BLOCK_STATE = new ContextKey<>(Key.of("craftengine:block_state"));
|
||||
public final class LootParameters {
|
||||
private LootParameters() {}
|
||||
|
||||
public static final ContextKey<Vec3d> LOCATION = ContextKey.of("location");
|
||||
public static final ContextKey<World> WORLD = ContextKey.of("world");
|
||||
public static final ContextKey<Entity> ENTITY = ContextKey.of("entity");
|
||||
public static final ContextKey<Boolean> FALLING_BLOCK = ContextKey.of("falling_block");
|
||||
public static final ContextKey<Float> EXPLOSION_RADIUS = ContextKey.of("explosion_radius");
|
||||
public static final ContextKey<Player> PLAYER = ContextKey.of("player");
|
||||
public static final ContextKey<Item<?>> TOOL = ContextKey.of("tool");
|
||||
public static final ContextKey<ImmutableBlockState> BLOCK_STATE = ContextKey.of("block_state");
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.momirealms.craftengine.core.pack.conflict.matcher;
|
||||
|
||||
import net.momirealms.craftengine.core.pack.conflict.PathContext;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.condition.AllOfCondition;
|
||||
import net.momirealms.craftengine.core.util.context.Condition;
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.momirealms.craftengine.core.pack.conflict.matcher;
|
||||
|
||||
import net.momirealms.craftengine.core.pack.conflict.PathContext;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.util.condition.InvertedCondition;
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.core.registry.WritableRegistry;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceKey;
|
||||
import net.momirealms.craftengine.core.util.condition.AllOfCondition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.GsonHelper;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.kyori.adventure.text.serializer.json.JSONOptions;
|
||||
import net.kyori.adventure.text.serializer.json.legacyimpl.NBTLegacyHoverEventSerializer;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
import net.momirealms.sparrow.nbt.serializer.NBTComponentSerializer;
|
||||
import net.momirealms.sparrow.nbt.serializer.NBTSerializerOptions;
|
||||
|
||||
/**
|
||||
* Helper class for handling Adventure components and related functionalities.
|
||||
@@ -34,8 +35,22 @@ public class AdventureHelper {
|
||||
builder.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get());
|
||||
builder.editOptions((b) -> b.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, false));
|
||||
}
|
||||
if (!VersionHelper.isOrAbove1_21_5()) {
|
||||
builder.editOptions((b) -> {
|
||||
b.value(JSONOptions.EMIT_CLICK_EVENT_TYPE, JSONOptions.ClickEventValueMode.CAMEL_CASE);
|
||||
b.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.CAMEL_CASE);
|
||||
b.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_KEY_AS_TYPE_AND_UUID_AS_ID, true);
|
||||
});
|
||||
}
|
||||
this.gsonComponentSerializer = builder.build();
|
||||
this.nbtComponentSerializer = NBTComponentSerializer.builder().build();
|
||||
this.nbtComponentSerializer = NBTComponentSerializer.builder()
|
||||
.editOptions((b) -> {
|
||||
if (!VersionHelper.isOrAbove1_21_5()) {
|
||||
b.value(NBTSerializerOptions.EMIT_CLICK_EVENT_TYPE, false);
|
||||
b.value(NBTSerializerOptions.EMIT_HOVER_EVENT_TYPE, false);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private static class SingletonHolder {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.momirealms.craftengine.core.util.context;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.util.context.parameter.BlockParameterProvider;
|
||||
import net.momirealms.craftengine.core.util.context.parameter.CommonParameterProvider;
|
||||
import net.momirealms.craftengine.core.util.context.parameter.PlayerParameterProvider;
|
||||
import net.momirealms.craftengine.core.world.BlockInWorld;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerBlockActionContext extends PlayerOptionalContext {
|
||||
|
||||
public PlayerBlockActionContext(@NotNull Player player, @NotNull BlockInWorld block, @NotNull ContextHolder contexts) {
|
||||
super(player, contexts, List.of(new CommonParameterProvider(), new PlayerParameterProvider(player), new BlockParameterProvider(block)));
|
||||
}
|
||||
|
||||
public static PlayerBlockActionContext of(@NotNull Player player, @NotNull BlockInWorld block, @NotNull ContextHolder contexts) {
|
||||
return new PlayerBlockActionContext(player, block, contexts);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import net.momirealms.craftengine.core.util.context.parameter.PlayerParameterPro
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerOptionalContext extends AbstractAdditionalCommonContext implements MiniMessageTagContext {
|
||||
public static final PlayerOptionalContext EMPTY = new PlayerOptionalContext(null, ContextHolder.EMPTY);
|
||||
|
||||
@@ -22,6 +22,7 @@ public class BlockParameterProvider implements LazyContextParameterProvider {
|
||||
CONTEXT_FUNCTIONS.put(BlockParameters.BLOCK_Z, BlockInWorld::z);
|
||||
CONTEXT_FUNCTIONS.put(BlockParameters.BLOCK_OWNER, BlockInWorld::owner);
|
||||
CONTEXT_FUNCTIONS.put(BlockParameters.BLOCK_STATE, BlockInWorld::getAsString);
|
||||
CONTEXT_FUNCTIONS.put(BlockParameters.WORLD_NAME, b -> b.world().name());
|
||||
}
|
||||
|
||||
private final BlockInWorld block;
|
||||
|
||||
@@ -4,17 +4,16 @@ import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.context.ContextKey;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class BlockParameters {
|
||||
private BlockParameters() {}
|
||||
|
||||
public static final ContextKey<Double> X = new ContextKey<>(Key.of("craftengine:block.x"));
|
||||
public static final ContextKey<Double> Y = new ContextKey<>(Key.of("craftengine:block.y"));
|
||||
public static final ContextKey<Double> Z = new ContextKey<>(Key.of("craftengine:block.z"));
|
||||
public static final ContextKey<Integer> BLOCK_X = new ContextKey<>(Key.of("craftengine:block.block_x"));
|
||||
public static final ContextKey<Integer> BLOCK_Y = new ContextKey<>(Key.of("craftengine:block.block_y"));
|
||||
public static final ContextKey<Integer> BLOCK_Z = new ContextKey<>(Key.of("craftengine:block.block_z"));
|
||||
public static final ContextKey<ImmutableBlockState> BLOCK_STATE = new ContextKey<>(Key.of("craftengine:block.state"));
|
||||
public static final ContextKey<Key> BLOCK_OWNER = new ContextKey<>(Key.of("craftengine:block.owner"));
|
||||
public static final ContextKey<Double> X = ContextKey.of("block.x");
|
||||
public static final ContextKey<Double> Y = ContextKey.of("block.y");
|
||||
public static final ContextKey<Double> Z = ContextKey.of("block.z");
|
||||
public static final ContextKey<Integer> BLOCK_X = ContextKey.of("block.block_x");
|
||||
public static final ContextKey<Integer> BLOCK_Y = ContextKey.of("block.block_y");
|
||||
public static final ContextKey<Integer> BLOCK_Z = ContextKey.of("block.block_z");
|
||||
public static final ContextKey<ImmutableBlockState> BLOCK_STATE = ContextKey.of("block.state");
|
||||
public static final ContextKey<Key> BLOCK_OWNER = ContextKey.of("block.owner.id");
|
||||
public static final ContextKey<String> WORLD_NAME = ContextKey.of("block.world.name");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ public class CommonParameterProvider implements LazyContextParameterProvider {
|
||||
|
||||
private static final Map<ContextKey<?>, Function<CommonParameterProvider, Object>> CONTEXT_FUNCTIONS = new HashMap<>();
|
||||
static {
|
||||
CONTEXT_FUNCTIONS.put(CommonParameters.RANDOM, (f) -> RandomUtils.generateRandomDouble(0,1));
|
||||
CONTEXT_FUNCTIONS.put(CommonParameters.RANDOM, (f) -> {
|
||||
f.lastRandom = RandomUtils.generateRandomDouble(0,1);
|
||||
return f.lastRandom;
|
||||
});
|
||||
CONTEXT_FUNCTIONS.put(CommonParameters.LAST_RANDOM, (f) -> {
|
||||
if (f.lastRandom == -1) {
|
||||
f.lastRandom = RandomUtils.generateRandomDouble(0, 1);
|
||||
|
||||
@@ -24,6 +24,7 @@ public class PlayerParameterProvider implements LazyContextParameterProvider {
|
||||
CONTEXT_FUNCTIONS.put(PlayerParameters.BLOCK_Z, p -> MCUtils.fastFloor(p.z()));
|
||||
CONTEXT_FUNCTIONS.put(PlayerParameters.NAME, Player::name);
|
||||
CONTEXT_FUNCTIONS.put(PlayerParameters.UUID, Player::uuid);
|
||||
CONTEXT_FUNCTIONS.put(PlayerParameters.WORLD_NAME, p -> p.world().name());
|
||||
}
|
||||
|
||||
private final Player player;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.momirealms.craftengine.core.util.context.parameter;
|
||||
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.context.ContextKey;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -8,12 +7,13 @@ import java.util.UUID;
|
||||
public final class PlayerParameters {
|
||||
private PlayerParameters() {}
|
||||
|
||||
public static final ContextKey<Double> X = new ContextKey<>(Key.of("craftengine:player.x"));
|
||||
public static final ContextKey<Double> Y = new ContextKey<>(Key.of("craftengine:player.y"));
|
||||
public static final ContextKey<Double> Z = new ContextKey<>(Key.of("craftengine:player.z"));
|
||||
public static final ContextKey<Integer> BLOCK_X = new ContextKey<>(Key.of("craftengine:player.block_x"));
|
||||
public static final ContextKey<Integer> BLOCK_Y = new ContextKey<>(Key.of("craftengine:player.block_y"));
|
||||
public static final ContextKey<Integer> BLOCK_Z = new ContextKey<>(Key.of("craftengine:player.block_z"));
|
||||
public static final ContextKey<String> NAME = new ContextKey<>(Key.of("craftengine:player.name"));
|
||||
public static final ContextKey<UUID> UUID = new ContextKey<>(Key.of("craftengine:player.uuid"));
|
||||
public static final ContextKey<Double> X = ContextKey.of("player.x");
|
||||
public static final ContextKey<Double> Y = ContextKey.of("player.y");
|
||||
public static final ContextKey<Double> Z = ContextKey.of("player.z");
|
||||
public static final ContextKey<Integer> BLOCK_X = ContextKey.of("player.block_x");
|
||||
public static final ContextKey<Integer> BLOCK_Y = ContextKey.of("player.block_y");
|
||||
public static final ContextKey<Integer> BLOCK_Z = ContextKey.of("player.block_z");
|
||||
public static final ContextKey<String> NAME = ContextKey.of("player.name");
|
||||
public static final ContextKey<String> WORLD_NAME = ContextKey.of("player.world.name");
|
||||
public static final ContextKey<UUID> UUID = ContextKey.of("player.uuid");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ public interface BlockInWorld {
|
||||
|
||||
String getAsString();
|
||||
|
||||
World world();
|
||||
|
||||
int x();
|
||||
|
||||
int y();
|
||||
|
||||
@@ -39,7 +39,7 @@ lz4_version=1.8.0
|
||||
geantyref_version=1.3.16
|
||||
zstd_version=1.5.7-2
|
||||
commons_io_version=2.18.0
|
||||
sparrow_nbt_version=0.6.2
|
||||
sparrow_nbt_version=0.7.1
|
||||
sparrow_util_version=0.39
|
||||
fastutil_version=8.5.15
|
||||
netty_version=4.1.119.Final
|
||||
|
||||
Reference in New Issue
Block a user