Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-1104

EntityType.Chicken makes a switch return EntityType.Cow

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Major Major
    • None
    • None
    • OS: Windows 10 Pro
      Java: 1.8_51
      Spigot: 1.8.8-R0.1 SNAPSHOT

      Well I have made a NMS library, to only discover when you switch the EntityType enum and pass EntityType.Chicken to it, the switch chooses EntityType.Cow for some reason I'm not sure of

      Registering the Chicken

      NMS.RegisterCustomEntites(new NMSMob[] { new NMSMob(EntityType.ZOMBIE, zombie), new NMSMob(EntityType.CHICKEN, chicken) });
      

      The Switch code

      	public NMSMob(EntityType type, Object entity) {
      		this.type = type;
      		switch (type) {
      			case BAT: mi = NMSMobInfo.BAT; mob = ((EntityBat)(entity));
      			case BLAZE: mi = NMSMobInfo.BLAZE; mob = ((EntityBlaze)(entity));
      			case CAVE_SPIDER: mi = NMSMobInfo.CABESPIDER; mob = ((EntityCaveSpider)(entity));
      			case CHICKEN: mi = NMSMobInfo.CHICKEN; mob = ((EntityChicken)(entity));
      			case COW: mi = NMSMobInfo.COW; mob = ((EntityCow)(entity));
      			case CREEPER: mi = NMSMobInfo.CREEPER; mob = ((EntityCreeper)(entity));
      			case ENDERMAN: mi = NMSMobInfo.ENDERMAN; mob = ((EntityEnderman)(entity));
      			case ENDERMITE: mi = NMSMobInfo.ENDERMITE; mob = ((EntityEndermite)(entity));
      			case ENDER_DRAGON: mi = NMSMobInfo.ENDERDRAGON; mob = ((EntityEnderDragon)(entity));
      			case GHAST: mi = NMSMobInfo.GHAST; mob = ((EntityGhast)(entity));
      			case GIANT: mi = NMSMobInfo.GIANTZOMBIE; mob = ((EntityGiantZombie)(entity));
      			case GUARDIAN: mi = NMSMobInfo.GUARDIAN; mob = ((EntityGuardian)(entity));
      			case HORSE: mi = NMSMobInfo.HORSE; mob = ((EntityHorse)(entity));
      			case IRON_GOLEM: mi = NMSMobInfo.IRONGOLEM; mob = ((EntityIronGolem)(entity));
      			case MAGMA_CUBE: mi = NMSMobInfo.MAGMACUBE; mob = ((EntityMagmaCube)(entity));
      			case MUSHROOM_COW: mi = NMSMobInfo.MOOSHROOM; mob = ((EntityMushroomCow)(entity));
      			case OCELOT: mi = NMSMobInfo.OCELOT; mob = ((EntityOcelot)(entity));
      			case PIG: mi = NMSMobInfo.PIG; mob = ((EntityPig)(entity));
      			case PIG_ZOMBIE: mi = NMSMobInfo.ZOMBIEPIGMAN; mob = ((EntityPigZombie)(entity));
      			case RABBIT: mi = NMSMobInfo.RABBIT; mob = ((EntityRabbit)(entity));
      			case SHEEP: mi = NMSMobInfo.SHEEP; mob = ((EntitySheep)(entity));
      			case SILVERFISH: mi = NMSMobInfo.SILVERFISH; mob = ((EntitySilverfish)(entity));
      			case SKELETON: mi = NMSMobInfo.SKELETON; mob = ((EntitySkeleton)(entity));
      			case SLIME: mi = NMSMobInfo.SLIME; mob = ((EntitySlime)(entity));
      			case SNOWMAN: mi = NMSMobInfo.SNOWGOLEM; mob = ((EntitySnowman)(entity));
      			case SPIDER: mi = NMSMobInfo.SPIDER; mob = ((EntitySpider)(entity));
      			case SQUID: mi = NMSMobInfo.SQUID; mob = ((EntitySquid)(entity));
      			case VILLAGER: mi = NMSMobInfo.VILLAGER; mob = ((EntityVillager)(entity));
      			case WITCH: mi = NMSMobInfo.WITCH; mob = ((EntityWitch)(entity));
      			case WITHER: mi = NMSMobInfo.WITHER; mob = ((EntityWither)(entity));
      			case WOLF: mi = NMSMobInfo.WOLF; mob = ((EntityWolf)(entity));
      			case ZOMBIE: mi = NMSMobInfo.ZOMBIE; mob = ((EntityZombie)(entity));
      			default: break;
      		}
      	}
      

      The Exception
      java.lang.ClassCastException: com.realix.codexum.mobulator.mob.CustomChicken cannot be cast to net.minecraft.server.v1_8_R3.EntityCow
      at com.realix.codexum.nmsulator.NMSMob.<init>(NMSMob.java:55) ~[?:?]
      at com.realix.codexum.mobulator.NMSMobLoader.init(NMSMobLoader.java:17) ~[?:?]
      at com.realix.codexum.mobulator.Mobulator.onEnable(Mobulator.java:28) ~[?:?]
      at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:356) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:316) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:524) [spigot-1.8.8.jar:git-Spigot-6abac0c-9935adc]
      at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]

            Unassigned Unassigned
            Anonixis Connor S
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: