From ea100a992d13d4d84f9c04e00119623e7a78c40f Mon Sep 17 00:00:00 2001 From: jhqwqmc Date: Tue, 23 Sep 2025 13:05:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(block):=20=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=92=8C=E4=B8=80=E4=B8=AA=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E9=9A=8F=E6=9C=BA=E6=95=B0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/configuration/blocks/honeydew.yml | 294 ++++++++++++++++++ .../default/configuration/categories.yml | 4 +- .../resources/default/configuration/i18n.yml | 12 +- .../textures/block/custom/honeydew.png | Bin 0 -> 463 bytes .../textures/block/custom/honeydew_bottom.png | Bin 0 -> 420 bytes .../textures/block/custom/honeydew_top.png | Bin 0 -> 493 bytes .../textures/item/custom/honeydew_item.png | Bin 0 -> 377 bytes .../src/main/resources/translations/en.yml | 2 + .../src/main/resources/translations/zh_cn.yml | 2 + .../core/pack/AbstractPackManager.java | 5 + .../number/BinomialNumberProvider.java | 51 +++ .../context/number/NumberProviders.java | 2 + 12 files changed, 370 insertions(+), 2 deletions(-) create mode 100644 common-files/src/main/resources/resources/default/configuration/blocks/honeydew.yml create mode 100644 common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew.png create mode 100644 common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew_bottom.png create mode 100644 common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew_top.png create mode 100644 common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/item/custom/honeydew_item.png create mode 100644 core/src/main/java/net/momirealms/craftengine/core/plugin/context/number/BinomialNumberProvider.java diff --git a/common-files/src/main/resources/resources/default/configuration/blocks/honeydew.yml b/common-files/src/main/resources/resources/default/configuration/blocks/honeydew.yml new file mode 100644 index 000000000..12d8f5598 --- /dev/null +++ b/common-files/src/main/resources/resources/default/configuration/blocks/honeydew.yml @@ -0,0 +1,294 @@ +items: + default:honeydew_item: + material: apple + data: + item-name: + 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: + 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 diff --git a/common-files/src/main/resources/resources/default/configuration/categories.yml b/common-files/src/main/resources/resources/default/configuration/categories.yml index 55610a412..6f02cfd78 100644 --- a/common-files/src/main/resources/resources/default/configuration/categories.yml +++ b/common-files/src/main/resources/resources/default/configuration/categories.yml @@ -78,4 +78,6 @@ categories: - default:bench - default:wooden_chair - default:flower_basket - - default:amethyst_torch \ No newline at end of file + - default:amethyst_torch + - default:honeydew_item + - default:honeydew \ No newline at end of file diff --git a/common-files/src/main/resources/resources/default/configuration/i18n.yml b/common-files/src/main/resources/resources/default/configuration/i18n.yml index fa91ebbb0..fbd75318d 100644 --- a/common-files/src/main/resources/resources/default/configuration/i18n.yml +++ b/common-files/src/main/resources/resources/default/configuration/i18n.yml @@ -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: 紫水晶火把 \ No newline at end of file + block_name:default:amethyst_wall_torch: 紫水晶火把 + block_name:default:honeydew: 哈密瓜 + block_name:default:honeydew_stem: 哈密瓜茎 + block_name:default:default:attached_honeydew_stem: 哈密瓜茎 \ No newline at end of file diff --git a/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew.png b/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew.png new file mode 100644 index 0000000000000000000000000000000000000000..df74b134bb10be3dbd46afc1bf2d9c71129a8fc8 GIT binary patch literal 463 zcmV;=0WkiFP)Px$iAh93R49>6k-=(%KoEw1MJU0NV_kYE;=xN1qz@3tNuMRqLLfdx0);+EPd&s_ zArBA&O9*&KB!sZ`C|$%$?BTbIdm5dY@Be4Udi_kYI9RJH6&`?L03a3KFpx?+k#O<< znCr%)yeOs8CMA^y2&x?Nq|#CyvpDF+qyGvdq2B>1JfJdAo7BbRne5eOpBLp~@*D}* zs++thjmd62l1e+2OU6Dcj0o{iz568eso-#+4oE^Db+c9#6q3+iZT69H&Cmeyq6A=5 zi|S0I!lNr=Ln>|64MiL}F_^w+r-3pFeNwnCt8OCU+FXd)G%+;8NruLx(l&ths@W!$ zUTyYP-LN7rN~>;$*92f^abV0u!p-7fxjPQ-g;aQ{@Rqw{d)1L}`#Z3XU?QZ_3`}XS zAeFv*bla;wU0QlutE#=~w+D}I0et*a)7yPNgYoeG@-%evZU6Fr76+$G%eE{IY~y&o zJu`TF@aEg|^mb2?+1J6aW?u)J-R7Ck`S$$rQw>>6{Q*}Z5xyxv;}ZY?002ovPDHLk FV1g!V(KrAA literal 0 HcmV?d00001 diff --git a/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew_bottom.png b/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/block/custom/honeydew_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..a21c39cec5bfbd841da2aecdb77dc0b23131c39a GIT binary patch literal 420 zcmV;V0bBlwP)Px$UP(kjR5*=YQa^8kKoozOE_LR{2rX^4x! zGhqfI=qwwhhrt>g_Z$6P*b=8_O+*zu(6Uj1XL1j7r@qAFBDX>7r_akJa@>_kU%x*e zwgu?!tWsa@&T4m7+r=y{>bGZk%YfFT>M)j(EfE^@Svbc?Q2F<3jBH6&hnWCJM45fF zgs2Zo2jjXNTLPx$r%6OXR49>MQcX+4KoFg@sUb85^pZVjiKPvcQYginQ1FzTyn3r=1rLJ#6&CtW zM8rdS?LiPk3ZV$4AE8v(2vxC-QU&AT*==x7vokyIy?Hy*>7`v_X@?mu4~Qrp5RuD+ zcyQ4fChFxZ9>ohD5C8S!lvp|uzoRG8)e=kFmKo_PssheohAc25U2U|x=hb4X=i8Rq z>iI;3z_!eY2pJiDk*;9wZBgnf^Q+Oy91$Pqm7bPbrPN z-rmM~PSa-eh347fqgJszJF;}GLf!= z`Mg>L)=Cn9@$0C$Jn(oZjF#R%T^`8sv50(F3>o!umMDmSi^GiNKMFfdBPXnu!~SF^3x}D(^vz*Le;(#j%8b4YZSCLkKF_~z`Rh?`JEv(f jw2Ji-D;Ph5(Bt7Rur?NdAIn!}00000NkvXXu0mjfg*Mxx literal 0 HcmV?d00001 diff --git a/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/item/custom/honeydew_item.png b/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/item/custom/honeydew_item.png new file mode 100644 index 0000000000000000000000000000000000000000..5c46ede57f362cf847e055b5a49d59ae749c495a GIT binary patch literal 377 zcmV-<0fzpGP)Px$Gf6~2R5*>jlD$g9P#A`vRz)O%h}2GLJ?dhMAYGhX70D{N7O{g{K@hx#fL=kb zp!5oyow^j46cM2shhjjIK}1qH4&{U#Oeli*ZQuFM^S#KK!DTs zI-wWPGb^&+^$Rlv6nJq}2jK1bL!0Lcq#XeUogr%ng3t?Q3%HJuNBbtr^;Mp3MgTNg zwZuJoc~ABh^AeF5^o+|;7wm(sF9U;|Qt5R_De){oV zZyz;xEkV!xB6^59Uz{Yv>rXX~GhrIssue found in file warning.config.number.uniform.missing_max: "Issue found in file - The config '' is missing the required 'max' argument for 'uniform' number." warning.config.number.gaussian.missing_min: "Issue found in file - The config '' is missing the required 'min' argument for 'gaussian' number." warning.config.number.gaussian.missing_max: "Issue found in file - The config '' is missing the required 'max' argument for 'gaussian' number." +warning.config.number.binomial.missing_extra: "Issue found in file - The config '' is missing the required 'extra' argument for 'binomial' number." +warning.config.number.binomial.missing_probability: "Issue found in file - The config '' is missing the required 'probability' argument for 'binomial' number." warning.config.condition.all_of.missing_terms: "Issue found in file - The config '' is missing the required 'terms' argument for 'all_of' condition." warning.config.condition.all_of.invalid_terms_type: "Issue found in file - The config '' has a misconfigured 'all_of' condition, 'terms' should be a map list, current type: ''." warning.config.condition.any_of.missing_terms: "Issue found in file - The config '' is missing the required 'terms' argument for 'any_of' condition." diff --git a/common-files/src/main/resources/translations/zh_cn.yml b/common-files/src/main/resources/translations/zh_cn.yml index 462138c04..6f5171988 100644 --- a/common-files/src/main/resources/translations/zh_cn.yml +++ b/common-files/src/main/resources/translations/zh_cn.yml @@ -87,6 +87,8 @@ warning.config.number.uniform.missing_min: "在文件 发现问 warning.config.number.uniform.missing_max: "在文件 发现问题 - 配置项 '' 缺少 'uniform' 数字类型所需的 'max' 参数" warning.config.number.gaussian.missing_min: "在文件 发现问题 - 配置项 '' 缺少 'gaussian' 数字类型所需的 'min' 参数" warning.config.number.gaussian.missing_max: "在文件 发现问题 - 配置项 '' 缺少 'gaussian' 数字类型所需的 'max' 参数" +warning.config.number.binomial.missing_extra: "在文件 发现问题 - 配置项 '' 缺少 'binomial' 数字类型所需的 'extra' 参数" +warning.config.number.binomial.missing_probability: "在文件 发现问题 - 配置项 '' 缺少 'binomial' 数字类型所需的 'probability' 参数" warning.config.condition.all_of.missing_terms: "在文件 发现问题 - 配置项 '' 缺少 'all_of' 条件所需的 'terms' 参数" warning.config.condition.all_of.invalid_terms_type: "在文件 发现问题 - 配置项 '' 的 'all_of' 条件配置错误, 'terms' 应为映射列表, 当前类型: ''" warning.config.condition.any_of.missing_terms: "在文件 发现问题 - 配置项 '' 缺少 'any_of' 条件所需的 'terms' 参数" diff --git a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java index 62898220f..b3eafb708 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java +++ b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java @@ -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> updateCachedConfigFiles() { diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/number/BinomialNumberProvider.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/number/BinomialNumberProvider.java new file mode 100644 index 000000000..3d2306df8 --- /dev/null +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/number/BinomialNumberProvider.java @@ -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 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)); + } + } +} diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/number/NumberProviders.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/number/NumberProviders.java index 49ce77b1a..0b46ffb92 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/number/NumberProviders.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/number/NumberProviders.java @@ -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) {