Skip to content

Commit 7da41b0

Browse files
authored
fix: fixed zombies and husks not having texture (#203)
1 parent 18a6f2c commit 7da41b0

File tree

4 files changed

+248
-238
lines changed

4 files changed

+248
-238
lines changed

prismarine-viewer/viewer/lib/entities.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,8 @@ export class Entities extends EventEmitter {
340340
}
341341

342342
update (entity: import('prismarine-entity').Entity & { delete?; pos }, overrides) {
343-
let isPlayerModel = entity.name === 'player'
343+
const isPlayerModel = entity.name === 'player'
344344
if (entity.name === 'zombie' || entity.name === 'zombie_villager' || entity.name === 'husk') {
345-
isPlayerModel = true
346345
overrides.texture = `textures/1.16.4/entity/${entity.name === 'zombie_villager' ? 'zombie_villager/zombie_villager.png' : `zombie/${entity.name}.png`}`
347346
}
348347
if (!this.entities[entity.id] && !entity.delete) {

prismarine-viewer/viewer/lib/entity/EntityMesh.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ts-check
22
import * as THREE from 'three'
33
import { OBJLoader } from 'three-stdlib'
4+
import huskPng from 'mc-assets/dist/other-textures/latest/entity/zombie/husk.png'
45
import entities from './entities.json'
56
import { externalModels } from './objModels'
67
import externalTexturesJson from './externalTextures.json'
@@ -290,6 +291,10 @@ const getEntity = (name) => {
290291
// zombie_villager: 'zombie_villager/zombie_villager'
291292
// }
292293

294+
const scaleEntity = {
295+
zombie: 1.9,
296+
husk: 1.9
297+
}
293298
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
294299
export class EntityMesh {
295300
constructor(version, type, scene, /** @type {{textures?, rotation?: Record<string, {x,y,z}>}} */overrides = {}) {
@@ -303,6 +308,9 @@ export class EntityMesh {
303308
if (originalType === 'zombie_horse') {
304309
texturePath = `textures/${version}/entity/horse/horse_zombie.png`
305310
}
311+
if (originalType === 'husk') {
312+
texturePath = huskPng
313+
}
306314
if (originalType === 'skeleton_horse') {
307315
texturePath = `textures/${version}/entity/horse/horse_skeleton.png`
308316
}
@@ -325,6 +333,8 @@ export class EntityMesh {
325333
alphaTest: 0.1
326334
})
327335
const obj = objLoader.parse(externalModels[type])
336+
const scale = scaleEntity[originalType]
337+
if (scale) obj.scale.set(scale, scale, scale)
328338
if (type === 'boat') obj.position.y = -1 // todo, should not be hardcoded
329339
obj.traverse((child) => {
330340
if (child instanceof THREE.Mesh) {

prismarine-viewer/viewer/lib/entity/exportedModels.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ export { default as witch } from './models/witch.obj'
3535
export { default as wolf } from './models/wolf.obj'
3636
export { default as zombie_villager } from './models/zombie_villager.obj'
3737
export { default as zombie } from './models/zombie.obj'
38+
export { default as husk } from './models/zombie.obj'
3839
export { default as boat } from './models/boat.obj'

0 commit comments

Comments
 (0)