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

Spawner ignoring provided Rotation tag

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: Minecraft 1.9 Pre-Release 2, Minecraft 1.9 Pre-Release 3, Minecraft 1.9, Minecraft 1.9.1, Minecraft 1.9.2, Minecraft 1.9.4, Minecraft 1.10 Pre-Release 1, Minecraft 1.10.2, Minecraft 16w32b, Minecraft 16w40a, Minecraft 1.11.2, Minecraft 1.12.2, Minecraft 18w06a, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w05a, Minecraft 19w06a, Minecraft 19w07a, 1.14.4, 19w46b
    • Fix Version/s: None
    • Labels:
    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      The bug

      Spawners ignore the Rotation tag of the entity to spawn and instead give them a random rotation.

      How to reproduce

      Use the following command

      /setblock ~ ~1 ~ minecraft:spawner{SpawnData:{id:"minecraft:armor_stand",Rotation:[180f,0f]},MinSpawnDelay:10s,MaxSpawnDelay:10s,SpawnCount:1,SpawnRange:5}
      

      You will see that the armor stands spawn with a random rotation

      The reason

      The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

      The reason why this happens is because the method net.minecraft.tileentity.MobSpawnerBaseLogic.updateSpawner() always uses a random yaw value and 0f as pitch value.

      public void updateSpawner()
      {
          if (!this.isActivated())
          {
              this.prevMobRotation = this.mobRotation;
          }
          else
          {
              BlockPos blockpos = this.getSpawnerPosition();
      
              if (this.getSpawnerWorld().isRemote)
              {
                  //...
              }
              else
              {
                  //...
      
                  for (int i = 0; i < this.spawnCount; ++i)
                  {
                      NBTTagCompound nbttagcompound = this.randomEntity.func_185277_b();
                      NBTTagList nbttaglist = nbttagcompound.getTagList("Pos", 6);
                      World world = this.getSpawnerWorld();
                      int j = nbttaglist.tagCount();
                      double d0 = j >= 1 ? nbttaglist.getDoubleAt(0) : (double)blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double)this.spawnRange + 0.5D;
                      double d1 = j >= 2 ? nbttaglist.getDoubleAt(1) : (double)(blockpos.getY() + world.rand.nextInt(3) - 1);
                      double d2 = j >= 3 ? nbttaglist.getDoubleAt(2) : (double)blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double)this.spawnRange + 0.5D;
                      Entity entity = AnvilChunkLoader.func_186054_a(nbttagcompound, world, d0, d1, d2, false);
      
                      if (entity == null)
                      {
                          return;
                      }
      
                      int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), (double)(blockpos.getX() + 1), (double)(blockpos.getY() + 1), (double)(blockpos.getZ() + 1))).func_186662_g((double)this.spawnRange)).size();
      
                      if (k >= this.maxNearbyEntities)
                      {
                          this.resetTimer();
                          return;
                      }
      
                      EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null;
                      
                      // Replaced this
                      //entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, world.rand.nextFloat() * 360.0F, 0.0F);
                      NBTTagList nbtRotation = nbttagcompound.getTagList("Rotation", 5);
                      int nbtRotationTagCount = nbtRotation.tagCount();
                      float yaw = nbtRotationTagCount >= 1 ? nbtRotation.getFloatAt(0) : world.rand.nextFloat() * 360.0F;
                      float pitch = nbtRotationTagCount >= 2 ? nbtRotation.getFloatAt(1) : 0.0F;
                      entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, yaw, pitch);
      
                      //...
                  }
      
                  if (flag)
                  {
                      this.resetTimer();
                  }
              }
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                marcono1234 [Mod] Marcono1234
              • Votes:
                6 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  CHK: