Skip to content

Commit

Permalink
Attempting to fix #399
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Jul 3, 2023
1 parent 6f4fdd0 commit d9f7fe0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/app/components/customized/CustomizedGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import type { VersionId } from '../../services/Schemas.js'
import type { CustomizedOreModel } from './CustomizedModel.js'
import { CustomizedModel } from './CustomizedModel.js'

// Random prefix to avoid collisions with other packs that add no-op placed features
const FeatureCollisionPrefix = 468794

const PackTypes = ['dimension_type', 'worldgen/noise_settings', 'worldgen/noise', 'worldgen/structure_set', 'worldgen/placed_feature', 'worldgen/configured_feature', 'worldgen/configured_carver'] as const
export type CustomizedPackType = typeof PackTypes[number]

Expand All @@ -17,6 +20,7 @@ interface Context {
blockStates: Map<string, {properties: Record<string, string[]>, default: Record<string, string>}>,
vanilla: CustomizedPack,
out: CustomizedPack,
featureCollisionIndex: number,
}

export async function generateCustomized(model: CustomizedModel, version: VersionId): Promise<CustomizedPack> {
Expand All @@ -35,6 +39,7 @@ export async function generateCustomized(model: CustomizedModel, version: Versio
out: PackTypes.reduce((acc, k) => {
return { ...acc, [k]: new Map()}
}, Object.create(null)) as CustomizedPack,
featureCollisionIndex: FeatureCollisionPrefix,
}
generateDimensionType(ctx)
generateNoiseSettings(ctx)
Expand Down Expand Up @@ -158,13 +163,18 @@ function generateStructures(ctx: Context) {
}

function getDisabledFeature(ctx: Context) {
ctx.out['worldgen/configured_feature'].set('no_op', {
type: 'minecraft:no_op',
config: {},
})
ctx.featureCollisionIndex += 1
return {
feature: 'minecraft:no_op',
placement: [],
feature: {
type: 'minecraft:no_op',
config: {},
},
placement: [
{
type: 'minecraft:rarity_filter',
chance: ctx.featureCollisionIndex,
},
],
}
}

Expand Down

1 comment on commit d9f7fe0

@vercel
Copy link

@vercel vercel bot commented on d9f7fe0 Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

misode – ./

misode-git-master-misode.vercel.app
misode.vercel.app
misode-misode.vercel.app

Please sign in to comment.