mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
feat(block): 添加配置文件和一个新的随机数类型
This commit is contained in:
@@ -0,0 +1,294 @@
|
||||
items:
|
||||
default:honeydew_item:
|
||||
material: apple
|
||||
data:
|
||||
item-name: <!i><i18n:item.honeydew_item>
|
||||
model:
|
||||
template: default:model/simplified_generated
|
||||
arguments:
|
||||
path: minecraft:item/custom/honeydew_item
|
||||
behavior:
|
||||
type: block_item
|
||||
block: default:honeydew_stem
|
||||
default:honeydew:
|
||||
material: nether_brick
|
||||
data:
|
||||
item-name: <!i><i18n:item.honeydew>
|
||||
model:
|
||||
path: minecraft:item/custom/honeydew
|
||||
generation:
|
||||
parent: minecraft:block/custom/honeydew
|
||||
behavior:
|
||||
type: block_item
|
||||
block: default:honeydew
|
||||
|
||||
blocks:
|
||||
default:honeydew:
|
||||
loot:
|
||||
pools:
|
||||
- rolls: 1
|
||||
entries:
|
||||
- type: alternatives
|
||||
children:
|
||||
- type: item
|
||||
item: default:honeydew
|
||||
conditions:
|
||||
- type: enchantment
|
||||
predicate: minecraft:silk_touch>=1
|
||||
- type: item
|
||||
item: default:honeydew_item
|
||||
functions:
|
||||
- type: apply_bonus
|
||||
enchantment: minecraft:fortune
|
||||
formula:
|
||||
type: ore_drops
|
||||
- type: set_count
|
||||
add: false
|
||||
count: 3~7
|
||||
- type: explosion_decay
|
||||
settings:
|
||||
map-color: 19
|
||||
hardness: 1
|
||||
resistance: 1
|
||||
push-reaction: DESTROY
|
||||
is-suffocating: true
|
||||
is-redstone-conductor: true
|
||||
item: default:honeydew
|
||||
tags:
|
||||
- minecraft:enderman_holdable
|
||||
- minecraft:mineable/axe
|
||||
- minecraft:sword_efficient
|
||||
incorrect-tool-dig-speed: 1
|
||||
state:
|
||||
id: 30
|
||||
state: note_block:30
|
||||
model:
|
||||
template: default:model/cube
|
||||
arguments:
|
||||
model: minecraft:block/custom/honeydew
|
||||
particle_texture: minecraft:block/custom/honeydew
|
||||
down_texture: minecraft:block/custom/honeydew_bottom
|
||||
up_texture: minecraft:block/custom/honeydew_top
|
||||
north_texture: minecraft:block/custom/honeydew
|
||||
east_texture: minecraft:block/custom/honeydew
|
||||
south_texture: minecraft:block/custom/honeydew
|
||||
west_texture: minecraft:block/custom/honeydew
|
||||
default:honeydew_stem:
|
||||
loot:
|
||||
pools:
|
||||
- rolls: 1
|
||||
entries:
|
||||
- type: item
|
||||
item: default:honeydew_item
|
||||
functions:
|
||||
- type: set_count
|
||||
add: false
|
||||
conditions:
|
||||
- type: match_block_property
|
||||
properties:
|
||||
age: 0
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.06666667
|
||||
- type: set_count
|
||||
add: false
|
||||
conditions:
|
||||
- type: match_block_property
|
||||
properties:
|
||||
age: 1
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.13333334
|
||||
- type: set_count
|
||||
add: false
|
||||
conditions:
|
||||
- type: match_block_property
|
||||
properties:
|
||||
age: 2
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.2
|
||||
- type: set_count
|
||||
add: false
|
||||
conditions:
|
||||
- type: match_block_property
|
||||
properties:
|
||||
age: 3
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.26666668
|
||||
- type: set_count
|
||||
add: false
|
||||
conditions:
|
||||
- type: match_block_property
|
||||
properties:
|
||||
age: 4
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.33333334
|
||||
- type: set_count
|
||||
add: false
|
||||
conditions:
|
||||
- type: match_block_property
|
||||
properties:
|
||||
age: 5
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.4
|
||||
- type: set_count
|
||||
add: false
|
||||
conditions:
|
||||
- type: match_block_property
|
||||
properties:
|
||||
age: 6
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.46666667
|
||||
- type: set_count
|
||||
add: false
|
||||
conditions:
|
||||
- type: match_block_property
|
||||
properties:
|
||||
age: 7
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.53333336
|
||||
functions:
|
||||
- type: explosion_decay
|
||||
settings:
|
||||
map-color: 7
|
||||
hardness: 0
|
||||
resistance: 0
|
||||
push-reaction: DESTROY
|
||||
is-suffocating: false
|
||||
is-redstone-conductor: false
|
||||
item: default:honeydew_item
|
||||
is-randomly-ticking: true
|
||||
tags:
|
||||
- minecraft:bee_growables
|
||||
- minecraft:crops
|
||||
- minecraft:maintains_farmland
|
||||
behaviors:
|
||||
type: stem_block
|
||||
fruit: default:honeydew
|
||||
attached-stem: default:attached_honeydew_stem
|
||||
blacklist: false
|
||||
bottom-blocks:
|
||||
- minecraft:farmland
|
||||
states:
|
||||
properties:
|
||||
age:
|
||||
type: int
|
||||
default: 0
|
||||
range: 0~7
|
||||
appearances:
|
||||
age=0:
|
||||
state: pumpkin_stem[age=0]
|
||||
age=1:
|
||||
state: pumpkin_stem[age=1]
|
||||
age=2:
|
||||
state: pumpkin_stem[age=2]
|
||||
age=3:
|
||||
state: pumpkin_stem[age=3]
|
||||
age=4:
|
||||
state: pumpkin_stem[age=4]
|
||||
age=5:
|
||||
state: pumpkin_stem[age=5]
|
||||
age=6:
|
||||
state: pumpkin_stem[age=6]
|
||||
age=7:
|
||||
state: pumpkin_stem[age=7]
|
||||
variants:
|
||||
age=0:
|
||||
appearance: age=0
|
||||
id: 0
|
||||
age=1:
|
||||
appearance: age=1
|
||||
id: 1
|
||||
age=2:
|
||||
appearance: age=2
|
||||
id: 2
|
||||
age=3:
|
||||
appearance: age=3
|
||||
id: 3
|
||||
age=4:
|
||||
appearance: age=4
|
||||
id: 4
|
||||
age=5:
|
||||
appearance: age=5
|
||||
id: 5
|
||||
age=6:
|
||||
appearance: age=6
|
||||
id: 6
|
||||
age=7:
|
||||
appearance: age=7
|
||||
id: 7
|
||||
default:attached_honeydew_stem:
|
||||
loot:
|
||||
pools:
|
||||
- rolls: 1
|
||||
entries:
|
||||
- type: item
|
||||
item: default:honeydew_item
|
||||
functions:
|
||||
- type: set_count
|
||||
add: false
|
||||
count:
|
||||
type: binomial
|
||||
extra: 3
|
||||
probability: 0.53333336
|
||||
functions:
|
||||
- type: explosion_decay
|
||||
settings:
|
||||
map-color: 7
|
||||
hardness: 0
|
||||
resistance: 0
|
||||
push-reaction: DESTROY
|
||||
is-suffocating: false
|
||||
is-redstone-conductor: false
|
||||
item: default:honeydew_item
|
||||
is-randomly-ticking: true
|
||||
tags:
|
||||
- minecraft:maintains_farmland
|
||||
behaviors:
|
||||
type: attached_stem_block
|
||||
fruit: default:honeydew
|
||||
stem: default:honeydew_stem
|
||||
blacklist: false
|
||||
bottom-blocks:
|
||||
- minecraft:farmland
|
||||
states:
|
||||
properties:
|
||||
facing:
|
||||
type: horizontal_direction
|
||||
default: north
|
||||
appearances:
|
||||
facing=east:
|
||||
state: attached_pumpkin_stem[facing=east]
|
||||
facing=south:
|
||||
state: attached_pumpkin_stem[facing=south]
|
||||
facing=west:
|
||||
state: attached_pumpkin_stem[facing=west]
|
||||
facing=north:
|
||||
state: attached_pumpkin_stem[facing=north]
|
||||
variants:
|
||||
facing=east:
|
||||
appearance: facing=east
|
||||
id: 0
|
||||
facing=south:
|
||||
appearance: facing=south
|
||||
id: 1
|
||||
facing=west:
|
||||
appearance: facing=west
|
||||
id: 2
|
||||
facing=north:
|
||||
appearance: facing=north
|
||||
id: 3
|
||||
@@ -78,4 +78,6 @@ categories:
|
||||
- default:bench
|
||||
- default:wooden_chair
|
||||
- default:flower_basket
|
||||
- default:amethyst_torch
|
||||
- default:amethyst_torch
|
||||
- default:honeydew_item
|
||||
- default:honeydew
|
||||
@@ -49,6 +49,8 @@ i18n:
|
||||
item.safe_block: Safe Block
|
||||
item.sofa: Sofa
|
||||
item.amethyst_torch: Amethyst Torch
|
||||
item.honeydew_item: Honeydew Slice
|
||||
item.honeydew: Honeydew
|
||||
category.default.name: Default Assets
|
||||
category.default.lore: Contains the default configuration of CraftEngine
|
||||
category.palm_tree: Palm Tree
|
||||
@@ -107,6 +109,8 @@ i18n:
|
||||
item.safe_block: 保险柜
|
||||
item.sofa: 沙发
|
||||
item.amethyst_torch: 紫水晶火把
|
||||
item.honeydew_item: 哈密瓜片
|
||||
item.honeydew: 哈密瓜
|
||||
category.default.name: 默认资产
|
||||
category.default.lore: 包含了CraftEngine的默认配置
|
||||
category.palm_tree: 棕榈树
|
||||
@@ -149,6 +153,9 @@ lang:
|
||||
block_name:default:sofa: Sofa
|
||||
block_name:default:amethyst_torch: Amethyst Torch
|
||||
block_name:default:amethyst_wall_torch: Amethyst Torch
|
||||
block_name:default:honeydew: Honeydew
|
||||
block_name:default:honeydew_stem: Honeydew Stem
|
||||
block_name:default:default:attached_honeydew_stem: Honeydew Stem
|
||||
zh_cn:
|
||||
block_name:default:chinese_lantern: 灯笼
|
||||
block_name:default:netherite_anvil: 下界合金砧
|
||||
@@ -178,4 +185,7 @@ lang:
|
||||
block_name:default:sleeper_sofa: 沙发
|
||||
block_name:default:sofa: 沙发
|
||||
block_name:default:amethyst_torch: 紫水晶火把
|
||||
block_name:default:amethyst_wall_torch: 紫水晶火把
|
||||
block_name:default:amethyst_wall_torch: 紫水晶火把
|
||||
block_name:default:honeydew: 哈密瓜
|
||||
block_name:default:honeydew_stem: 哈密瓜茎
|
||||
block_name:default:default:attached_honeydew_stem: 哈密瓜茎
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 463 B |
Binary file not shown.
|
After Width: | Height: | Size: 420 B |
Binary file not shown.
|
After Width: | Height: | Size: 493 B |
Binary file not shown.
|
After Width: | Height: | Size: 377 B |
@@ -87,6 +87,8 @@ warning.config.number.uniform.missing_min: "<yellow>Issue found in file <arg:0>
|
||||
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.number.gaussian.missing_min: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'min' argument for 'gaussian' number.</yellow>"
|
||||
warning.config.number.gaussian.missing_max: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'max' argument for 'gaussian' number.</yellow>"
|
||||
warning.config.number.binomial.missing_extra: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'extra' argument for 'binomial' number.</yellow>"
|
||||
warning.config.number.binomial.missing_probability: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'probability' argument for 'binomial' 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>"
|
||||
|
||||
@@ -87,6 +87,8 @@ warning.config.number.uniform.missing_min: "<yellow>在文件 <arg:0> 发现问
|
||||
warning.config.number.uniform.missing_max: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'uniform' 数字类型所需的 'max' 参数</yellow>"
|
||||
warning.config.number.gaussian.missing_min: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'gaussian' 数字类型所需的 'min' 参数</yellow>"
|
||||
warning.config.number.gaussian.missing_max: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'gaussian' 数字类型所需的 'max' 参数</yellow>"
|
||||
warning.config.number.binomial.missing_extra: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'binomial' 数字类型所需的 'extra' 参数</yellow>"
|
||||
warning.config.number.binomial.missing_probability: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 缺少 'binomial' 数字类型所需的 'probability' 参数</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>"
|
||||
|
||||
@@ -431,6 +431,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
plugin.saveResource("resources/default/configuration/blocks/topaz_ore.yml");
|
||||
plugin.saveResource("resources/default/configuration/blocks/netherite_anvil.yml");
|
||||
plugin.saveResource("resources/default/configuration/blocks/amethyst_torch.yml");
|
||||
plugin.saveResource("resources/default/configuration/blocks/honeydew.yml");
|
||||
// assets
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/font/image/emojis.png");
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/block/custom/chinese_lantern.png");
|
||||
@@ -537,6 +538,10 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/gui/sprites/tooltip/topaz_background.png.mcmeta");
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/gui/sprites/tooltip/topaz_frame.png");
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/gui/sprites/tooltip/topaz_frame.png.mcmeta");
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew.png");
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew_bottom.png");
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew_top.png");
|
||||
plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/item/custom/honeydew_item.png");
|
||||
}
|
||||
|
||||
private TreeMap<ConfigParser, List<CachedConfigSection>> updateCachedConfigFiles() {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package net.momirealms.craftengine.core.plugin.context.number;
|
||||
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.RandomUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public record BinomialNumberProvider(NumberProvider trials, NumberProvider successProbability) implements NumberProvider {
|
||||
public static final Factory FACTORY = new Factory();
|
||||
|
||||
@Override
|
||||
public float getFloat(Context context) {
|
||||
return getInt(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(Context context) {
|
||||
return getInt(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(Context context) {
|
||||
int trialCount = this.trials.getInt(context);
|
||||
float probability = this.successProbability.getFloat(context);
|
||||
int successCount = 0;
|
||||
|
||||
for (int i = 0; i < trialCount; i++) {
|
||||
if (RandomUtils.generateRandomFloat(0, 1) < probability) {
|
||||
successCount++;
|
||||
}
|
||||
}
|
||||
return successCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return NumberProviders.BINOMIAL;
|
||||
}
|
||||
|
||||
public static class Factory implements NumberProviderFactory {
|
||||
|
||||
@Override
|
||||
public NumberProvider create(Map<String, Object> arguments) {
|
||||
Object trials = ResourceConfigUtils.requireNonNullOrThrow(arguments.get("extra"), "warning.config.number.binomial.missing_extra");
|
||||
Object successProbability = ResourceConfigUtils.requireNonNullOrThrow(arguments.get("probability"), "warning.config.number.binomial.missing_probability");
|
||||
return new BinomialNumberProvider(NumberProviders.fromObject(trials), NumberProviders.fromObject(successProbability));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class NumberProviders {
|
||||
public static final Key UNIFORM = Key.of("craftengine:uniform");
|
||||
public static final Key EXPRESSION = Key.of("craftengine:expression");
|
||||
public static final Key GAUSSIAN = Key.of("craftengine:gaussian");
|
||||
public static final Key BINOMIAL = Key.of("craftengine:binomial");
|
||||
|
||||
static {
|
||||
register(FIXED, FixedNumberProvider.FACTORY);
|
||||
@@ -25,6 +26,7 @@ public class NumberProviders {
|
||||
register(UNIFORM, UniformNumberProvider.FACTORY);
|
||||
register(GAUSSIAN, GaussianNumberProvider.FACTORY);
|
||||
register(EXPRESSION, ExpressionNumberProvider.FACTORY);
|
||||
register(BINOMIAL, BinomialNumberProvider.FACTORY);
|
||||
}
|
||||
|
||||
public static void register(Key key, NumberProviderFactory factory) {
|
||||
|
||||
Reference in New Issue
Block a user