Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-218120

Certain spawner nbt causes an error and a CastClassException casting ClientWorld to ServerWorld

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.16.5
    • None
    • Unconfirmed
    • (Unassigned)

      The bug is reproducible with the following steps:
      1. Obtain a command block and put in the following command: {{setblock ~ ~1 ~ minecraft:spawner{MinSpawnDelay: 200s, MaxNearbyEntities: 6s, SpawnData:

      {id: "minecraft:zombified_piglin"}

      , z: 290, x: 14, MaxSpawnDelay: 800s, SpawnCount: 4s, RequiredPlayerRange: 16s, id: "minecraft:mob_spawner", SpawnPotentials: \\\\{Weight: 1, Entity: {id: "minecraft:zombified_piglin"}}, y: 31, SpawnRange: 4s, Delay: 335s}}}

      2. Power the command block with a lever or button to set the spawner
      3. No mob appears spinning in the spawner and spammed errors appear in the log as attached below.

      This issue affects Endermen, Zombie Piglins, Bees, Iron Golems, Polar Bears, and Wolves.

      Upon analysis in a fabric environment with yarn mappings, we can see that the cast cast exception is:
      Caused by: java.lang.ClassCastException: class net.minecraft.client.world.ClientWorld cannot be cast to class net.minecraft.server.world.ServerWorld (net.minecraft.client.world.ClientWorld and net.minecraft.server.world.ServerWorld are in unnamed module of loader net.fabricmc.loader.launch.knot.KnotClassLoader @26d9b808)Caused by: java.lang.ClassCastException: class net.minecraft.client.world.ClientWorld cannot be cast to class net.minecraft.server.world.ServerWorld (net.minecraft.client.world.ClientWorld and net.minecraft.server.world.ServerWorld are in unnamed module of loader net.fabricmc.loader.launch.knot.KnotClassLoader @26d9b808) at net.minecraft.entity.mob.ZombifiedPiglinEntity.readCustomDataFromTag(ZombifiedPiglinEntity.java:175) ~[minecraft-1.16.4-projectmapped-net.fabricmc.yarn-1.16.4+build.1-v2.jar:?] at net.minecraft.entity.Entity.fromTag(Entity.java:1517)

      The relevant code causing this exception seems to be in the readCustomDataFromTag(CompoundTag tag) method in each of the affected entities:
      public void readCustomDataFromTag(CompoundTag tag) {

      { super.readCustomDataFromTag(tag); this.angerFromTag((ServerWorld)this.world, tag); }

        1. latest.log
          781 kB
          Justsnoopy30

            Unassigned Unassigned
            Justsnoopy30 Justsnoopy30
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: