diff --git a/src/app/components/Octicon.tsx b/src/app/components/Octicon.tsx index 97dcf1e1..9404a34c 100644 --- a/src/app/components/Octicon.tsx +++ b/src/app/components/Octicon.tsx @@ -28,6 +28,7 @@ export const Octicon = { link_external: , mark_github: , moon: , + package: , play: , plus: , plus_circle: , diff --git a/src/app/schema/renderHtml.tsx b/src/app/schema/renderHtml.tsx index a6a98c6e..999fc2b6 100644 --- a/src/app/schema/renderHtml.tsx +++ b/src/app/schema/renderHtml.tsx @@ -9,7 +9,7 @@ import { localize, useStore } from '../contexts' import { useFocus } from '../hooks' import { VanillaColors } from '../previews' import type { BlockStateRegistry, VersionId } from '../services' -import { CachedDecorator, CachedFeature } from '../services' +import { CachedCollections, CachedDecorator, CachedFeature, getTextureUrl } from '../services' import { deepClone, deepEqual, generateUUID, hexId, hexToRgb, isObject, newSeed, rgbToHex, stringToColor } from '../Utils' import { ModelWrapper } from './ModelWrapper' @@ -22,6 +22,8 @@ const fixedLists = ['generator_biome.parameters.temperature', 'generator_biome.p const collapsedFields = ['noise_settings.surface_rule', 'noise_settings.noise.terrain_shaper'] const collapsableFields = ['density_function.argument', 'density_function.argument1', 'density_function.argument2', 'density_function.input', 'density_function.when_in_range', 'density_function.when_out_of_range'] +const PACKAGE = '' + const findGenerator = (id: string) => { return config.generators.find(g => g.id === id.replace(/^\$/, '')) } @@ -134,11 +136,24 @@ const renderHtml: RenderHook = { const cPath = path.push(index).contextPush('entry') const canToggle = children.type(cPath) === 'object' const toggle = isToggled(cId) + + let label: undefined | string | JSX.Element + if (['loot_pool.entries.entry', 'loot_entry.alternatives.children.entry', 'loot_entry.group.children.entry', 'loot_entry.sequence.children.entry', 'function.set_contents.entries.entry'].includes(cPath.getContext().join('.'))) { + if (isObject(cValue) && typeof cValue.type === 'string' && cValue.type.replace(/^minecraft:/, '') === 'item' && typeof cValue.name === 'string') { + const texturePath = `item/${cValue.name.replace(/^minecraft:/, '')}` + if (CachedCollections.get('texture').includes('minecraft:' + texturePath)) { + label = e.currentTarget.outerHTML = PACKAGE} /> + } else { + label = Octicon.package + } + } + } + if (canToggle && (toggle === false || (toggle === undefined && value.length > 20))) { return
- +
} @@ -165,7 +180,7 @@ const renderHtml: RenderHook = { }, }, ] - return + return {canToggle && } {value.length > 1 &&
@@ -451,7 +466,7 @@ type TreeNodeProps = { states: BlockStateRegistry, ctx: Record, compare?: any, - label?: string, + label?: string | ComponentChildren, actions?: MenuAction[], children?: ComponentChildren, } diff --git a/src/app/services/DataFetcher.ts b/src/app/services/DataFetcher.ts index 4318b718..0ab5c869 100644 --- a/src/app/services/DataFetcher.ts +++ b/src/app/services/DataFetcher.ts @@ -154,6 +154,11 @@ export async function fetchVersions(): Promise { } } +export function getTextureUrl(versionId: VersionId, path: string): string { + const version = config.versions.find(v => v.id === versionId)! + return `${mcmeta(version, 'assets')}/assets/minecraft/textures/${path}.png` +} + async function getData(url: string, fn: (v: any) => T = (v: any) => v): Promise { try { const cache = await caches.open(CACHE_NAME) diff --git a/src/styles/nodes.css b/src/styles/nodes.css index 8fc4d060..08820d8c 100644 --- a/src/styles/nodes.css +++ b/src/styles/nodes.css @@ -94,7 +94,6 @@ .node-header > * { height: 34px; - /* border: none; */ border: 1px solid; color: var(--node-text); border-color: var(--node-border); @@ -109,6 +108,21 @@ background-color: var(--node-background-label); } +.node-header > label > img { + height: 80%; + position: relative; + top: 10%; + image-rendering: pixelated; +} + +.node-header > label > svg { + width: 25.59px; + height: 20px; + position: relative; + top: 5px; + fill: var(--node-text-dimmed); +} + .node-header > input { font-size: 18px; padding-left: 9px;