Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions prismarine-viewer/viewer/lib/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import { WalkingGeneralSwing } from './entity/animations'
import externalTexturesJson from './entity/externalTextures.json'
import { disposeObject } from './threeJsUtils'
import worldBlockProvider from 'mc-assets/dist/worldBlockProvider';

export const TWEEN_DURATION = 120

Expand Down Expand Up @@ -93,6 +94,25 @@
return cube
}

function getFrameMesh (entity, scene, options, overrides) {
//@ts-expect-error
const pos = cursorBlockRel(0, 1, 0).position
const blockProvider = worldBlockProvider(this.world.blockstatesModels, this.world.blocksAtlases, 'latest')
const models = blockProvider.getAllResolvedModels0_1({
name: 'item_frame',
properties: {
// map: false
}
}, true)
const { material } = this.world
const mesh = getThreeBlockModelGroup(material, models, undefined, 'plains', loadedData)

Check failure on line 108 in prismarine-viewer/viewer/lib/entities.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Cannot find name 'getThreeBlockModelGroup'.
// mesh.rotation.y = THREE.MathUtils.degToRad(90)
setBlockPosition(mesh, pos)

Check failure on line 110 in prismarine-viewer/viewer/lib/entities.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Cannot find name 'setBlockPosition'.
const helper = new THREE.BoxHelper(mesh, 0xff_ff_00)
mesh.add(helper)
this.scene.add(mesh)
}

export type SceneEntity = THREE.Object3D & {
playerObject?: PlayerObject & {
animation?: PlayerAnimation
Expand Down Expand Up @@ -402,6 +422,8 @@
playerObject.animation = new WalkingGeneralSwing()
//@ts-expect-error
playerObject.animation.isMoving = false
} else if (entity.name === 'item_frame' || entity.name === 'glow_item_frame') {
mesh = getFrameMesh(entity, this.scene, this.entitiesOptions, overrides)
} else {
mesh = getEntityMesh(entity, this.scene, this.entitiesOptions, overrides)
}
Expand Down Expand Up @@ -452,28 +474,32 @@

// todo handle map, map_chunks events
// if (entity.name === 'item_frame' || entity.name === 'glow_item_frame') {


// console.log(entity)
// const example = {
// "present": true,
// "itemId": 847,
// "itemCount": 1,
// "nbtData": {
// "type": "compound",
// "name": "",
// "value": {
// "map": {
// "type": "int",
// "value": 2146483444
// },
// "interactiveboard": {
// "type": "byte",
// "value": 1
// }
// "type": "compound",
// "name": "",
// "value": {
// "map": {
// "type": "int",
// "value": 2146483444
// },
// "interactiveboard": {
// "type": "byte",
// "value": 1
// }
// }
// }
// }
// const item = entity.metadata?.[8]
// if (item.nbtData) {
// const nbt = nbt.simplify(item.nbtData)
// }

// const item = entity.metadata?.[8];
// if (item?.nbtData) {
// const nbT = nbt.simplify(item.nbtData)
// }
// }

Expand Down
Loading