Patchouli

Patchouli

168M Downloads

[1.14] Can't display a custom villager entity

desht opened this issue ยท 2 comments

commented

I have the following page:

{
      "type": "entity",
      "name": "Mechanic",
      "entity": "minecraft:villager{VillagerData:{profession:'pneumaticcraft:mechanic',level:1,type:'minecraft:plains'}}",
      "text": "$(italic)Not a fan of $(l:tools/amadron_tablet)Amadron/$."
}

but it throws the following exception:

Caused by: java.lang.ClassCastException: net.minecraft.client.world.ClientWorld cannot be cast to net.minecraft.world.server.ServerWorld
	at net.minecraft.entity.merchant.villager.VillagerEntity.readAdditional(VillagerEntity.java:439) ~[forge-1.14.4-28.2.3_mapped_snapshot_20191125-1.14.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.Entity.read(Entity.java:1667) ~[forge-1.14.4-28.2.3_mapped_snapshot_20191125-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at vazkii.patchouli.common.util.EntityUtil.lambda$loadEntity$0(EntityUtil.java:53) ~[Patchouli-1.14.4-1.1-25.128_mapped_snapshot_20191125-1.14.3.jar:1.1-25.128] {re:classloading}
... 39 more

Unfortunately, villager NBT reading requires a ServerWorld (see VillagerEntity#readAdditional()). Not sure there's an simple fix for this; possibly a custom extension of VillagerEntity which overrides readAdditional() to omit the resetBrain() call?

commented

in vanilla 1.15 an instanceof check appears to have been added

commented

Yep, you're right - this will be a non-issue in 1.15. Guess it's up to you if you want to add a workaround in 1.14 (probably not worth the effort :) )