9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-28 19:39:11 +00:00

增强数字参数

This commit is contained in:
XiaoMoMi
2025-05-04 19:52:26 +08:00
parent 5e28d964be
commit dd3e1276ec
48 changed files with 388 additions and 242 deletions

View File

@@ -70,6 +70,25 @@ warning.config.type.float: "<yellow>Issue found in file <arg:0> - Failed to load
warning.config.type.double: "<yellow>Issue found in file <arg:0> - Failed to load '<arg:1>': Cannot cast '<arg:2>' to double type for option '<arg:3>'.</yellow>"
warning.config.type.quaternionf: "<yellow>Issue found in file <arg:0> - Failed to load '<arg:1>': Cannot cast '<arg:2>' to Quaternionf type for option '<arg:3>'.</yellow>"
warning.config.type.vector3f: "<yellow>Issue found in file <arg:0> - Failed to load '<arg:1>': Cannot cast '<arg:2>' to Vector3f type for option '<arg:3>'.</yellow>"
warning.config.number.missing_argument: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the argument for 'number'.</yellow>"
warning.config.number.invalid_format: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid number format '<arg:2>'.</yellow>"
warning.config.number.fixed.missing_value: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'value' argument for 'constant' number.</yellow>"
warning.config.number.fixed.invalid_value: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using the invalid 'value' argument '<arg:2>' for 'constant' number.</yellow>"
warning.config.number.expression.missing_expression: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'expression' argument for 'expression' number.</yellow>"
warning.config.number.uniform.missing_min: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'min' argument for 'uniform' number.</yellow>"
warning.config.number.uniform.missing_max: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'max' argument for 'uniform' number.</yellow>"
warning.config.condition.all_of.missing_terms: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'terms' argument for 'all_of' condition.</yellow>"
warning.config.condition.all_of.invalid_terms_type: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' has a misconfigured 'all_of' condition, 'terms' should be a map list, current type: '<arg:2>'.</yellow>"
warning.config.condition.any_of.missing_terms: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'terms' argument for 'any_of' condition.</yellow>"
warning.config.condition.any_of.invalid_terms_type: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' has a misconfigured 'any_of' condition, 'terms' should be a map list, current type: '<arg:2>'.</yellow>"
warning.config.condition.inverted.missing_term: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'term' argument for 'inverted' condition.</yellow>"
warning.config.condition.inverted.invalid_term_type: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' has a misconfigured 'inverted' condition, 'term' should be a config section, current type: '<arg:2>'.</yellow>"
warning.config.condition.enchantment.missing_predicate: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'predicate' argument for 'enchantment' condition.</yellow>"
warning.config.condition.enchantment.invalid_predicate: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid enchantment 'predicate' argument '<arg:2>'.</yellow>"
warning.config.condition.match_block_property.missing_properties: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'properties' argument for 'match_block_property' condition.</yellow>"
warning.config.condition.match_item.missing_id: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'id' argument for 'match_item' condition.</yellow>"
warning.config.condition.table_bonus.missing_enchantment: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'enchantment' argument for 'table_bonus' condition.</yellow>"
warning.config.condition.table_bonus.missing_chances: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'chances' argument for 'table_bonus' condition.</yellow>"
warning.config.structure.not_section: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is expected to be a config section while it's actually a(n) '<arg:2>'.</yellow>"
warning.config.image.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated image '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.image.missing_height: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is missing the required 'height' argument.</yellow>"
@@ -228,8 +247,6 @@ warning.config.loot_table.entry.exp.missing_count: "<yellow>Issue found in file
warning.config.loot_table.entry.item.missing_item: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, entry 'item' is missing the required 'item' argument.</yellow>"
warning.config.loot_table.condition.missing_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the conditions is missing the required 'type' argument.</yellow>"
warning.config.loot_table.condition.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the conditions is using an invalid condition type '<arg:2>'.</yellow>"
warning.config.loot_table.condition.table_bonus.missing_enchantment: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'table_bonus' condition is missing the required 'enchantment' argument.</yellow>"
warning.config.loot_table.condition.table_bonus.missing_chances: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'table_bonus' condition is missing the required 'chances' argument.</yellow>"
warning.config.loot_table.number.missing_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the numbers is missing the required 'type' argument.</yellow>"
warning.config.loot_table.number.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the numbers is using an invalid number type '<arg:2>'.</yellow>"
warning.config.host.missing_type: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required 'type' argument for host.</yellow>"

View File

@@ -40,11 +40,11 @@ argument.parse.failure.aggregate.failure: "<red>无效的组件 '<arg:0>': <arg:
argument.parse.failure.either: "<red>无法从 '<arg:0>' 解析 <arg:1> 或 <arg:2></red>"
argument.parse.failure.namedtextcolor: "<red>'<arg:0>' 不是颜色代码</red>"
command.reload.config.success: "<white>重新加载配置完成. 耗时 <green><arg:0></green> 毫秒</white> <gray>(异步: <arg:1>ms | 同步: <arg:2>ms)</gray>"
command.reload.config.failure: "<red>重新加载配置失败请检查控制台日志</red>"
command.reload.config.failure: "<red>重新加载配置失败, 请检查控制台日志</red>"
command.reload.pack.success: "<white>资源包重新加载完成. 耗时 <green><arg:0></green> 毫秒</white>"
command.reload.pack.failure: "<red>重新加载资源包失败请检查控制台日志</red>"
command.reload.pack.failure: "<red>重新加载资源包失败, 请检查控制台日志</red>"
command.reload.all.success: "<white>全部重新加载完成. 耗时 <green><arg:0></green> 毫秒</white> <gray>(异步: <arg:1>ms | 同步: <arg:2>ms | 资源包: <arg:3>ms)</gray>"
command.reload.all.failure: "<red>重新加载失败请检查控制台日志</red>"
command.reload.all.failure: "<red>重新加载失败, 请检查控制台日志</red>"
command.item.get.success: "<white>获得<arg:0>个<arg:1></white>"
command.item.get.failure.not_exist: "<red><lang:argument.item.id.invalid:'<arg:0>'></red>"
command.item.give.success.single: "<lang:commands.give.success.single:'<arg:0>':'<arg:1>':'<arg:2>'>"
@@ -70,6 +70,25 @@ warning.config.type.float: "<yellow>在文件 <arg:0> 发现问题 - 无法加
warning.config.type.double: "<yellow>在文件 <arg:0> 发现问题 - 无法加载 '<arg:1>': 无法将 '<arg:2>' 转换为双精度类型 (选项 '<arg:3>')</yellow>"
warning.config.type.quaternionf: "<yellow>在文件 <arg:0> 发现问题 - 无法加载 '<arg:1>': 无法将 '<arg:2>' 转换为四元数类型 (选项 '<arg:3>')</yellow>"
warning.config.type.vector3f: "<yellow>在文件 <arg:0> 发现问题 - 无法加载 '<arg:1>': 无法将 '<arg:2>' 转换为三维向量类型 (选项 '<arg:3>')</yellow>"
warning.config.number.missing_argument: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少数字参数</yellow>"
warning.config.number.invalid_format: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 使用了无效的数字格式 '<arg:2>'</yellow>"
warning.config.number.fixed.missing_value: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'constant' 数字类型所需的 'value' 参数</yellow>"
warning.config.number.fixed.invalid_value: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 使用了无效的常量值参数 '<arg:2>'</yellow>"
warning.config.number.expression.missing_expression: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'expression' 数字类型所需的 'expression' 参数</yellow>"
warning.config.number.uniform.missing_min: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'uniform' 数字类型所需的 'min' 参数</yellow>"
warning.config.number.uniform.missing_max: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'uniform' 数字类型所需的 'max' 参数</yellow>"
warning.config.condition.all_of.missing_terms: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'all_of' 条件所需的 'terms' 参数</yellow>"
warning.config.condition.all_of.invalid_terms_type: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 的 'all_of' 条件配置错误, 'terms' 应为映射列表, 当前类型: '<arg:2>'</yellow>"
warning.config.condition.any_of.missing_terms: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'any_of' 条件所需的 'terms' 参数</yellow>"
warning.config.condition.any_of.invalid_terms_type: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 的 'any_of' 条件配置错误, 'terms' 应为映射列表, 当前类型: '<arg:2>'</yellow>"
warning.config.condition.inverted.missing_term: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'inverted' 条件所需的 'term' 参数</yellow>"
warning.config.condition.inverted.invalid_term_type: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 的 'inverted' 条件配置错误, 'term' 应为配置节点, 当前类型: '<arg:2>'</yellow>"
warning.config.condition.enchantment.missing_predicate: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'enchantment' 条件所需的 'predicate' 参数</yellow>"
warning.config.condition.enchantment.invalid_predicate: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 使用了无效的附魔 'predicate' 参数 '<arg:2>'</yellow>"
warning.config.condition.match_block_property.missing_properties: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'match_block_property' 条件所需的 'properties' 参数</yellow>"
warning.config.condition.match_item.missing_id: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'match_item' 条件所需的 'id' 参数</yellow>"
warning.config.condition.table_bonus.missing_enchantment: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'table_bonus' 条件所需的 'enchantment' 参数</yellow>"
warning.config.condition.table_bonus.missing_chances: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'table_bonus' 条件所需的 'chances' 参数</yellow>"
warning.config.structure.not_section: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 应为配置段落 但实际类型为 '<arg:2>'</yellow>"
warning.config.image.duplicate: "<yellow>在文件 <arg:0> 发现问题 - 重复的图片配置 '<arg:1>' 请检查其他文件中是否存在相同配置</yellow>"
warning.config.image.missing_height: "<yellow>在文件 <arg:0> 发现问题 - 图片 '<arg:1>' 缺少必需的 'height' 参数</yellow>"

View File

@@ -150,11 +150,11 @@ public class BlockEventListener implements Listener {
}
// drop items
ContextHolder.Builder builder = ContextHolder.builder();
builder.withParameter(CommonParameters.WORLD, world);
builder.withParameter(CommonParameters.LOCATION, vec3d);
builder.withParameter(CommonParameters.PLAYER, serverPlayer);
builder.withOptionalParameter(CommonParameters.TOOL, itemInHand);
ContextHolder.Builder builder = ContextHolder.builder()
.withParameter(CommonParameters.WORLD, world)
.withParameter(CommonParameters.LOCATION, vec3d)
.withParameter(CommonParameters.PLAYER, serverPlayer)
.withOptionalParameter(CommonParameters.TOOL, itemInHand);
for (Item<Object> item : state.getDrops(builder, world)) {
world.dropItemNaturally(vec3d, item);
}
@@ -171,11 +171,11 @@ public class BlockEventListener implements Listener {
BukkitServerPlayer serverPlayer = this.plugin.adapt(player);
net.momirealms.craftengine.core.world.World world = new BukkitWorld(player.getWorld());
Vec3d vec3d = new Vec3d(location.getBlockX() + 0.5, location.getBlockY() + 0.5, location.getBlockZ() + 0.5);
ContextHolder.Builder builder = ContextHolder.builder();
builder.withParameter(CommonParameters.WORLD, world);
builder.withParameter(CommonParameters.LOCATION, vec3d);
builder.withParameter(CommonParameters.PLAYER, serverPlayer);
builder.withOptionalParameter(CommonParameters.TOOL, serverPlayer.getItemInHand(InteractionHand.MAIN_HAND));
ContextHolder.Builder builder = ContextHolder.builder()
.withParameter(CommonParameters.WORLD, world)
.withParameter(CommonParameters.LOCATION, vec3d)
.withParameter(CommonParameters.PLAYER, serverPlayer)
.withOptionalParameter(CommonParameters.TOOL, serverPlayer.getItemInHand(InteractionHand.MAIN_HAND));
ContextHolder contextHolder = builder.build();
for (LootTable<?> lootTable : it.lootTables()) {
for (Item<?> item : lootTable.getRandomItems(contextHolder, world)) {
@@ -213,9 +213,9 @@ public class BlockEventListener implements Listener {
Location location = block.getLocation();
net.momirealms.craftengine.core.world.World world = new BukkitWorld(block.getWorld());
Vec3d vec3d = new Vec3d(location.getBlockX() + 0.5, location.getBlockY() + 0.5, location.getBlockZ() + 0.5);
ContextHolder.Builder builder = ContextHolder.builder();
builder.withParameter(CommonParameters.WORLD, world);
builder.withParameter(CommonParameters.LOCATION, vec3d);
ContextHolder.Builder builder = ContextHolder.builder()
.withParameter(CommonParameters.WORLD, world)
.withParameter(CommonParameters.LOCATION, vec3d);
for (Item<?> item : immutableBlockState.getDrops(builder, world)) {
world.dropItemNaturally(vec3d, item);
}

View File

@@ -30,7 +30,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ThreadLocalRandom;
public class CropBlockBehavior extends BushBlockBehavior {
public static final Factory FACTORY = new Factory();
@@ -148,7 +147,7 @@ public class CropBlockBehavior extends BushBlockBehavior {
int z = FastNMS.INSTANCE.field$Vec3i$z(pos);
net.momirealms.craftengine.core.world.World wrappedWorld = new BukkitWorld(world);
int i = this.getAge(immutableBlockState) + this.boneMealBonus.getInt(new LootContext(wrappedWorld, 1, ThreadLocalRandom.current(), ContextHolder.builder()
int i = this.getAge(immutableBlockState) + this.boneMealBonus.getInt(new LootContext(wrappedWorld, 1, ContextHolder.builder()
.withParameter(CommonParameters.WORLD, wrappedWorld)
.withParameter(CommonParameters.LOCATION, Vec3d.atCenterOf(new Vec3i(x, y, z)))
.build()));

View File

@@ -752,7 +752,7 @@ public class RecipeEventListener implements Listener {
return;
}
Item<ItemStack> newItem = customItem.buildItem(ItemBuildContext.of(plugin.adapt(player), ContextHolder.EMPTY));
Item<ItemStack> newItem = customItem.buildItem(ItemBuildContext.of(plugin.adapt(player)));
int remainingDurability = totalMaxDamage - totalDamage;
int newItemDamage = Math.max(0, newItem.maxDamage().get() - remainingDurability);
newItem.damage(newItemDamage);

View File

@@ -70,7 +70,6 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme
ContextHolder.Builder builder = ContextHolder.builder();
builder.withParameter(CommonParameters.WORLD, world);
builder.withParameter(CommonParameters.LOCATION, vec3d);
// TODO Vanilla State Parameter
if (VersionHelper.isOrAbove1_20_5()) {
if (event.getDamageSource().getCausingEntity() instanceof Player player) {
BukkitServerPlayer serverPlayer = this.plugin.adapt(player);

View File

@@ -1,11 +1,10 @@
package net.momirealms.craftengine.bukkit.plugin.command.feature;
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.plugin.context.ContextHolder;
import net.momirealms.craftengine.core.plugin.context.PlayerOptionalContext;
import net.momirealms.craftengine.core.util.AdventureHelper;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -24,10 +23,9 @@ public class TestCommand extends BukkitCommandFeature<CommandSender> {
.senderType(Player.class)
.required("text", StringParser.greedyStringParser())
.handler(context -> {
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")));
String text = "<red><arg:1:0912012><papi:player_name></red>";
PlayerOptionalContext context1 = PlayerOptionalContext.of(plugin().adapt(context.sender()), ContextHolder.builder());
plugin().senderFactory().wrap(context.sender()).sendMessage(AdventureHelper.customMiniMessage().deserialize(text, context1.tagResolvers()));
});
}

View File

@@ -199,7 +199,6 @@ public class PacketConsumers {
buf.writeInt(chunkZ);
if (VersionHelper.isOrAbove1_21_5()) {
buf.writeVarInt(heightmapsCount);
assert heightmapsMap != null;
for (Map.Entry<Integer, long[]> entry : heightmapsMap.entrySet()) {
buf.writeVarInt(entry.getKey());
buf.writeLongArray(entry.getValue());