private WeakReference<EntityPlayer> createNewPlayer(WorldServer world, int x, int y, int z) {
   EntityPlayer player = FakePlayerFactory.get(world, gameProfile);
   player.posX = x;
   player.posY = y;
   player.posZ = z;
   return new WeakReference<EntityPlayer>(player);
 }
Пример #2
0
  public static CraftEntity getEntity(CraftServer server, net.minecraft.entity.Entity entity) {
    /** Order is *EXTREMELY* important -- keep it right! =D */
    if (entity instanceof net.minecraft.entity.EntityLivingBase) {
      // Players
      if (entity instanceof net.minecraft.entity.player.EntityPlayer) {
        if (entity instanceof net.minecraft.entity.player.EntityPlayerMP) {
          return new CraftPlayer(server, (net.minecraft.entity.player.EntityPlayerMP) entity);
        }
        // Cauldron start - support fake player classes from mods
        // This case is never hit in vanilla
        // else { return new CraftHumanEntity(server, (net.minecraft.entity.player.EntityPlayer)
        // entity); }
        else {
          return new CraftPlayer(
              server,
              FakePlayerFactory.get(
                  DimensionManager.getWorld(entity.worldObj.provider.dimensionId),
                  ((net.minecraft.entity.player.EntityPlayer) entity).getGameProfile()));
        }
        // Cauldron end
      } else if (entity instanceof net.minecraft.entity.EntityCreature) {
        // Animals
        if (entity instanceof net.minecraft.entity.passive.EntityAnimal) {
          if (entity instanceof net.minecraft.entity.passive.EntityChicken) {
            return new CraftChicken(server, (net.minecraft.entity.passive.EntityChicken) entity);
          } else if (entity instanceof net.minecraft.entity.passive.EntityCow) {
            if (entity instanceof net.minecraft.entity.passive.EntityMooshroom) {
              return new CraftMushroomCow(
                  server, (net.minecraft.entity.passive.EntityMooshroom) entity);
            } else {
              return new CraftCow(server, (net.minecraft.entity.passive.EntityCow) entity);
            }
          } else if (entity instanceof net.minecraft.entity.passive.EntityPig) {
            return new CraftPig(server, (net.minecraft.entity.passive.EntityPig) entity);
          } else if (entity instanceof net.minecraft.entity.passive.EntityTameable) {
            if (entity instanceof net.minecraft.entity.passive.EntityWolf) {
              return new CraftWolf(server, (net.minecraft.entity.passive.EntityWolf) entity);
            } else if (entity instanceof net.minecraft.entity.passive.EntityOcelot) {
              return new CraftOcelot(server, (net.minecraft.entity.passive.EntityOcelot) entity);
            } // Cauldron
            else {
              return new CraftTameableAnimal(
                  server, (net.minecraft.entity.passive.EntityTameable) entity);
            } // Cauldron
          } else if (entity instanceof net.minecraft.entity.passive.EntitySheep) {
            return new CraftSheep(server, (net.minecraft.entity.passive.EntitySheep) entity);
          } else if (entity instanceof net.minecraft.entity.passive.EntityHorse) {
            return new CraftHorse(server, (net.minecraft.entity.passive.EntityHorse) entity);
          } else {
            return new CraftAnimals(server, (net.minecraft.entity.passive.EntityAnimal) entity);
          }
        }
        // Monsters
        else if (entity instanceof net.minecraft.entity.monster.EntityMob) {
          if (entity instanceof net.minecraft.entity.monster.EntityZombie) {
            if (entity instanceof net.minecraft.entity.monster.EntityPigZombie) {
              return new CraftPigZombie(
                  server, (net.minecraft.entity.monster.EntityPigZombie) entity);
            } else {
              return new CraftZombie(server, (net.minecraft.entity.monster.EntityZombie) entity);
            }
          } else if (entity instanceof net.minecraft.entity.monster.EntityCreeper) {
            return new CraftCreeper(server, (net.minecraft.entity.monster.EntityCreeper) entity);
          } else if (entity instanceof net.minecraft.entity.monster.EntityEnderman) {
            return new CraftEnderman(server, (net.minecraft.entity.monster.EntityEnderman) entity);
          } else if (entity instanceof net.minecraft.entity.monster.EntitySilverfish) {
            return new CraftSilverfish(
                server, (net.minecraft.entity.monster.EntitySilverfish) entity);
          } else if (entity instanceof net.minecraft.entity.monster.EntityGiantZombie) {
            return new CraftGiant(server, (net.minecraft.entity.monster.EntityGiantZombie) entity);
          } else if (entity instanceof net.minecraft.entity.monster.EntitySkeleton) {
            return new CraftSkeleton(server, (net.minecraft.entity.monster.EntitySkeleton) entity);
          } else if (entity instanceof net.minecraft.entity.monster.EntityBlaze) {
            return new CraftBlaze(server, (net.minecraft.entity.monster.EntityBlaze) entity);
          } else if (entity instanceof net.minecraft.entity.monster.EntityWitch) {
            return new CraftWitch(server, (net.minecraft.entity.monster.EntityWitch) entity);
          } else if (entity instanceof net.minecraft.entity.boss.EntityWither) {
            return new CraftWither(server, (net.minecraft.entity.boss.EntityWither) entity);
          } else if (entity instanceof net.minecraft.entity.monster.EntitySpider) {
            if (entity instanceof net.minecraft.entity.monster.EntityCaveSpider) {
              return new CraftCaveSpider(
                  server, (net.minecraft.entity.monster.EntityCaveSpider) entity);
            } else {
              return new CraftSpider(server, (net.minecraft.entity.monster.EntitySpider) entity);
            }
          } else {
            return new CraftMonster(server, (net.minecraft.entity.monster.EntityMob) entity);
          }
        }
        // Water Animals
        else if (entity instanceof net.minecraft.entity.passive.EntityWaterMob) {
          if (entity instanceof net.minecraft.entity.passive.EntitySquid) {
            return new CraftSquid(server, (net.minecraft.entity.passive.EntitySquid) entity);
          } else {
            return new CraftWaterMob(server, (net.minecraft.entity.passive.EntityWaterMob) entity);
          }
        } else if (entity instanceof net.minecraft.entity.monster.EntityGolem) {
          if (entity instanceof net.minecraft.entity.monster.EntitySnowman) {
            return new CraftSnowman(server, (net.minecraft.entity.monster.EntitySnowman) entity);
          } else if (entity instanceof net.minecraft.entity.monster.EntityIronGolem) {
            return new CraftIronGolem(
                server, (net.minecraft.entity.monster.EntityIronGolem) entity);
          } else {
            return new CraftLivingEntity(server, (net.minecraft.entity.EntityLivingBase) entity);
          } // Cauldron
        } else if (entity instanceof net.minecraft.entity.passive.EntityVillager) {
          return new CraftVillager(server, (net.minecraft.entity.passive.EntityVillager) entity);
        } else {
          return new CraftCreature(server, (net.minecraft.entity.EntityCreature) entity);
        }
      }
      // Slimes are a special (and broken) case
      else if (entity instanceof net.minecraft.entity.monster.EntitySlime) {
        if (entity instanceof net.minecraft.entity.monster.EntityMagmaCube) {
          return new CraftMagmaCube(server, (net.minecraft.entity.monster.EntityMagmaCube) entity);
        } else {
          return new CraftSlime(server, (net.minecraft.entity.monster.EntitySlime) entity);
        }
      }
      // Flying
      else if (entity instanceof net.minecraft.entity.EntityFlying) {
        if (entity instanceof net.minecraft.entity.monster.EntityGhast) {
          return new CraftGhast(server, (net.minecraft.entity.monster.EntityGhast) entity);
        } else {
          return new CraftFlying(server, (net.minecraft.entity.EntityFlying) entity);
        }
      } else if (entity instanceof net.minecraft.entity.boss.EntityDragon) {
        return new CraftEnderDragon(server, (net.minecraft.entity.boss.EntityDragon) entity);
      }
      // Ambient
      else if (entity instanceof net.minecraft.entity.passive.EntityAmbientCreature) {
        if (entity instanceof net.minecraft.entity.passive.EntityBat) {
          return new CraftBat(server, (net.minecraft.entity.passive.EntityBat) entity);
        } else {
          return new CraftAmbient(
              server, (net.minecraft.entity.passive.EntityAmbientCreature) entity);
        }
      } else {
        return new CraftLivingEntity(server, (net.minecraft.entity.EntityLivingBase) entity);
      }
    } else if (entity instanceof net.minecraft.entity.boss.EntityDragonPart) {
      net.minecraft.entity.boss.EntityDragonPart part =
          (net.minecraft.entity.boss.EntityDragonPart) entity;
      if (part.entityDragonObj instanceof net.minecraft.entity.boss.EntityDragon) {
        return new CraftEnderDragonPart(
            server, (net.minecraft.entity.boss.EntityDragonPart) entity);
      } else {
        return new CraftComplexPart(server, (net.minecraft.entity.boss.EntityDragonPart) entity);
      }
    } else if (entity instanceof net.minecraft.entity.item.EntityXPOrb) {
      return new CraftExperienceOrb(server, (net.minecraft.entity.item.EntityXPOrb) entity);
    } else if (entity instanceof net.minecraft.entity.projectile.EntityArrow) {
      return new CraftArrow(server, (net.minecraft.entity.projectile.EntityArrow) entity);
    } else if (entity instanceof net.minecraft.entity.item.EntityBoat) {
      return new CraftBoat(server, (net.minecraft.entity.item.EntityBoat) entity);
    } else if (entity instanceof net.minecraft.entity.projectile.EntityThrowable) {
      if (entity instanceof net.minecraft.entity.projectile.EntityEgg) {
        return new CraftEgg(server, (net.minecraft.entity.projectile.EntityEgg) entity);
      } else if (entity instanceof net.minecraft.entity.projectile.EntitySnowball) {
        return new CraftSnowball(server, (net.minecraft.entity.projectile.EntitySnowball) entity);
      } else if (entity instanceof net.minecraft.entity.projectile.EntityPotion) {
        return new CraftThrownPotion(server, (net.minecraft.entity.projectile.EntityPotion) entity);
      } else if (entity instanceof net.minecraft.entity.item.EntityEnderPearl) {
        return new CraftEnderPearl(server, (net.minecraft.entity.item.EntityEnderPearl) entity);
      } else if (entity instanceof net.minecraft.entity.item.EntityExpBottle) {
        return new CraftThrownExpBottle(server, (net.minecraft.entity.item.EntityExpBottle) entity);
      } else {
        return new CraftProjectile(
            server, (net.minecraft.entity.projectile.EntityThrowable) entity);
      } // Cauldron
    } else if (entity instanceof net.minecraft.entity.item.EntityFallingBlock) {
      return new CraftFallingSand(server, (net.minecraft.entity.item.EntityFallingBlock) entity);
    } else if (entity instanceof net.minecraft.entity.projectile.EntityFireball) {
      if (entity instanceof net.minecraft.entity.projectile.EntitySmallFireball) {
        return new CraftSmallFireball(
            server, (net.minecraft.entity.projectile.EntitySmallFireball) entity);
      } else if (entity instanceof net.minecraft.entity.projectile.EntityLargeFireball) {
        return new CraftLargeFireball(
            server, (net.minecraft.entity.projectile.EntityLargeFireball) entity);
      } else if (entity instanceof net.minecraft.entity.projectile.EntityWitherSkull) {
        return new CraftWitherSkull(
            server, (net.minecraft.entity.projectile.EntityWitherSkull) entity);
      } else {
        return new CraftFireball(server, (net.minecraft.entity.projectile.EntityFireball) entity);
      }
    } else if (entity instanceof net.minecraft.entity.item.EntityEnderEye) {
      return new CraftEnderSignal(server, (net.minecraft.entity.item.EntityEnderEye) entity);
    } else if (entity instanceof net.minecraft.entity.item.EntityEnderCrystal) {
      return new CraftEnderCrystal(server, (net.minecraft.entity.item.EntityEnderCrystal) entity);
    } else if (entity instanceof net.minecraft.entity.projectile.EntityFishHook) {
      return new CraftFish(server, (net.minecraft.entity.projectile.EntityFishHook) entity);
    } else if (entity instanceof net.minecraft.entity.item.EntityItem) {
      return new CraftItem(server, (net.minecraft.entity.item.EntityItem) entity);
    } else if (entity instanceof net.minecraft.entity.effect.EntityWeatherEffect) {
      if (entity instanceof net.minecraft.entity.effect.EntityLightningBolt) {
        return new CraftLightningStrike(
            server, (net.minecraft.entity.effect.EntityLightningBolt) entity);
      } else {
        return new CraftWeather(server, (net.minecraft.entity.effect.EntityWeatherEffect) entity);
      }
    } else if (entity instanceof net.minecraft.entity.item.EntityMinecart) {
      if (entity instanceof net.minecraft.entity.item.EntityMinecartFurnace) {
        return new CraftMinecartFurnace(
            server, (net.minecraft.entity.item.EntityMinecartFurnace) entity);
      } else if (entity instanceof net.minecraft.entity.item.EntityMinecartChest) {
        return new CraftMinecartChest(
            server, (net.minecraft.entity.item.EntityMinecartChest) entity);
      } else if (entity instanceof net.minecraft.entity.item.EntityMinecartTNT) {
        return new CraftMinecartTNT(server, (net.minecraft.entity.item.EntityMinecartTNT) entity);
      } else if (entity instanceof net.minecraft.entity.item.EntityMinecartHopper) {
        return new CraftMinecartHopper(
            server, (net.minecraft.entity.item.EntityMinecartHopper) entity);
      } else if (entity instanceof net.minecraft.entity.ai.EntityMinecartMobSpawner) {
        return new CraftMinecartMobSpawner(
            server, (net.minecraft.entity.ai.EntityMinecartMobSpawner) entity);
      } else if (entity instanceof net.minecraft.entity.item.EntityMinecartEmpty) {
        return new CraftMinecartRideable(
            server, (net.minecraft.entity.item.EntityMinecartEmpty) entity);
      } else if (entity instanceof net.minecraft.entity.EntityMinecartCommandBlock) {
        return new CraftMinecartCommand(
            server, (net.minecraft.entity.EntityMinecartCommandBlock) entity);
      } else {
        return new CraftMinecart(server, (net.minecraft.entity.item.EntityMinecart) entity);
      } // Cauldron - other minecarts (Steve's Carts)
    } else if (entity instanceof net.minecraft.entity.EntityHanging) {
      if (entity instanceof net.minecraft.entity.item.EntityPainting) {
        return new CraftPainting(server, (net.minecraft.entity.item.EntityPainting) entity);
      } else if (entity instanceof net.minecraft.entity.item.EntityItemFrame) {
        return new CraftItemFrame(server, (net.minecraft.entity.item.EntityItemFrame) entity);
      } else if (entity instanceof net.minecraft.entity.EntityLeashKnot) {
        return new CraftLeash(server, (net.minecraft.entity.EntityLeashKnot) entity);
      } else {
        return new CraftHanging(server, (net.minecraft.entity.EntityHanging) entity);
      }
    } else if (entity instanceof net.minecraft.entity.item.EntityTNTPrimed) {
      return new CraftTNTPrimed(server, (net.minecraft.entity.item.EntityTNTPrimed) entity);
    } else if (entity instanceof net.minecraft.entity.item.EntityFireworkRocket) {
      return new CraftFirework(server, (net.minecraft.entity.item.EntityFireworkRocket) entity);
    }
    // Cauldron - used for custom entities that extend Entity directly
    else if (entity instanceof net.minecraft.entity.Entity) {
      return new CraftCustomEntity(server, (net.minecraft.entity.Entity) entity);
    }

    throw new AssertionError(
        "Unknown entity " + entity == null
            ? null
            : entity.getClass()
                + ": "
                + entity); // Cauldron - show the entity that caused exception
  }
 private WeakReference<EntityPlayer> createNewPlayer(WorldServer world) {
   EntityPlayer player = FakePlayerFactory.get(world, gameProfile);
   return new WeakReference<EntityPlayer>(player);
 }
Пример #4
0
 public static boolean func_150919_a(ItemStack stack, World worldIn, int x, int y, int z) {
   if (worldIn instanceof WorldServer)
     return applyBonemeal(
         stack, worldIn, x, y, z, FakePlayerFactory.getMinecraft((WorldServer) worldIn));
   return false;
 }