Compare commits

...

4 Commits

Author SHA1 Message Date
Misode
39f4ecc504 Fix #824 noise settings preview in 1.18
Some checks failed
Deploy to GitHub Pages / build (push) Has been cancelled
Deploy to GitHub Pages / deploy (push) Has been cancelled
2026-02-01 00:16:10 +01:00
Misode
f243be3d5e Fix #832 enchant_with_levels loot preview 2026-02-01 00:07:09 +01:00
Misode
84028a06f1 Add basic support for crafting_dye and crafting_imbue 2026-01-31 23:27:56 +01:00
Misode
ef17f8a5e5 Fix mcdoc version filters for 26.1 2026-01-31 22:14:40 +01:00
4 changed files with 44 additions and 20 deletions

View File

@@ -282,7 +282,7 @@ export class Deepslate {
this.settingsCache = settings.noise
const randomState = new this.d.RandomState(settings, seed)
return randomState.router.finalDensity
} else {
} else if (this.isVersion('1.18.2')) {
const random = this.d.XoroshiroRandom.create(seed).forkPositional()
const settings = this.d.NoiseSettings.fromJson({
min_y: minY,
@@ -297,6 +297,8 @@ export class Deepslate {
this.settingsCache = settings
const originalFn = this.d.DensityFunction.fromJson(state)
return originalFn.mapAll(new (this.d.NoiseRouter as any).Visitor(random, settings))
} else {
return undefined
}
}

View File

@@ -311,7 +311,9 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
})
},
enchant_with_levels: ({ options, levels }) => (item, ctx) => {
const allowed = getHomogeneousList(options, ctx.getEnchantmentTag)
const allowed = options
? getHomogeneousList(options, ctx.getEnchantmentTag)
: [...ctx.getEnchantments().keys()]
const selected = selectEnchantments(item, computeInt(levels, ctx), allowed, ctx)
if (item.is('book')) {
item.id = Identifier.create('enchanted_book')
@@ -817,9 +819,12 @@ interface Enchant {
}
function selectEnchantments(item: ResolvedItem, levels: number, options: string[], ctx: LootContext): Enchant[] {
const enchantable = item.get('enchantable', tag => tag.isCompound() ? tag.getNumber('value') : undefined)
if (enchantable === undefined) {
return []
let enchantable: number | undefined = 1 // Not fully correct before version 1.21.2
if (checkVersion(ctx.version, '1.21.2')) {
enchantable = item.get('enchantable', tag => tag.isCompound() ? tag.getNumber('value') : undefined)
if (enchantable === undefined) {
return []
}
}
let cost = levels + 1 + ctx.random.nextInt(Math.floor(enchantable / 4 + 1)) + ctx.random.nextInt(Math.floor(enchantable / 4 + 1))
const f = (ctx.random.nextFloat() + ctx.random.nextFloat() - 1) * 0.15

View File

@@ -49,6 +49,35 @@ export function placeItems(version: VersionId, recipe: any, animation: number, i
const choice = materials[animation % materials.length]
items.set('crafting.1', choice)
}
} else if (type === 'crafting_dye') {
const target = allIngredientChoices(version, recipe.target, itemTags)
if (target.length > 0) {
const choice = target[animation % target.length]
items.set('crafting.0', choice)
}
const dye = allIngredientChoices(version, recipe.dye, itemTags)
if (dye.length > 0) {
const choice = dye[animation % dye.length]
items.set('crafting.1', choice)
}
} else if (type === 'crafting_imbue') {
const source = allIngredientChoices(version, recipe.source, itemTags)
if (source.length > 0) {
const choice = source[animation % source.length]
items.set('crafting.4', choice)
}
const material = allIngredientChoices(version, recipe.material, itemTags)
if (material.length > 0) {
const choice = material[animation % material.length]
items.set('crafting.0', choice)
items.set('crafting.1', choice)
items.set('crafting.2', choice)
items.set('crafting.3', choice)
items.set('crafting.5', choice)
items.set('crafting.6', choice)
items.set('crafting.7', choice)
items.set('crafting.8', choice)
}
} else if (type === 'smelting' || type === 'smoking' || type === 'blasting' || type === 'campfire_cooking') {
const choices = allIngredientChoices(version, recipe.ingredient, itemTags)
if (choices.length > 0) {

View File

@@ -420,20 +420,12 @@ const initialize: core.ProjectInitializer = async (ctx) => {
// Duplicate these from spyglass for now, until they are exported separately
function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, versions: VersionMeta[]) {
mcdoc.runtime.registerAttribute(meta, 'since', mcdoc.runtime.attribute.validator.string, {
filterElement: (config, ctx) => {
if (!config.startsWith('1.')) {
ctx.logger.warn(`Invalid mcdoc attribute for "since": ${config}`)
return true
}
filterElement: (config, _) => {
return ReleaseVersion.cmp(release, config as ReleaseVersion) >= 0
},
})
mcdoc.runtime.registerAttribute(meta, 'until', mcdoc.runtime.attribute.validator.string, {
filterElement: (config, ctx) => {
if (!config.startsWith('1.')) {
ctx.logger.warn(`Invalid mcdoc attribute for "until": ${config}`)
return true
}
filterElement: (config, _) => {
return ReleaseVersion.cmp(release, config as ReleaseVersion) < 0
},
})
@@ -442,14 +434,10 @@ function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, ve
'deprecated',
mcdoc.runtime.attribute.validator.optional(mcdoc.runtime.attribute.validator.string),
{
mapField: (config, field, ctx) => {
mapField: (config, field, _) => {
if (config === undefined) {
return { ...field, deprecated: true }
}
if (!config.startsWith('1.')) {
ctx.logger.warn(`Invalid mcdoc attribute for "deprecated": ${config}`)
return field
}
if (ReleaseVersion.cmp(release, config as ReleaseVersion) >= 0) {
return { ...field, deprecated: true }
}