Skip to content

Commit

Permalink
remove local_time, fix chest special renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsjo committed Nov 14, 2024
1 parent 290af74 commit 4cb1fbd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 32 deletions.
12 changes: 0 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
"dayjs": "^1.11.13",
"gl-matrix": "^3.3.0",
"md5": "^2.3.0",
"pako": "^2.0.3"
Expand Down
18 changes: 1 addition & 17 deletions src/render/ItemModel.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import dayjs from "dayjs"
import tz from "dayjs/plugin/timezone.js"
import { Identifier, ItemStack, } from "../core/index.js"
import { clamp } from "../math/index.js"
import { Color, Json } from "../util/index.js"
import { ItemTint } from "./ItemTint.js"
import { SpecialModel } from "./SpecialModel.js"
import { Cull, ItemRenderer, ItemRendererResources, ItemRenderingContext, Mesh } from "./index.js"
tz // don't remove import

export interface ItemModelProvider {
getItemModel(id: Identifier): ItemModel | null
Expand Down Expand Up @@ -212,16 +209,7 @@ export namespace ItemModel {
}
return tag.getString(block_state_property)
}) ?? '' // TODO: verify default value
case 'local_time':
const time_zone = Json.readString(root.time_zone)
const pattern = Json.readString(root.pattern) ?? 'yyyy-MM-dd'
return (item, context) => {
let time = dayjs(context.local_time)
if (time_zone) {
time = time.tz(time_zone)
}
return time.format(pattern)
}
case 'local_time': return (item, context) => 'NOT IMPLEMENTED'
case 'holder_type':
return (item, context) => context.holder_type?.toString() ?? ''
case 'custom_model_data':
Expand Down Expand Up @@ -352,15 +340,11 @@ export namespace ItemModel {
const selectedItemIndex = context['bundle/selected_item']
if (selectedItemIndex === undefined || selectedItemIndex < 0) return new Mesh()
const selectedItem = item.getComponent('bundle_contents', tag => {
console.log(tag)
if (!tag.isListOrArray()) return undefined
const selectedItemTag = tag.get(selectedItemIndex)
console.log(selectedItemTag)
if (selectedItemTag === undefined || !selectedItemTag.isCompound()) return undefined
return ItemStack.fromNbt(selectedItemTag)
})

console.log(selectedItem)

return selectedItem !== undefined ? ItemRenderer.getItemMesh(selectedItem, resources, {...context, 'bundle/selected_item': undefined}) : new Mesh()
}
Expand Down
1 change: 0 additions & 1 deletion src/render/ItemRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export type ItemRenderingContext = {
keybind_down?: string[],

main_hand?: 'left' | 'right',
local_time?: number, //milliseconds
holder_type?: Identifier,

cooldown_normalized?: number,
Expand Down
6 changes: 5 additions & 1 deletion src/render/SpecialModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export namespace SpecialModel {
}

public getMesh(item: ItemStack, resources: TextureAtlasProvider): Mesh {
return this.renderer(resources)
const t = mat4.create()
mat4.translate(t, t, [8, 8, 8])
mat4.rotateY(t, t, Math.PI)
mat4.translate(t, t, [-8, -8, -8])
return this.renderer(resources).transform(t)
}
}

Expand Down

0 comments on commit 4cb1fbd

Please sign in to comment.