mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
Compare commits
4 Commits
1f8be81f50
...
39f4ecc504
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39f4ecc504 | ||
|
|
f243be3d5e | ||
|
|
84028a06f1 | ||
|
|
ef17f8a5e5 |
@@ -282,7 +282,7 @@ export class Deepslate {
|
|||||||
this.settingsCache = settings.noise
|
this.settingsCache = settings.noise
|
||||||
const randomState = new this.d.RandomState(settings, seed)
|
const randomState = new this.d.RandomState(settings, seed)
|
||||||
return randomState.router.finalDensity
|
return randomState.router.finalDensity
|
||||||
} else {
|
} else if (this.isVersion('1.18.2')) {
|
||||||
const random = this.d.XoroshiroRandom.create(seed).forkPositional()
|
const random = this.d.XoroshiroRandom.create(seed).forkPositional()
|
||||||
const settings = this.d.NoiseSettings.fromJson({
|
const settings = this.d.NoiseSettings.fromJson({
|
||||||
min_y: minY,
|
min_y: minY,
|
||||||
@@ -297,6 +297,8 @@ export class Deepslate {
|
|||||||
this.settingsCache = settings
|
this.settingsCache = settings
|
||||||
const originalFn = this.d.DensityFunction.fromJson(state)
|
const originalFn = this.d.DensityFunction.fromJson(state)
|
||||||
return originalFn.mapAll(new (this.d.NoiseRouter as any).Visitor(random, settings))
|
return originalFn.mapAll(new (this.d.NoiseRouter as any).Visitor(random, settings))
|
||||||
|
} else {
|
||||||
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -311,7 +311,9 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
enchant_with_levels: ({ options, levels }) => (item, ctx) => {
|
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)
|
const selected = selectEnchantments(item, computeInt(levels, ctx), allowed, ctx)
|
||||||
if (item.is('book')) {
|
if (item.is('book')) {
|
||||||
item.id = Identifier.create('enchanted_book')
|
item.id = Identifier.create('enchanted_book')
|
||||||
@@ -817,9 +819,12 @@ interface Enchant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function selectEnchantments(item: ResolvedItem, levels: number, options: string[], ctx: LootContext): Enchant[] {
|
function selectEnchantments(item: ResolvedItem, levels: number, options: string[], ctx: LootContext): Enchant[] {
|
||||||
const enchantable = item.get('enchantable', tag => tag.isCompound() ? tag.getNumber('value') : undefined)
|
let enchantable: number | undefined = 1 // Not fully correct before version 1.21.2
|
||||||
if (enchantable === undefined) {
|
if (checkVersion(ctx.version, '1.21.2')) {
|
||||||
return []
|
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))
|
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
|
const f = (ctx.random.nextFloat() + ctx.random.nextFloat() - 1) * 0.15
|
||||||
|
|||||||
@@ -49,6 +49,35 @@ export function placeItems(version: VersionId, recipe: any, animation: number, i
|
|||||||
const choice = materials[animation % materials.length]
|
const choice = materials[animation % materials.length]
|
||||||
items.set('crafting.1', choice)
|
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') {
|
} else if (type === 'smelting' || type === 'smoking' || type === 'blasting' || type === 'campfire_cooking') {
|
||||||
const choices = allIngredientChoices(version, recipe.ingredient, itemTags)
|
const choices = allIngredientChoices(version, recipe.ingredient, itemTags)
|
||||||
if (choices.length > 0) {
|
if (choices.length > 0) {
|
||||||
|
|||||||
@@ -420,20 +420,12 @@ const initialize: core.ProjectInitializer = async (ctx) => {
|
|||||||
// Duplicate these from spyglass for now, until they are exported separately
|
// Duplicate these from spyglass for now, until they are exported separately
|
||||||
function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, versions: VersionMeta[]) {
|
function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, versions: VersionMeta[]) {
|
||||||
mcdoc.runtime.registerAttribute(meta, 'since', mcdoc.runtime.attribute.validator.string, {
|
mcdoc.runtime.registerAttribute(meta, 'since', mcdoc.runtime.attribute.validator.string, {
|
||||||
filterElement: (config, ctx) => {
|
filterElement: (config, _) => {
|
||||||
if (!config.startsWith('1.')) {
|
|
||||||
ctx.logger.warn(`Invalid mcdoc attribute for "since": ${config}`)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return ReleaseVersion.cmp(release, config as ReleaseVersion) >= 0
|
return ReleaseVersion.cmp(release, config as ReleaseVersion) >= 0
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
mcdoc.runtime.registerAttribute(meta, 'until', mcdoc.runtime.attribute.validator.string, {
|
mcdoc.runtime.registerAttribute(meta, 'until', mcdoc.runtime.attribute.validator.string, {
|
||||||
filterElement: (config, ctx) => {
|
filterElement: (config, _) => {
|
||||||
if (!config.startsWith('1.')) {
|
|
||||||
ctx.logger.warn(`Invalid mcdoc attribute for "until": ${config}`)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return ReleaseVersion.cmp(release, config as ReleaseVersion) < 0
|
return ReleaseVersion.cmp(release, config as ReleaseVersion) < 0
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -442,14 +434,10 @@ function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, ve
|
|||||||
'deprecated',
|
'deprecated',
|
||||||
mcdoc.runtime.attribute.validator.optional(mcdoc.runtime.attribute.validator.string),
|
mcdoc.runtime.attribute.validator.optional(mcdoc.runtime.attribute.validator.string),
|
||||||
{
|
{
|
||||||
mapField: (config, field, ctx) => {
|
mapField: (config, field, _) => {
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
return { ...field, deprecated: true }
|
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) {
|
if (ReleaseVersion.cmp(release, config as ReleaseVersion) >= 0) {
|
||||||
return { ...field, deprecated: true }
|
return { ...field, deprecated: true }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user