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

简化简单纹理模型

This commit is contained in:
XiaoMoMi
2025-11-11 16:11:18 +08:00
parent 45a7452484
commit 671d49203f
37 changed files with 1456 additions and 1332 deletions

View File

@@ -3,13 +3,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.amethyst_torch> item-name: <!i><l10n:item.amethyst_torch>
model: texture: minecraft:block/custom/amethyst_torch
type: minecraft:model
path: minecraft:item/custom/amethyst_torch
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:block/custom/amethyst_torch
behavior: behavior:
- type: wall_block_item - type: wall_block_item
block: default:amethyst_wall_torch block: default:amethyst_wall_torch

View File

@@ -16,7 +16,6 @@ items:
settings: settings:
template: template:
- default:sound/metal - default:sound/metal
- default:pickaxe_power/level_1
overrides: overrides:
hardness: 3.0 hardness: 3.0
resistance: 4.5 resistance: 4.5
@@ -27,6 +26,8 @@ items:
map-color: 15 map-color: 15
tags: tags:
- minecraft:mineable/pickaxe - minecraft:mineable/pickaxe
correct-tools:
template: default:pickaxe_power/level_1
behavior: behavior:
type: lamp_block type: lamp_block
states: states:

View File

@@ -3,10 +3,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.ender_pearl_flower_seeds> item-name: <!i><l10n:item.ender_pearl_flower_seeds>
model: texture: minecraft:item/custom/ender_pearl_flower_seeds
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/ender_pearl_flower_seeds
behavior: behavior:
type: block_item type: block_item
block: default:ender_pearl_flower block: default:ender_pearl_flower

View File

@@ -3,10 +3,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.fairy_flower> item-name: <!i><l10n:item.fairy_flower>
model: texture: minecraft:item/custom/fairy_flower
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/fairy_flower
behavior: behavior:
type: block_item type: block_item
block: block:

View File

@@ -3,10 +3,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.flame_cane> item-name: <!i><l10n:item.flame_cane>
model: texture: minecraft:item/custom/flame_cane
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/flame_cane
behavior: behavior:
type: block_item type: block_item
block: block:

View File

@@ -51,13 +51,14 @@ items:
settings: settings:
template: template:
- default:sound/stone - default:sound/stone
- default:pickaxe_power/level_1
- default:settings/solid_1x1x1 - default:settings/solid_1x1x1
overrides: overrides:
hardness: 1.8 hardness: 1.8
resistance: 1.8 resistance: 1.8
instrument: basedrum instrument: basedrum
map-color: 45 map-color: 45
correct-tools:
template: default:pickaxe_power/level_1
state: state:
auto-state: solid auto-state: solid
model: model:

View File

@@ -1,6 +1,7 @@
items: items:
default:hami_melon_slice: default:hami_melon_slice:
material: melon_slice material: melon_slice
texture: minecraft:item/custom/hami_melon_slice
data: data:
item-name: <!i><l10n:item.hami_melon_slice> item-name: <!i><l10n:item.hami_melon_slice>
$$>=1.20.5: $$>=1.20.5:
@@ -13,10 +14,6 @@ items:
food: food:
nutrition: 2 nutrition: 2
saturation: 1.0 saturation: 1.0
model:
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/hami_melon_slice
default:hami_melon: default:hami_melon:
material: nether_brick material: nether_brick
data: data:
@@ -32,10 +29,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.hami_melon_seeds> item-name: <!i><l10n:item.hami_melon_seeds>
model: texture: minecraft:item/custom/hami_melon_seeds
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/hami_melon_seeds
behavior: behavior:
type: block_item type: block_item
block: default:hami_melon_stem block: default:hami_melon_stem

View File

@@ -1,10 +1,7 @@
items: items:
default:magma_fruit: default:magma_fruit:
material: carrot material: carrot
model: texture: minecraft:item/custom/magma_fruit
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/magma_fruit
data: data:
item-name: <!i><white><l10n:item.magma_fruit> item-name: <!i><white><l10n:item.magma_fruit>
$$>=1.20.5: $$>=1.20.5:

View File

@@ -30,21 +30,19 @@ items:
- type: expression - type: expression
expression: '!<arg:player.is_sneaking>' expression: '!<arg:player.is_sneaking>'
settings: settings:
template: sounds:
- default:pickaxe_power/level_4 break: minecraft:block.anvil.break
overrides: step: minecraft:block.anvil.step
tags: place: minecraft:block.anvil.place
- minecraft:mineable/pickaxe hit: minecraft:block.anvil.hit
sounds: fall: minecraft:block.anvil.fall
break: minecraft:block.anvil.break map-color: 29
step: minecraft:block.anvil.step hardness: 10.0
place: minecraft:block.anvil.place resistance: 1200
hit: minecraft:block.anvil.hit push-reaction: block
fall: minecraft:block.anvil.fall correct-tools:
map-color: 29 template: default:pickaxe_power/level_4
hardness: 10.0 tags: ["minecraft:mineable/pickaxe"]
resistance: 1200
push-reaction: block
states: states:
properties: properties:
facing_clockwise: facing_clockwise:

View File

@@ -157,11 +157,7 @@ items:
lore: lore:
- "<!i><gray>Requires the datapack tree configuration to function." - "<!i><gray>Requires the datapack tree configuration to function."
- "<!i><gray>If not configured, an oak tree will grow by default." - "<!i><gray>If not configured, an oak tree will grow by default."
model: texture: minecraft:block/custom/palm_sapling
template: default:model/generated
arguments:
model: minecraft:item/custom/palm_sapling
texture: minecraft:block/custom/palm_sapling
behavior: behavior:
type: block_item type: block_item
block: block:
@@ -284,10 +280,7 @@ items:
item-name: <!i><l10n:item.palm_door> item-name: <!i><l10n:item.palm_door>
settings: settings:
fuel-time: 200 fuel-time: 200
model: texture: minecraft:item/custom/palm_door
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/palm_door
behavior: behavior:
type: double_high_block_item type: double_high_block_item
block: block:
@@ -693,15 +686,15 @@ recipes:
default:palm_planks: default:palm_planks:
template: default:recipe/planks template: default:recipe/planks
arguments: arguments:
wood_type: palm wood_type: default:palm
default:palm_wood: default:palm_wood:
template: default:recipe/log_2_wood template: default:recipe/log_2_wood
arguments: arguments:
wood_type: palm wood_type: default:palm
default:stripped_palm_wood: default:stripped_palm_wood:
template: default:recipe/log_2_wood template: default:recipe/log_2_wood
arguments: arguments:
wood_type: stripped_palm wood_type: default:stripped_palm
default:palm_trapdoor: default:palm_trapdoor:
type: shaped type: shaped
pattern: pattern:

View File

@@ -3,10 +3,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.pebble> item-name: <!i><l10n:item.pebble>
model: texture: minecraft:item/custom/pebble
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/pebble
behavior: behavior:
- type: block_item - type: block_item
block: block:

View File

@@ -3,10 +3,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.reed> item-name: <!i><l10n:item.reed>
model: texture: minecraft:item/custom/reed
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/reed
behavior: behavior:
type: liquid_collision_block_item type: liquid_collision_block_item
block: block:

View File

@@ -32,10 +32,7 @@ items:
percent: 0.25 percent: 0.25
data: data:
item-name: <!i><#FF8C00><l10n:item.topaz> item-name: <!i><#FF8C00><l10n:item.topaz>
model: texture: minecraft:item/custom/topaz
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/topaz
blocks: blocks:
default:topaz_ore: default:topaz_ore:
loot: loot:
@@ -75,26 +72,42 @@ blocks:
path: minecraft:block/custom/deepslate_topaz_ore path: minecraft:block/custom/deepslate_topaz_ore
recipes: recipes:
default:topaz_from_smelting_topaz_ore: default:topaz_from_smelting_topaz_ore:
template: default:recipe/smelting_ore type: smelting
arguments: experience: 1.0
exp: 1.0 category: misc
ingredient: default:topaz_ore group: topaz
result: default:topaz time: 200
ingredient: default:topaz_ore
result:
id: default:topaz
count: 1
default:topaz_from_smelting_deepslate_topaz_ore: default:topaz_from_smelting_deepslate_topaz_ore:
template: default:recipe/smelting_ore type: smelting
arguments: experience: 1.0
exp: 1.0 category: misc
ingredient: default:deepslate_topaz_ore group: topaz
result: default:topaz time: 200
ingredient: default:deepslate_topaz_ore
result:
id: default:topaz
count: 1
default:topaz_from_blasting_topaz_ore: default:topaz_from_blasting_topaz_ore:
template: default:recipe/blasting_ore type: blasting
arguments: experience: 1.0
exp: 1.0 category: misc
ingredient: default:topaz_ore group: topaz
result: default:topaz time: 100
ingredient: default:topaz_ore
result:
id: default:topaz
count: 1
default:topaz_from_blasting_deepslate_topaz_ore: default:topaz_from_blasting_deepslate_topaz_ore:
template: default:recipe/blasting_ore type: blasting
arguments: experience: 1.0
exp: 1.0 category: misc
ingredient: default:deepslate_topaz_ore group: topaz
result: default:topaz time: 100
ingredient: default:deepslate_topaz_ore
result:
id: default:topaz
count: 1

View File

@@ -1,6 +1,6 @@
templates: templates:
default:emoji/basic: default:emoji/basic:
content: <hover:show_text:'<l10n:emoji.tip>'><!shadow><white><arg:emoji></white></!shadow></hover> content: <hover:show_text:'<i18n:emoji.tip>'><!shadow><white><arg:emoji></white></!shadow></hover>
emoji: emoji:
default:emoji_smiley: default:emoji_smiley:
template: default:emoji/basic template: default:emoji/basic

View File

@@ -3,10 +3,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.flower_basket> item-name: <!i><l10n:item.flower_basket>
model: texture: minecraft:item/custom/flower_basket_2d
template: default:model/simplified_generated
arguments:
path: minecraft:item/custom/flower_basket_2d
behavior: behavior:
type: furniture_item type: furniture_item
furniture: default:flower_basket furniture: default:flower_basket

View File

@@ -3,9 +3,7 @@ items:
material: nether_brick material: nether_brick
data: data:
item-name: <!i><l10n:item.wooden_chair> item-name: <!i><l10n:item.wooden_chair>
model: model: minecraft:item/custom/wooden_chair
type: minecraft:model
path: minecraft:item/custom/wooden_chair
behavior: behavior:
type: furniture_item type: furniture_item
furniture: furniture:

View File

@@ -53,10 +53,7 @@ items:
item-name: <!i><#FF8C00><l10n:item.topaz_pickaxe> item-name: <!i><#FF8C00><l10n:item.topaz_pickaxe>
tooltip-style: minecraft:topaz tooltip-style: minecraft:topaz
max-damage: 64 max-damage: 64
model: texture: minecraft:item/custom/topaz_pickaxe
template: default:model/simplified_handheld
arguments:
path: minecraft:item/custom/topaz_pickaxe
default:topaz_axe: default:topaz_axe:
material: golden_axe material: golden_axe
settings: settings:
@@ -66,10 +63,7 @@ items:
item-name: <!i><#FF8C00><l10n:item.topaz_axe> item-name: <!i><#FF8C00><l10n:item.topaz_axe>
tooltip-style: minecraft:topaz tooltip-style: minecraft:topaz
max-damage: 64 max-damage: 64
model: texture: minecraft:item/custom/topaz_axe
template: default:model/simplified_handheld
arguments:
path: minecraft:item/custom/topaz_axe
default:topaz_hoe: default:topaz_hoe:
material: golden_hoe material: golden_hoe
settings: settings:
@@ -79,36 +73,25 @@ items:
item-name: <!i><#FF8C00><l10n:item.topaz_hoe> item-name: <!i><#FF8C00><l10n:item.topaz_hoe>
tooltip-style: minecraft:topaz tooltip-style: minecraft:topaz
max-damage: 64 max-damage: 64
model: texture: minecraft:item/custom/topaz_hoe
template: default:model/simplified_handheld
arguments:
path: minecraft:item/custom/topaz_hoe
default:topaz_shovel: default:topaz_shovel:
material: golden_shovel material: golden_shovel
settings: settings:
tags: tags: ["default:topaz_tools"]
- default:topaz_tools
data: data:
item-name: <!i><#FF8C00><l10n:item.topaz_shovel> item-name: <!i><#FF8C00><l10n:item.topaz_shovel>
tooltip-style: minecraft:topaz tooltip-style: minecraft:topaz
max-damage: 64 max-damage: 64
model: texture: minecraft:item/custom/topaz_shovel
template: default:model/simplified_handheld
arguments:
path: minecraft:item/custom/topaz_shovel
default:topaz_sword: default:topaz_sword:
material: golden_sword material: golden_sword
settings: settings:
tags: tags: ["default:topaz_tools"]
- default:topaz_tools
data: data:
item-name: <!i><#FF8C00><l10n:item.topaz_sword> item-name: <!i><#FF8C00><l10n:item.topaz_sword>
tooltip-style: minecraft:topaz tooltip-style: minecraft:topaz
max-damage: 64 max-damage: 64
model: texture: minecraft:item/custom/topaz_sword
template: default:model/simplified_handheld
arguments:
path: minecraft:item/custom/topaz_sword
$$>=1.21.4#topaz_trident: $$>=1.21.4#topaz_trident:
default:topaz_trident: default:topaz_trident:
material: trident material: trident

View File

@@ -0,0 +1,216 @@
templates#settings:
default:settings/solid_1x1x1:
is-suffocating: true
replaceable: false
is-view-blocking: true
is-redstone-conductor: true
can-occlude: true
default:settings/transparent_1x1x1:
is-suffocating: false
replaceable: false
is-view-blocking: false
is-redstone-conductor: false
can-occlude: false
default:settings/sapling:
burnable: false
template:
- default:hardness/none
- default:sound/grass
overrides:
push-reaction: destroy
is-randomly-ticking: true
tags:
- minecraft:mineable/axe
- minecraft:saplings
- minecraft:sword_efficient
default:settings/leaves:
template:
- default:sound/grass
- default:burn_data/leaves
- default:hardness/leaves
- default:settings/transparent_1x1x1
overrides:
hardness: 0.2
resistance: 0.2
push-reaction: destroy
instrument: harp
tags:
- minecraft:mineable/hoe
- minecraft:sword_efficient
- minecraft:leaves
- minecraft:replaceable_by_trees
default:settings/wood:
template:
- default:sound/wood
- default:burn_data/wood
- default:hardness/wood
overrides:
instrument: bass
tags:
- minecraft:mineable/axe
- minecraft:logs_that_burn
- minecraft:logs
- minecraft:completes_find_tree_tutorial
default:settings/planks:
template:
- default:sound/wood
- default:burn_data/planks
- default:hardness/planks
- default:settings/solid_1x1x1
overrides:
instrument: bass
tags: ["minecraft:mineable/axe"]
default:settings/ore:
template:
- default:sound/stone
- default:settings/solid_1x1x1
overrides:
hardness: 3.0
resistance: 3.0
instrument: basedrum
map-color: 11
tags: ["minecraft:mineable/pickaxe"]
correct-tools::template: default:pickaxe_power/level_${break_power}
default:settings/deepslate_ore:
template:
- default:sound/deepslate
- default:settings/solid_1x1x1
- default:hardness/deepslate
overrides:
hardness: 4.5
resistance: 3.0
instrument: basedrum
map-color: 59
tags: ["minecraft:mineable/pickaxe"]
correct-tools::template: default:pickaxe_power/level_${break_power}
templates#hardness:
default:hardness/none:
hardness: 0
resistance: 0
default:hardness/leaves:
hardness: 0.2
resistance: 0.2
default:hardness/glass:
hardness: 0.3
resistance: 0.3
default:hardness/stone:
hardness: 1.5
resistance: 6.0
default:hardness/deepslate:
hardness: 3.0
resistance: 6.0
default:hardness/obsidian:
hardness: 50.0
resistance: 1200.0
default:hardness/wool:
hardness: 0.8
resistance: 0.8
default:hardness/wood:
hardness: 2.0
resistance: 2.0
default:hardness/planks:
hardness: 2.0
resistance: 3.0
default:hardness/button:
hardness: 0.5
resistance: 0.5
default:hardness/melon:
hardness: 1.0
resistance: 1.0
templates#burn_data:
default:burn_data/leaves:
burnable: true
burn-chance: 30
fire-spread-chance: 60
default:burn_data/wood:
burnable: true
burn-chance: 5
fire-spread-chance: 5
default:burn_data/planks:
burnable: true
burn-chance: 5
fire-spread-chance: 20
default:burn_data/wool:
burnable: true
burn-chance: 30
fire-spread-chance: 60
default:burn_data/vine:
burnable: true
burn-chance: 15
fire-spread-chance: 100
default:burn_data/carpet:
burnable: true
burn-chance: 60
fire-spread-chance: 20
default:burn_data/coal:
burnable: true
burn-chance: 5
fire-spread-chance: 5
default:burn_data/grass:
burnable: true
burn-chance: 60
fire-spread-chance: 100
templates#sounds:
default:sound/block_template:
sounds:
break: minecraft:block.${block_type}.break
step: minecraft:block.${block_type}.step
place: minecraft:block.${block_type}.place
hit: minecraft:block.${block_type}.hit
fall: minecraft:block.${block_type}.fall
default:sound/crop:
sounds:
break: minecraft:block.crop.break
step: minecraft:block.grass.step
place: minecraft:item.crop.plant
hit: minecraft:block.grass.hit
fall: minecraft:block.grass.fall
default:sound/stem_crop:
sounds:
break: minecraft:block.crop.break
step: minecraft:block.wood.step
place: minecraft:item.crop.plant
hit: minecraft:block.wood.hit
fall: minecraft:block.wood.fall
default:sound/grass:
template: default:sound/block_template
arguments::block_type: grass
default:sound/wood:
template: default:sound/block_template
arguments::block_type: wood
default:sound/stone:
template: default:sound/block_template
arguments::block_type: stone
default:sound/deepslate:
template: default:sound/block_template
arguments::block_type: deepslate
default:sound/glass:
template: default:sound/block_template
arguments::block_type: glass
default:sound/sand:
template: default:sound/block_template
arguments::block_type: sand
default:sound/gravel:
template: default:sound/block_template
arguments::block_type: gravel
default:sound/metal:
template: default:sound/block_template
arguments::block_type: metal
default:sound/snow:
template: default:sound/block_template
arguments::block_type: snow
default:sound/bamboo:
template: default:sound/block_template
arguments::block_type: bamboo
default:sound/vine:
template: default:sound/block_template
arguments::block_type: vine
default:sound/lantern:
template: default:sound/block_template
arguments::block_type: lantern
default:sound/amethyst_block:
template: default:sound/block_template
arguments::block_type: amethyst_block

View File

@@ -0,0 +1,270 @@
templates:
# Drop itself.
# Suitable for the vast majority of loot items.
# Only requires the template ID to be filled in during use, with no parameter requirements.
# template: default:loot_table/self
default:loot_table/self:
pools:
- rolls: 1
conditions:
- type: survives_explosion
entries:
- type: item
item: ${__NAMESPACE__}:${__ID__}
# Drop the original furniture item or a fallback item.
# template: default:loot_table/furniture
# arguments:
# item: the fallback item
default:loot_table/furniture:
pools:
- rolls: 1
entries:
- type: furniture_item
item: ${item}
# Drop one or more items.
# template: default:loot_table/basic
# arguments:
# item: the item
# count: the amount of the item
default:loot_table/basic:
pools:
- rolls: 1
conditions:
- type: survives_explosion
entries:
- type: item
item: ${item}
functions:
- type: set_count
add: false
count: ${count:-1}
# Drop the door.
# Since a door consists of two blocks, if both of them have drop items, it will cause duplication.
# template: default:loot_table/door
default:loot_table/door:
pools:
- rolls: 1
entries:
- type: item
item: ${__NAMESPACE__}:${__ID__}
conditions:
- type: match_block_property
properties:
half: lower
# Drop with silk touch
# This template is used for loot that only drops when harvested with Silk Touch.
# template: default:loot_table/silk_touch
# arguments:
# item: the item
# count: the amount of the item
default:loot_table/silk_touch:
pools:
- rolls: 1
conditions:
- type: enchantment
predicate: minecraft:silk_touch>=1
entries:
- type: item
item: ${item}
functions:
- type: set_count
add: false
count: ${count:-1}
# Drop slabs
# When two slabs are stacked, the loot table should be set to drop two items.
# template: default:loot_table/slab
default:loot_table/slab:
pools:
- rolls: 1
entries:
- type: item
item: ${__NAMESPACE__}:${__ID__}
functions:
- type: set_count
count: 2
add: false
conditions:
- type: match_block_property
properties:
type: double
- type: explosion_decay
# This loot table is for crops that are grown from seeds. Example: wheat.
# template: default:loot_table/seed_crop
# arguments:
# crop_item: the mature crop item
# crop_item_count: quantity of mature crop items
# crop_seed: the seed item of the crop
# extra_seed_count: additional seeds dropped when crop reaches maturity
# ripe_age: the max age
default:loot_table/seed_crop:
pools:
- rolls: 1
entries:
- type: alternatives
children:
- type: item
item: ${crop_item}
conditions:
- type: match_block_property
properties:
age: ${ripe_age}
functions:
- type: set_count
add: false
count: ${crop_item_count:-1}
- type: item
item: ${crop_seed}
- rolls: 1
conditions:
- type: match_block_property
properties:
age: ${ripe_age}
entries:
- type: item
item: ${crop_seed}
functions:
- type: apply_bonus
enchantment: minecraft:fortune
formula:
type: binomial_with_bonus_count
extra: ${extra_seed_count:-3}
probability: 0.5714286
# This loot table is for crops that are grown from themselves. Example: carrots.
# template: default:loot_table/crop
# arguments:
# crop_item: the crop item
# extra_crop_count: additional crops dropped when crop reaches maturity
# ripe_age: the max age
default:loot_table/crop:
pools:
- rolls: 1
entries:
- type: item
item: ${crop_item}
- rolls: 1
conditions:
- type: match_block_property
properties:
age: ${ripe_age}
entries:
- type: item
item: ${crop_item}
functions:
- type: apply_bonus
enchantment: minecraft:fortune
formula:
type: binomial_with_bonus_count
extra: ${extra_crop_count:-3}
probability: 0.5714286
# When Silk Touch is used, it drops the ore block itself. When Fortune is used, it increases the drops of the materials.
# template: default:loot_table/ore
# arguments:
# ore_block: the ore block
# ore_drop: the drops of the ore
# ore_drop_count: the amount of the ore materials
# exp: the exp to drop
default:loot_table/ore:
pools:
- rolls: 1
entries:
- type: alternatives
children:
- type: item
item: ${ore_block}
conditions:
- type: enchantment
predicate: minecraft:silk_touch>=1
- type: item
item: ${ore_drop}
functions:
- type: set_count
count: ${ore_drop_count:-1}
add: false
- type: apply_bonus
enchantment: minecraft:fortune
formula:
type: ore_drops
- type: explosion_decay
- type: drop_exp
count: ${exp:-2~4}
# Using Silk Touch or shears will cause the leaves block itself to drop.
# Using Fortune, however, increases the drop rates of sticks and saplings.
# template: default:loot_table/leaves
# arguments:
# leaves: the leaves block
# sapling: the sapling item
default:loot_table/leaves:
pools:
- rolls: 1
entries:
- type: alternatives
children:
- type: item
item: ${leaves}
conditions:
- type: any_of
terms:
- type: match_item
id: minecraft:shears
- type: enchantment
predicate: minecraft:silk_touch>=1
- type: item
item: ${sapling}
conditions:
- type: survives_explosion
- type: table_bonus
enchantment: minecraft:fortune
chances:
- 0.05
- 0.0625
- 0.083333333
- 0.1
- rolls: 1
conditions:
- type: inverted
term:
type: any_of
terms:
- type: match_item
id: minecraft:shears
- type: enchantment
predicate: minecraft:silk_touch>=1
entries:
- type: item
item: minecraft:stick
conditions:
- type: table_bonus
enchantment: minecraft:fortune
chances:
- 0.02
- 0.022222222
- 0.025
- 0.033333333
- 0.1
functions:
- type: set_count
count:
type: uniform
min: 1
max: 2
- type: explosion_decay

View File

@@ -0,0 +1,559 @@
# blocks
templates#models#block:
# template: default:model/cube_all
# arguments:
# model: model_path
# texture: texture_path
default:model/cube_all:
path: ${model}
generation:
parent: minecraft:block/cube_all
textures:
all: ${texture}
# template: default:model/simplified_cube_all
# arguments:
# path: [model/texture]_path
default:model/simplified_cube_all:
path: ${path}
generation:
parent: minecraft:block/cube_all
textures:
all: ${path}
# template: default:model/cube_column
# arguments:
# model: model_path
# end_texture: end_texture_path
# side_texture: side_texture_path
default:model/cube_column:
path: ${model}
generation:
parent: minecraft:block/cube_column
textures:
end: ${end_texture}
side: ${side_texture}
# template: default:model/cube
# arguments:
# model: model_path
# particle_texture: particle_texture_path
# down_texture: down_texture_path
# up_texture: up_texture_path
# north_texture: north_texture_path
# east_texture: east_texture_path
# south_texture: south_texture_path
# west_texture: west_texture_path
default:model/cube:
path: ${model}
generation:
parent: minecraft:block/cube_column
textures:
particle: ${particle_texture}
down: ${down_texture}
up: ${up_texture}
north: ${north_texture}
east: ${east_texture}
south: ${south_texture}
west: ${west_texture}
# 2D items
templates#models#2d:
# template: default:model/generated
# arguments:
# model: model_path
# texture: texture_path
default:model/generated:
type: minecraft:model
path: ${model}
generation:
parent: minecraft:item/generated
textures:
layer0: ${texture}
# template: default:model/simplified_generated
# arguments:
# path: [model/texture]_path
default:model/simplified_generated:
type: minecraft:model
path: ${path}
generation:
parent: minecraft:item/generated
textures:
layer0: ${path}
# template: default:model/2_layer_generated
# arguments:
# model: model_path
# layer0: texture_path
# layer1: texture_path
default:model/2_layer_generated:
type: minecraft:model
path: ${model}
generation:
parent: minecraft:item/generated
textures:
layer0: ${layer0}
layer1: ${layer1}
# template: default:model/handheld
# arguments:
# model: model_path
# texture: texture_path
default:model/handheld:
type: minecraft:model
path: ${model}
generation:
parent: minecraft:item/handheld
textures:
layer0: ${texture}
# template: default:model/simplified_handheld
# arguments:
# path: [model/texture]_path
default:model/simplified_handheld:
type: minecraft:model
path: ${path}
generation:
parent: minecraft:item/handheld
textures:
layer0: ${path}
# template: default:model/elytra
# arguments:
# model: model_path
# broken_model: broken_model_path
# texture: texture_path
# broken_texture: broken_texture_path
default:model/elytra:
type: minecraft:condition
property: minecraft:broken
on-false:
path: ${model}
generation:
parent: minecraft:item/generated
textures:
layer0: ${texture}
on-true:
path: ${broken_model}
generation:
parent: minecraft:item/generated
textures:
layer0: ${broken_texture}
# template: default:model/simplified_elytra
# arguments:
# path: [model/texture]_path
# broken_path: broken_[model/texture]_path
default:model/simplified_elytra:
template: default:model/elytra
arguments:
model: ${path}
texture: ${path}
broken_model: ${broken_path}
broken_texture: ${broken_path}
# template: default:model/armor_trim
# arguments:
# material: armor material type
# part: slot type
default:model/armor_trim:
type: minecraft:select
property: minecraft:trim_material
fallback:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
cases:
- when: minecraft:quartz
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_quartz_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_quartz
- when: minecraft:iron
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_iron_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_iron
- when: minecraft:netherite
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_netherite_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_netherite
- when: minecraft:redstone
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_redstone_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_redstone
- when: minecraft:copper
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_copper_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_copper
- when: minecraft:gold
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_gold_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_gold
- when: minecraft:emerald
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_emerald_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_emerald
- when: minecraft:diamond
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_diamond_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_diamond
- when: minecraft:lapis
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_lapis_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_lapis
- when: minecraft:amethyst
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_amethyst_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_amethyst
- when: minecraft:resin
model:
type: minecraft:model
path: minecraft:item/custom/${material}_${part}_resin_trim
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/${material}_${part}
layer1: minecraft:trims/items/${part}_trim_resin
# shield
templates#models#shield:
# template: default:model/shield_3d
# arguments:
# model: shield_model_path
# block_model: shield_block_model_path
default:model/shield_3d:
type: minecraft:condition
property: minecraft:using_item
on-false:
type: minecraft:model
path: ${model}
on-true:
type: minecraft:model
path: ${block_model}
# fishing rods
templates#models#fishing_rod:
# template: default:model/fishing_rod_3d
# arguments:
# model: rod_model_path
# cast_model: rod_cast_model_path
default:model/fishing_rod_3d:
type: minecraft:condition
property: minecraft:fishing_rod/cast
on-false:
type: minecraft:model
path: ${model}
on-true:
type: minecraft:model
path: ${cast_model}
# template: default:model/fishing_rod_2d
# arguments:
# model: rod_model_path
# cast_model: rod_cast_model_path
# texture: rod_texture_path
# cast_texture: rod_cast_texture_path
default:model/fishing_rod_2d:
type: minecraft:condition
property: minecraft:fishing_rod/cast
on-false:
type: minecraft:model
path: ${model}
generation:
parent: minecraft:item/fishing_rod
textures:
layer0: ${texture}
on-true:
type: minecraft:model
path: ${cast_model}
generation:
parent: minecraft:item/fishing_rod
textures:
layer0: ${cast_texture}
# template: default:model/simplified_fishing_rod_2d
# arguments:
# path: rod_[model/texture]_path
# cast_path: rod_cast_[model/texture]_path
default:model/simplified_fishing_rod_2d:
template: default:model/fishing_rod_2d
arguments:
texture: ${path}
model: ${path}
cast_texture: ${cast_path}
cast_model: ${cast_path}
# bows
templates#models#bow:
# template: default:model/bow_3d
# arguments:
# model: bow_model_path
# pulling_0_model: bow_pulling_0_model_path
# pulling_1_model: bow_pulling_1_model_path
# pulling_2_model: bow_pulling_2_model_path
default:model/bow_3d:
type: minecraft:condition
property: minecraft:using_item
on-false:
type: minecraft:model
path: ${model}
on-true:
type: minecraft:range_dispatch
property: minecraft:use_duration
scale: 0.05
entries:
- model:
type: minecraft:model
path: ${pulling_1_model}
threshold: 0.65
- model:
type: minecraft:model
path: ${pulling_2_model}
threshold: 0.9
fallback:
type: minecraft:model
path: ${pulling_0_model}
# template: default:model/bow_2d
# arguments:
# model: bow_model_path
# pulling_0_model: bow_pulling_0_model_path
# pulling_1_model: bow_pulling_1_model_path
# pulling_2_model: bow_pulling_2_model_path
# texture: bow_texture_path
# pulling_0_texture: bow_pulling_0_texture_path
# pulling_1_texture: bow_pulling_1_texture_path
# pulling_2_texture: bow_pulling_2_texture_path
default:model/bow_2d:
type: minecraft:condition
property: minecraft:using_item
on-false:
type: minecraft:model
path: ${model}
generation:
parent: minecraft:item/bow
textures:
layer0: ${texture}
on-true:
type: minecraft:range_dispatch
property: minecraft:use_duration
scale: 0.05
entries:
- model:
type: minecraft:model
path: ${pulling_1_model}
generation:
parent: minecraft:item/bow_pulling_1
textures:
layer0: ${pulling_1_texture}
threshold: 0.65
- model:
type: minecraft:model
path: ${pulling_2_model}
generation:
parent: minecraft:item/bow_pulling_2
textures:
layer0: ${pulling_2_texture}
threshold: 0.9
fallback:
type: minecraft:model
path: ${pulling_0_model}
generation:
parent: minecraft:item/bow_pulling_0
textures:
layer0: ${pulling_0_texture}
# template: default:model/simplified_bow_2d
# arguments:
# path: bow_[model/texture]_path
# pulling_0_path: bow_pulling_0_[model/texture]_path
# pulling_1_path: bow_pulling_1_[model/texture]_path
# pulling_2_path: bow_pulling_2_[model/texture]_path
default:model/simplified_bow_2d:
template: default:model/bow_2d
arguments:
model: ${path}
pulling_0_model: ${pulling_0_path}
pulling_1_model: ${pulling_1_path}
pulling_2_model: ${pulling_2_path}
texture: ${path}
pulling_0_texture: ${pulling_0_path}
pulling_1_texture: ${pulling_1_path}
pulling_2_texture: ${pulling_2_path}
# crossbows
templates#models#crossbow:
# template: default:model/crossbow_3d
# arguments:
# model: crossbow_model_path
# arrow_model: crossbow_arrow_model_path
# firework_model: crossbow_firework_model_path
# pulling_0_model: crossbow_pulling_0_model_path
# pulling_1_model: crossbow_pulling_1_model_path
# pulling_2_model: crossbow_pulling_2_model_path
default:model/crossbow_3d:
type: minecraft:condition
property: minecraft:using_item
on-false:
type: minecraft:select
property: minecraft:charge_type
cases:
- when: arrow
model:
type: minecraft:model
path: ${arrow_model}
- when: rocket
model:
type: minecraft:model
path: ${firework_model}
fallback:
type: minecraft:model
path: ${model}
on-true:
type: minecraft:range_dispatch
property: minecraft:crossbow/pull
entries:
- model:
type: minecraft:model
path: ${pulling_1_model}
threshold: 0.58
- model:
type: minecraft:model
path: ${pulling_2_model}
threshold: 1.0
fallback:
type: minecraft:model
path: ${pulling_0_model}
# template: default:model/crossbow_2d
# arguments:
# model: crossbow_model_path
# texture: crossbow_texture_path
# arrow_model: crossbow_arrow_model_path
# arrow_texture: crossbow_arrow_texture_path
# firework_model: crossbow_firework_model_path
# firework_texture: crossbow_firework_texture_path
# pulling_0_model: crossbow_pulling_0_model_path
# pulling_0_texture: crossbow_pulling_0_texture_path
# pulling_1_model: crossbow_pulling_1_model_path
# pulling_1_texture: crossbow_pulling_1_texture_path
# pulling_2_model: crossbow_pulling_2_model_path
# pulling_2_texture: crossbow_pulling_2_texture_path
default:model/crossbow_2d:
type: minecraft:condition
property: minecraft:using_item
on-false:
type: minecraft:select
property: minecraft:charge_type
cases:
- when: arrow
model:
type: minecraft:model
path: ${arrow_model}
generation:
parent: minecraft:item/crossbow_arrow
textures:
layer0: ${arrow_texture}
- when: rocket
model:
type: minecraft:model
path: ${firework_model}
generation:
parent: minecraft:item/crossbow_firework
textures:
layer0: ${firework_texture}
fallback:
type: minecraft:model
path: ${model}
generation:
parent: minecraft:item/crossbow
textures:
layer0: ${texture}
on-true:
type: minecraft:range_dispatch
property: minecraft:crossbow/pull
entries:
- model:
type: minecraft:model
path: ${pulling_1_model}
generation:
parent: minecraft:item/crossbow_pulling_1
textures:
layer0: ${pulling_1_texture}
threshold: 0.58
- model:
type: minecraft:model
path: ${pulling_2_model}
generation:
parent: minecraft:item/crossbow_pulling_2
textures:
layer0: ${pulling_2_texture}
threshold: 1.0
fallback:
type: minecraft:model
path: ${pulling_0_model}
generation:
parent: minecraft:item/crossbow_pulling_0
textures:
layer0: ${pulling_0_texture}
# template: default:model/simplified_crossbow_2d
# arguments:
# path: crossbow_[model/texture]_path
# arrow_path: crossbow_arrow_[model/texture]_path
# firework_path: crossbow_firework_[model/texture]_path
# pulling_0_path: crossbow_pulling_0_[model/texture]_path
# pulling_1_path: crossbow_pulling_1_[model/texture]_path
# pulling_2_path: crossbow_pulling_2_[model/texture]_path
default:model/simplified_crossbow_2d:
template: default:model/crossbow_2d
arguments:
model: ${path}
texture: ${path}
arrow_model: ${arrow_path}
arrow_texture: ${arrow_path}
firework_model: ${firework_path}
firework_texture: ${firework_path}
pulling_0_model: ${pulling_0_path}
pulling_0_texture: ${pulling_0_path}
pulling_1_model: ${pulling_1_path}
pulling_1_texture: ${pulling_1_path}
pulling_2_model: ${pulling_2_path}
pulling_2_texture: ${pulling_2_path}

View File

@@ -0,0 +1,28 @@
templates:
# template: default:recipe/planks
# arguments:
# wood_type: the wood type, for instance 'default:palm'
default:recipe/planks:
type: shapeless
category: building
group: planks
ingredients:
- '#${wood_type}_logs'
result:
id: ${wood_type}_planks
count: 4
# template: default:recipe/log_2_wood
# arguments:
# wood_type: the wood type, for instance 'default:palm'
default:recipe/log_2_wood:
type: shaped
category: building
group: bark
pattern:
- AA
- AA
ingredients:
A: ${wood_type}_log
result:
id: ${wood_type}_wood
count: 3

View File

@@ -0,0 +1,25 @@
templates:
default:pickaxe_power/level_1:
- minecraft:wooden_pickaxe
- minecraft:stone_pickaxe
- minecraft:iron_pickaxe
- minecraft:golden_pickaxe
- minecraft:diamond_pickaxe
- minecraft:netherite_pickaxe
- default:topaz_pickaxe
default:pickaxe_power/level_2:
- minecraft:stone_pickaxe
- minecraft:iron_pickaxe
- minecraft:golden_pickaxe
- minecraft:diamond_pickaxe
- minecraft:netherite_pickaxe
- default:topaz_pickaxe
default:pickaxe_power/level_3:
- minecraft:iron_pickaxe
- minecraft:golden_pickaxe
- minecraft:diamond_pickaxe
- minecraft:netherite_pickaxe
- default:topaz_pickaxe
default:pickaxe_power/level_4:
- minecraft:diamond_pickaxe
- minecraft:netherite_pickaxe

View File

@@ -10,16 +10,14 @@ import net.momirealms.craftengine.core.item.updater.ItemUpdateConfig;
import net.momirealms.craftengine.core.item.updater.ItemUpdateResult; import net.momirealms.craftengine.core.item.updater.ItemUpdateResult;
import net.momirealms.craftengine.core.item.updater.ItemUpdater; import net.momirealms.craftengine.core.item.updater.ItemUpdater;
import net.momirealms.craftengine.core.item.updater.ItemUpdaters; import net.momirealms.craftengine.core.item.updater.ItemUpdaters;
import net.momirealms.craftengine.core.pack.AbstractPackManager; import net.momirealms.craftengine.core.pack.*;
import net.momirealms.craftengine.core.pack.LoadingSequence;
import net.momirealms.craftengine.core.pack.Pack;
import net.momirealms.craftengine.core.pack.ResourceLocation;
import net.momirealms.craftengine.core.pack.allocator.IdAllocator; import net.momirealms.craftengine.core.pack.allocator.IdAllocator;
import net.momirealms.craftengine.core.pack.model.*; import net.momirealms.craftengine.core.pack.model.*;
import net.momirealms.craftengine.core.pack.model.generation.AbstractModelGenerator; import net.momirealms.craftengine.core.pack.model.generation.AbstractModelGenerator;
import net.momirealms.craftengine.core.pack.model.generation.ModelGeneration; import net.momirealms.craftengine.core.pack.model.generation.ModelGeneration;
import net.momirealms.craftengine.core.pack.model.select.ChargeTypeSelectProperty; import net.momirealms.craftengine.core.pack.model.select.ChargeTypeSelectProperty;
import net.momirealms.craftengine.core.pack.model.select.TrimMaterialSelectProperty; import net.momirealms.craftengine.core.pack.model.select.TrimMaterialSelectProperty;
import net.momirealms.craftengine.core.pack.model.simplified.SimplifiedModelReader;
import net.momirealms.craftengine.core.plugin.CraftEngine; import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.config.Config; import net.momirealms.craftengine.core.plugin.config.Config;
import net.momirealms.craftengine.core.plugin.config.ConfigParser; import net.momirealms.craftengine.core.plugin.config.ConfigParser;
@@ -518,18 +516,56 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
CustomItem.Builder<I> itemBuilder = createPlatformItemBuilder(uniqueId, material, clientBoundMaterial); CustomItem.Builder<I> itemBuilder = createPlatformItemBuilder(uniqueId, material, clientBoundMaterial);
// 模型配置区域,如果这里被配置了,那么用户必须要配置custom-model-data或item-model // 模型配置区域,如果这里被配置了,那么用户可以配置custom-model-data或item-model
// model可以是一个string也可以是一个区域 // model可以是一个string也可以是一个区域
Object modelSection = section.get("model"); Object modelSection = section.get("model");
Map<String, Object> legacyModelSection = MiscUtils.castToMap(section.get("legacy-model"), true); Map<String, Object> legacyModelSection = MiscUtils.castToMap(section.get("legacy-model"), true);
boolean hasModelSection = modelSection != null || legacyModelSection != null; // model可以是一个map也可以是一个string或list
boolean hasModelSection = modelSection instanceof Map<?,?> || legacyModelSection != null;
if (!hasModelSection) {
Object texture = ResourceConfigUtils.get(section, "textures", "texture");
// 如果使用的是textures那么model指的是
if (texture != null) {
// 获取textures列表
List<String> textures = texture instanceof List<?> ? MiscUtils.getAsStringList(texture) : List.of(texture.toString());
if (!textures.isEmpty()) {
// 获取可选的模型列表此时的model不可能是map了
List<String> modelPath = modelSection != null ? MiscUtils.getAsStringList(modelSection) : List.of();
// 根据父item model选择处理方案
Key templateModel = itemModel != null && AbstractPackManager.PRESET_MODERN_MODELS_ITEM.containsKey(itemModel) ? itemModel : clientBoundMaterial;
SimplifiedModelReader simplifiedModelReader = AbstractPackManager.SIMPLIFIED_MODEL_READERS.get(templateModel);
if (simplifiedModelReader != null) {
modelSection = simplifiedModelReader.convert(textures, modelPath, id);
if (modelSection != null) {
hasModelSection = true;
}
}
}
}
// 如果没有配贴图且model为string或list直接生成相应类型的模型
else if (modelSection != null) {
if (modelSection instanceof String singleModel) {
modelSection = Map.of(
"type", "model",
"path", singleModel
);
hasModelSection = true;
} else if (modelSection instanceof List<?>) {
modelSection = List.of(
"type", "composite",
"models", MiscUtils.getAsStringList(modelSection)
);
hasModelSection = true;
}
}
}
if (customModelData > 0 && (hasModelSection || forceCustomModelData)) { if (customModelData > 0 && (hasModelSection || forceCustomModelData)) {
if (clientBoundModel) itemBuilder.clientBoundDataModifier(new CustomModelDataModifier<>(customModelData)); if (clientBoundModel) itemBuilder.clientBoundDataModifier(new OverwritableCustomModelDataModifier<>(customModelData));
else itemBuilder.dataModifier(new CustomModelDataModifier<>(customModelData)); else itemBuilder.dataModifier(new CustomModelDataModifier<>(customModelData));
} }
if (itemModel != null && (hasModelSection || forceItemModel)) { if (itemModel != null && (hasModelSection || forceItemModel)) {
if (clientBoundModel) itemBuilder.clientBoundDataModifier(new ItemModelModifier<>(itemModel)); if (clientBoundModel) itemBuilder.clientBoundDataModifier(new OverwritableItemModelModifier<>(itemModel));
else itemBuilder.dataModifier(new ItemModelModifier<>(itemModel)); else itemBuilder.dataModifier(new ItemModelModifier<>(itemModel));
} }

View File

@@ -15,6 +15,7 @@ public final class ItemDataModifiers {
private ItemDataModifiers() {} private ItemDataModifiers() {}
public static final Key ITEM_MODEL = Key.of("craftengine:item-model"); public static final Key ITEM_MODEL = Key.of("craftengine:item-model");
public static final Key OVERWRITABLE_ITEM_MODEL = Key.of("craftengine:overwritable-item-model");
public static final Key ID = Key.of("craftengine:id"); public static final Key ID = Key.of("craftengine:id");
public static final Key HIDE_TOOLTIP = Key.of("craftengine:hide-tooltip"); public static final Key HIDE_TOOLTIP = Key.of("craftengine:hide-tooltip");
public static final Key FOOD = Key.of("craftengine:food"); public static final Key FOOD = Key.of("craftengine:food");
@@ -27,6 +28,7 @@ public final class ItemDataModifiers {
public static final Key DISPLAY_NAME = Key.of("craftengine:display-name"); public static final Key DISPLAY_NAME = Key.of("craftengine:display-name");
public static final Key CUSTOM_NAME = Key.of("craftengine:custom-name"); public static final Key CUSTOM_NAME = Key.of("craftengine:custom-name");
public static final Key CUSTOM_MODEL_DATA = Key.of("craftengine:custom-model-data"); public static final Key CUSTOM_MODEL_DATA = Key.of("craftengine:custom-model-data");
public static final Key OVERWRITABLE_CUSTOM_MODEL_DATA = Key.of("craftengine:overwritable-custom-model-data");
public static final Key COMPONENTS = Key.of("craftengine:components"); public static final Key COMPONENTS = Key.of("craftengine:components");
public static final Key COMPONENT = Key.of("craftengine:component"); public static final Key COMPONENT = Key.of("craftengine:component");
public static final Key ATTRIBUTE_MODIFIERS = Key.of("craftengine:attribute-modifiers"); public static final Key ATTRIBUTE_MODIFIERS = Key.of("craftengine:attribute-modifiers");

View File

@@ -0,0 +1,58 @@
package net.momirealms.craftengine.core.item.modifier;
import net.momirealms.craftengine.core.item.DataComponentKeys;
import net.momirealms.craftengine.core.item.Item;
import net.momirealms.craftengine.core.item.ItemBuildContext;
import net.momirealms.craftengine.core.item.ItemDataModifierFactory;
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
import org.jetbrains.annotations.Nullable;
public class OverwritableCustomModelDataModifier<I> implements SimpleNetworkItemDataModifier<I> {
public static final Factory<?> FACTORY = new Factory<>();
private final int argument;
public OverwritableCustomModelDataModifier(int argument) {
this.argument = argument;
}
public int customModelData() {
return this.argument;
}
@Override
public Key type() {
return ItemDataModifiers.OVERWRITABLE_CUSTOM_MODEL_DATA;
}
@Override
public Item<I> apply(Item<I> item, ItemBuildContext context) {
if (item.customModelData().isPresent()) return item;
item.customModelData(this.argument);
return item;
}
@Override
public @Nullable Key componentType(Item<I> item, ItemBuildContext context) {
return DataComponentKeys.CUSTOM_MODEL_DATA;
}
@Override
public @Nullable Object[] nbtPath(Item<I> item, ItemBuildContext context) {
return new Object[]{"CustomModelData"};
}
@Override
public String nbtPathString(Item<I> item, ItemBuildContext context) {
return "CustomModelData";
}
public static class Factory<I> implements ItemDataModifierFactory<I> {
@Override
public ItemDataModifier<I> create(Object arg) {
int customModelData = ResourceConfigUtils.getAsInt(arg, "custom-model-data");
return new OverwritableCustomModelDataModifier<>(customModelData);
}
}
}

View File

@@ -0,0 +1,46 @@
package net.momirealms.craftengine.core.item.modifier;
import net.momirealms.craftengine.core.item.DataComponentKeys;
import net.momirealms.craftengine.core.item.Item;
import net.momirealms.craftengine.core.item.ItemBuildContext;
import net.momirealms.craftengine.core.item.ItemDataModifierFactory;
import net.momirealms.craftengine.core.util.Key;
import org.jetbrains.annotations.Nullable;
public class OverwritableItemModelModifier<I> implements SimpleNetworkItemDataModifier<I> {
public static final Factory<?> FACTORY = new Factory<>();
private final Key data;
public OverwritableItemModelModifier(Key data) {
this.data = data;
}
public Key data() {
return data;
}
@Override
public Key type() {
return ItemDataModifiers.OVERWRITABLE_CUSTOM_MODEL_DATA;
}
@Override
public Item<I> apply(Item<I> item, ItemBuildContext context) {
if (item.hasNonDefaultComponent(DataComponentKeys.ITEM_MODEL)) return item;
return item.itemModel(this.data.asString());
}
@Override
public @Nullable Key componentType(Item<I> item, ItemBuildContext context) {
return DataComponentKeys.ITEM_MODEL;
}
public static class Factory<I> implements ItemDataModifierFactory<I> {
@Override
public ItemDataModifier<I> create(Object arg) {
String id = arg.toString();
return new OverwritableItemModelModifier<>(Key.of(id));
}
}
}

View File

@@ -42,7 +42,7 @@ public class CustomBlastingRecipe<T> extends CustomCookingRecipe<T> {
parseResult(arguments), arguments.containsKey("group") ? arguments.get("group").toString() : null, cookingRecipeCategory(arguments), parseResult(arguments), arguments.containsKey("group") ? arguments.get("group").toString() : null, cookingRecipeCategory(arguments),
singleInputIngredient(arguments), singleInputIngredient(arguments),
ResourceConfigUtils.getAsInt(arguments.getOrDefault("time", 80), "time"), ResourceConfigUtils.getAsInt(arguments.getOrDefault("time", 80), "time"),
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f), "experience") ResourceConfigUtils.getAsFloat(ResourceConfigUtils.get(arguments, "exp", "experience"), "experience")
); );
} }

View File

@@ -42,7 +42,7 @@ public class CustomCampfireRecipe<T> extends CustomCookingRecipe<T> {
parseResult(arguments), arguments.containsKey("group") ? arguments.get("group").toString() : null, cookingRecipeCategory(arguments), parseResult(arguments), arguments.containsKey("group") ? arguments.get("group").toString() : null, cookingRecipeCategory(arguments),
singleInputIngredient(arguments), singleInputIngredient(arguments),
ResourceConfigUtils.getAsInt(arguments.getOrDefault("time", 80), "time"), ResourceConfigUtils.getAsInt(arguments.getOrDefault("time", 80), "time"),
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f), "experience") ResourceConfigUtils.getAsFloat(ResourceConfigUtils.get(arguments, "exp", "experience"), "experience")
); );
} }

View File

@@ -42,7 +42,7 @@ public class CustomSmeltingRecipe<T> extends CustomCookingRecipe<T> {
parseResult(arguments), arguments.containsKey("group") ? arguments.get("group").toString() : null, cookingRecipeCategory(arguments), parseResult(arguments), arguments.containsKey("group") ? arguments.get("group").toString() : null, cookingRecipeCategory(arguments),
singleInputIngredient(arguments), singleInputIngredient(arguments),
ResourceConfigUtils.getAsInt(arguments.getOrDefault("time", 80), "time"), ResourceConfigUtils.getAsInt(arguments.getOrDefault("time", 80), "time"),
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f), "experience") ResourceConfigUtils.getAsFloat(ResourceConfigUtils.get(arguments, "exp", "experience"), "experience")
); );
} }

View File

@@ -42,7 +42,7 @@ public class CustomSmokingRecipe<T> extends CustomCookingRecipe<T> {
parseResult(arguments), arguments.containsKey("group") ? arguments.get("group").toString() : null, cookingRecipeCategory(arguments), parseResult(arguments), arguments.containsKey("group") ? arguments.get("group").toString() : null, cookingRecipeCategory(arguments),
singleInputIngredient(arguments), singleInputIngredient(arguments),
ResourceConfigUtils.getAsInt(arguments.getOrDefault("time", 80), "time"), ResourceConfigUtils.getAsInt(arguments.getOrDefault("time", 80), "time"),
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f), "experience") ResourceConfigUtils.getAsFloat(ResourceConfigUtils.get(arguments, "exp", "experience"), "experience")
); );
} }

View File

@@ -3,12 +3,9 @@ package net.momirealms.craftengine.core.loot.function;
import net.momirealms.craftengine.core.item.Item; import net.momirealms.craftengine.core.item.Item;
import net.momirealms.craftengine.core.item.ItemBuildContext; import net.momirealms.craftengine.core.item.ItemBuildContext;
import net.momirealms.craftengine.core.item.modifier.ItemDataModifier; import net.momirealms.craftengine.core.item.modifier.ItemDataModifier;
import net.momirealms.craftengine.core.item.recipe.result.ApplyItemDataPostProcessor;
import net.momirealms.craftengine.core.loot.LootConditions; import net.momirealms.craftengine.core.loot.LootConditions;
import net.momirealms.craftengine.core.loot.LootContext; import net.momirealms.craftengine.core.loot.LootContext;
import net.momirealms.craftengine.core.plugin.context.Condition; import net.momirealms.craftengine.core.plugin.context.Condition;
import net.momirealms.craftengine.core.plugin.context.number.NumberProvider;
import net.momirealms.craftengine.core.plugin.context.number.NumberProviders;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.ResourceConfigUtils; import net.momirealms.craftengine.core.util.ResourceConfigUtils;

View File

@@ -22,6 +22,9 @@ import net.momirealms.craftengine.core.pack.model.RangeDispatchItemModel;
import net.momirealms.craftengine.core.pack.model.generation.ModelGeneration; import net.momirealms.craftengine.core.pack.model.generation.ModelGeneration;
import net.momirealms.craftengine.core.pack.model.generation.ModelGenerator; import net.momirealms.craftengine.core.pack.model.generation.ModelGenerator;
import net.momirealms.craftengine.core.pack.model.rangedisptach.CustomModelDataRangeDispatchProperty; import net.momirealms.craftengine.core.pack.model.rangedisptach.CustomModelDataRangeDispatchProperty;
import net.momirealms.craftengine.core.pack.model.simplified.GeneratedModelReader;
import net.momirealms.craftengine.core.pack.model.simplified.HandheldModelReader;
import net.momirealms.craftengine.core.pack.model.simplified.SimplifiedModelReader;
import net.momirealms.craftengine.core.pack.revision.Revision; import net.momirealms.craftengine.core.pack.revision.Revision;
import net.momirealms.craftengine.core.pack.revision.Revisions; import net.momirealms.craftengine.core.pack.revision.Revisions;
import net.momirealms.craftengine.core.plugin.CraftEngine; import net.momirealms.craftengine.core.plugin.CraftEngine;
@@ -67,16 +70,28 @@ import static net.momirealms.craftengine.core.util.MiscUtils.castToMap;
@SuppressWarnings("DuplicatedCode") @SuppressWarnings("DuplicatedCode")
public abstract class AbstractPackManager implements PackManager { public abstract class AbstractPackManager implements PackManager {
// 1.21.4+物品模型
public static final Map<Key, JsonObject> PRESET_MODERN_MODELS_ITEM = new HashMap<>(); public static final Map<Key, JsonObject> PRESET_MODERN_MODELS_ITEM = new HashMap<>();
// 旧版本的物品模型
public static final Map<Key, JsonObject> PRESET_LEGACY_MODELS_ITEM = new HashMap<>(); public static final Map<Key, JsonObject> PRESET_LEGACY_MODELS_ITEM = new HashMap<>();
// 全版本的方块模型
public static final Map<Key, JsonObject> PRESET_MODELS_BLOCK = new HashMap<>(); public static final Map<Key, JsonObject> PRESET_MODELS_BLOCK = new HashMap<>();
// 1.21.4+物品模型定义
public static final Map<Key, ModernItemModel> PRESET_ITEMS = new HashMap<>(); public static final Map<Key, ModernItemModel> PRESET_ITEMS = new HashMap<>();
// 原版资产id
public static final Set<Key> VANILLA_TEXTURES = new HashSet<>(); public static final Set<Key> VANILLA_TEXTURES = new HashSet<>();
public static final Set<Key> VANILLA_MODELS = new HashSet<>(); public static final Set<Key> VANILLA_MODELS = new HashSet<>();
public static final Set<Key> VANILLA_SOUNDS = new HashSet<>(); public static final Set<Key> VANILLA_SOUNDS = new HashSet<>();
// 简化的model读取器
public static final Map<Key, SimplifiedModelReader> SIMPLIFIED_MODEL_READERS = new HashMap<>();
public static final String NEW_TRIM_MATERIAL = "custom"; public static final String NEW_TRIM_MATERIAL = "custom";
public static final Set<String> ALLOWED_VANILLA_EQUIPMENT = Set.of("chainmail", "diamond", "gold", "iron", "netherite"); public static final Set<String> ALLOWED_VANILLA_EQUIPMENT = Set.of("chainmail", "diamond", "gold", "iron", "netherite");
public static final Set<String> ALLOWED_MODEL_TAGS = Set.of("parent", "ambientocclusion", "display", "textures", "elements", "gui_light", "overrides"); public static final Set<String> ALLOWED_MODEL_TAGS = Set.of("parent", "ambientocclusion", "display", "textures", "elements", "gui_light", "overrides");
private static final byte[] EMPTY_1X1_IMAGE; private static final byte[] EMPTY_1X1_IMAGE;
private static final byte[] EMPTY_EQUIPMENT_IMAGE; private static final byte[] EMPTY_EQUIPMENT_IMAGE;
private static final byte[] EMPTY_16X16_IMAGE; private static final byte[] EMPTY_16X16_IMAGE;
@@ -166,6 +181,15 @@ public abstract class AbstractPackManager implements PackManager {
loadInternalData("internal/models/item/_all.json", ((key, jsonObject) -> { loadInternalData("internal/models/item/_all.json", ((key, jsonObject) -> {
PRESET_MODERN_MODELS_ITEM.put(key, jsonObject); PRESET_MODERN_MODELS_ITEM.put(key, jsonObject);
VANILLA_MODELS.add(Key.of(key.namespace(), "item/" + key.value())); VANILLA_MODELS.add(Key.of(key.namespace(), "item/" + key.value()));
JsonElement parent = jsonObject.get("parent");
if (parent instanceof JsonPrimitive primitive) {
String parentModel = primitive.getAsString();
if (parentModel.equals("minecraft:item/handheld")) {
SIMPLIFIED_MODEL_READERS.put(key, HandheldModelReader.INSTANCE);
} else {
SIMPLIFIED_MODEL_READERS.put(key, GeneratedModelReader.INSTANCE);
}
}
})); }));
loadInternalData("internal/models/block/_all.json", ((key, jsonObject) -> { loadInternalData("internal/models/block/_all.json", ((key, jsonObject) -> {
PRESET_MODELS_BLOCK.put(key, jsonObject); PRESET_MODELS_BLOCK.put(key, jsonObject);
@@ -428,7 +452,12 @@ public abstract class AbstractPackManager implements PackManager {
plugin.saveResource("resources/default/resourcepack/pack.mcmeta"); plugin.saveResource("resources/default/resourcepack/pack.mcmeta");
plugin.saveResource("resources/default/resourcepack/pack.png"); plugin.saveResource("resources/default/resourcepack/pack.png");
// configs // configs
plugin.saveResource("resources/default/configuration/templates.yml"); plugin.saveResource("resources/default/configuration/templates/block_settings.yml");
plugin.saveResource("resources/default/configuration/templates/block_states.yml");
plugin.saveResource("resources/default/configuration/templates/models.yml");
plugin.saveResource("resources/default/configuration/templates/loot_tables.yml");
plugin.saveResource("resources/default/configuration/templates/recipes.yml");
plugin.saveResource("resources/default/configuration/templates/tool_levels.yml");
plugin.saveResource("resources/default/configuration/categories.yml"); plugin.saveResource("resources/default/configuration/categories.yml");
plugin.saveResource("resources/default/configuration/emoji.yml"); plugin.saveResource("resources/default/configuration/emoji.yml");
plugin.saveResource("resources/default/configuration/translations.yml"); plugin.saveResource("resources/default/configuration/translations.yml");

View File

@@ -0,0 +1,38 @@
package net.momirealms.craftengine.core.pack.model.simplified;
import net.momirealms.craftengine.core.util.Key;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GeneratedModelReader implements SimplifiedModelReader {
public static final GeneratedModelReader INSTANCE = new GeneratedModelReader();
@Override
public Map<String, Object> convert(List<String> textures, List<String> optionalModelPaths, Key id) {
boolean autoModelPath = optionalModelPaths.size() != 1;
Map<String, String> texturesProperty;
switch (textures.size()) {
case 1 -> texturesProperty = Map.of("layer0", textures.getFirst());
case 2 -> texturesProperty = Map.of(
"layer0", textures.get(0),
"layer1", textures.get(1)
);
default -> {
texturesProperty = new HashMap<>();
for (int i = 0; i < textures.size(); i++) {
texturesProperty.put("layer" + i, textures.get(i));
}
}
}
return Map.of(
"type", "model",
"path", autoModelPath ? id.namespace() + ":item/" + id.value() : optionalModelPaths.getFirst(),
"generation", Map.of(
"parent", "item/generated",
"textures", texturesProperty
)
);
}
}

View File

@@ -0,0 +1,38 @@
package net.momirealms.craftengine.core.pack.model.simplified;
import net.momirealms.craftengine.core.util.Key;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HandheldModelReader implements SimplifiedModelReader {
public static final HandheldModelReader INSTANCE = new HandheldModelReader();
@Override
public Map<String, Object> convert(List<String> textures, List<String> optionalModelPaths, Key id) {
boolean autoModelPath = optionalModelPaths.size() != 1;
Map<String, String> texturesProperty;
switch (textures.size()) {
case 1 -> texturesProperty = Map.of("layer0", textures.getFirst());
case 2 -> texturesProperty = Map.of(
"layer0", textures.get(0),
"layer1", textures.get(1)
);
default -> {
texturesProperty = new HashMap<>();
for (int i = 0; i < textures.size(); i++) {
texturesProperty.put("layer" + i, textures.get(i));
}
}
}
return Map.of(
"type", "model",
"path", autoModelPath ? id.namespace() + ":item/" + id.value() : optionalModelPaths.getFirst(),
"generation", Map.of(
"parent", "item/handheld",
"textures", texturesProperty
)
);
}
}

View File

@@ -0,0 +1,13 @@
package net.momirealms.craftengine.core.pack.model.simplified;
import net.momirealms.craftengine.core.util.Key;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
public interface SimplifiedModelReader {
@Nullable
Map<String, Object> convert(List<String> textures, List<String> optionalModelPaths, Key id);
}

View File

@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
# Project settings # Project settings
# Rule: [major update].[feature update].[bug fix] # Rule: [major update].[feature update].[bug fix]
project_version=0.0.65.6 project_version=0.0.65.7
config_version=54 config_version=54
lang_version=38 lang_version=38
project_group=net.momirealms project_group=net.momirealms
@@ -49,7 +49,7 @@ byte_buddy_version=1.17.8
ahocorasick_version=0.6.3 ahocorasick_version=0.6.3
snake_yaml_version=2.5 snake_yaml_version=2.5
anti_grief_version=1.0.4 anti_grief_version=1.0.4
nms_helper_version=1.0.129 nms_helper_version=1.0.128
evalex_version=3.5.0 evalex_version=3.5.0
reactive_streams_version=1.0.4 reactive_streams_version=1.0.4
amazon_awssdk_version=2.34.5 amazon_awssdk_version=2.34.5