Java 类cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration 实例源码

项目:RuneCraftery    文件:EntitySpawnPacket.java   
@Override
public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
    NetworkModHandler nmh = handler.findNetworkModHandler(networkId);
    ModContainer mc = nmh.getContainer();

    EntityRegistration registration = EntityRegistry.instance().lookupModSpawn(mc, modEntityId);
    if (registration == null || registration.getEntityClass() == null)
    {
        FMLLog.log(Level.WARNING, "Missing mod entity information for %s : %d", mc.getModId(), modEntityId);
        return;
    }


    Entity entity = FMLCommonHandler.instance().spawnEntityIntoClientWorld(registration, this);
}
项目:RuneCraftery    文件:EntityRegistry.java   
public EntityRegistration lookupModSpawn(Class<? extends Entity> clazz, boolean keepLooking)
{
    Class<?> localClazz = clazz;

    do
    {
        EntityRegistration er = entityClassRegistrations.get(localClazz);
        if (er != null)
        {
            return er;
        }
        localClazz = localClazz.getSuperclass();
        keepLooking = (!Object.class.equals(localClazz));
    }
    while (keepLooking);

    return null;
}
项目:RuneCraftery    文件:EntitySpawnPacket.java   
@Override
public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
    NetworkModHandler nmh = handler.findNetworkModHandler(networkId);
    ModContainer mc = nmh.getContainer();

    EntityRegistration registration = EntityRegistry.instance().lookupModSpawn(mc, modEntityId);
    if (registration == null || registration.getEntityClass() == null)
    {
        FMLLog.log(Level.WARNING, "Missing mod entity information for %s : %d", mc.getModId(), modEntityId);
        return;
    }


    Entity entity = FMLCommonHandler.instance().spawnEntityIntoClientWorld(registration, this);
}
项目:RuneCraftery    文件:EntityRegistry.java   
public EntityRegistration lookupModSpawn(Class<? extends Entity> clazz, boolean keepLooking)
{
    Class<?> localClazz = clazz;

    do
    {
        EntityRegistration er = entityClassRegistrations.get(localClazz);
        if (er != null)
        {
            return er;
        }
        localClazz = localClazz.getSuperclass();
        keepLooking = (!Object.class.equals(localClazz));
    }
    while (keepLooking);

    return null;
}
项目:BetterNutritionMod    文件:EntitySpawnPacket.java   
@Override
public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
    NetworkModHandler nmh = handler.findNetworkModHandler(networkId);
    ModContainer mc = nmh.getContainer();

    EntityRegistration registration = EntityRegistry.instance().lookupModSpawn(mc, modEntityId);
    if (registration == null || registration.getEntityClass() == null)
    {
        FMLLog.log(Level.WARNING, "Missing mod entity information for %s : %d", mc.getModId(), modEntityId);
        return;
    }


    Entity entity = FMLCommonHandler.instance().spawnEntityIntoClientWorld(registration, this);
}
项目:BetterNutritionMod    文件:EntityRegistry.java   
public EntityRegistration lookupModSpawn(Class<? extends Entity> clazz, boolean keepLooking)
{
    Class<?> localClazz = clazz;

    do
    {
        EntityRegistration er = entityClassRegistrations.get(localClazz);
        if (er != null)
        {
            return er;
        }
        localClazz = localClazz.getSuperclass();
        keepLooking = (!Object.class.equals(localClazz));
    }
    while (keepLooking);

    return null;
}
项目:TRHS_Club_Mod_2016    文件:FMLNetworkHandler.java   
public static Packet getEntitySpawningPacket(Entity entity)
{
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false);
    if (er == null)
    {
        return null;
    }
    if (er.usesVanillaSpawning())
    {
        return null;
    }

    return channelPair.get(Side.SERVER).generatePacketFrom(new FMLMessage.EntitySpawnMessage(er, entity, er.getContainer()));
}
项目:CauldronGit    文件:FMLNetworkHandler.java   
public static Packet getEntitySpawningPacket(Entity entity)
{
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false);
    if (er == null)
    {
        return null;
    }
    if (er.usesVanillaSpawning())
    {
        return null;
    }

    return channelPair.get(Side.SERVER).generatePacketFrom(new FMLMessage.EntitySpawnMessage(er, entity, er.getContainer()));
}
项目:NEI-Integration    文件:EntityDumper.java   
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();

    List<Integer> ids = new ArrayList<Integer>();
    ids.addAll(EntityList.IDtoClassMapping.keySet());
    Collections.sort(ids);

    for (int id : ids) {
        list.add(new String[] { GLOBAL, String.valueOf(id), EntityList.getStringFromID(id), EntityList.getClassFromID(id).getName() });
    }

    ListMultimap<ModContainer, EntityRegistration> modEntities = ReflectionHelper.getPrivateValue(EntityRegistry.class, EntityRegistry.instance(), "entityRegistrations");

    for (Entry<ModContainer, EntityRegistration> e : modEntities.entries()) {
        EntityRegistration er = e.getValue();
        list.add(new String[] { e.getKey().getModId(), String.valueOf(er.getModEntityId()), e.getKey().getModId() + "." + er.getEntityName(), er.getEntityClass().getName() });
    }

    Collections.sort(list, new Comparator<String[]>() {
        @Override
        public int compare(String[] s1, String[] s2) {
            if (s1[0].equals(GLOBAL) && !s1[0].equals(s2[0])) {
                return -1;
            }
            int i = s1[0].compareTo(s2[0]);
            if (i != 0) {
                return i;
            }
            return Integer.compare(Integer.valueOf(s1[1]), Integer.valueOf(s2[1]));
        }
    });

    return list;
}
项目:Cauldron    文件:FMLNetworkHandler.java   
public static Packet getEntitySpawningPacket(Entity entity)
{
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false);
    if (er == null)
    {
        return null;
    }
    if (er.usesVanillaSpawning())
    {
        return null;
    }

    return channelPair.get(Side.SERVER).generatePacketFrom(new FMLMessage.EntitySpawnMessage(er, entity, er.getContainer()));
}
项目:Cauldron    文件:FMLNetworkHandler.java   
public static Packet getEntitySpawningPacket(Entity entity)
{
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false);
    if (er == null)
    {
        return null;
    }
    if (er.usesVanillaSpawning())
    {
        return null;
    }

    return channelPair.get(Side.SERVER).generatePacketFrom(new FMLMessage.EntitySpawnMessage(er, entity, er.getContainer()));
}
项目:Cauldron    文件:FMLNetworkHandler.java   
public static Packet getEntitySpawningPacket(Entity entity)
{
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false);
    if (er == null)
    {
        return null;
    }
    if (er.usesVanillaSpawning())
    {
        return null;
    }

    return channelPair.get(Side.SERVER).generatePacketFrom(new FMLMessage.EntitySpawnMessage(er, entity, er.getContainer()));
}
项目:RuneCraftery    文件:FMLNetworkHandler.java   
public static Packet getEntitySpawningPacket(Entity entity)
{
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false);
    if (er == null)
    {
        return null;
    }
    if (er.usesVanillaSpawning())
    {
        return null;
    }
    return PacketDispatcher.getPacket("FML", FMLPacket.makePacket(Type.ENTITYSPAWN, er, entity, instance().findNetworkModHandler(er.getContainer())));
}
项目:RuneCraftery    文件:EntityRegistry.java   
public EntityRegistration(ModContainer mc, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    this.container = mc;
    this.entityClass = entityClass;
    this.entityName = entityName;
    this.modId = id;
    this.trackingRange = trackingRange;
    this.updateFrequency = updateFrequency;
    this.sendsVelocityUpdates = sendsVelocityUpdates;
}
项目:RuneCraftery    文件:EntityRegistry.java   
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
    EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates);
    try
    {
        entityClassRegistrations.put(entityClass, er);
        entityNames.put(entityName, mc);
        if (!EntityList.field_75626_c.containsKey(entityClass))
        {
            String entityModName = String.format("%s.%s", mc.getModId(), entityName);
            EntityList.field_75626_c.put(entityClass, entityModName);
            EntityList.field_75625_b.put(entityModName, entityClass);
            FMLLog.finest("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName);
        }
        else
        {
            FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName());
        }
    }
    catch (IllegalArgumentException e)
    {
        FMLLog.log(Level.WARNING, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName());
        return;
    }
    entityRegistrations.put(mc, er);
}
项目:RuneCraftery    文件:EntityRegistry.java   
public EntityRegistration lookupModSpawn(ModContainer mc, int modEntityId)
{
    for (EntityRegistration er : entityRegistrations.get(mc))
    {
        if (er.getModEntityId() == modEntityId)
        {
            return er;
        }
    }
    return null;
}
项目:RuneCraftery    文件:EntityRegistry.java   
public boolean tryTrackingEntity(EntityTracker entityTracker, Entity entity)
{

    EntityRegistration er = lookupModSpawn(entity.getClass(), true);
    if (er != null)
    {
        entityTracker.func_72785_a(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates());
        return true;
    }
    return false;
}
项目:RuneCraftery    文件:EntityRegistry.java   
/**
 *
 * DO NOT USE THIS METHOD
 *
 * @param entityClass
 * @param entityTypeId
 * @param updateRange
 * @param updateInterval
 * @param sendVelocityInfo
 */
@Deprecated
public static EntityRegistration registerModLoaderEntity(Object mod, Class<? extends Entity> entityClass, int entityTypeId, int updateRange, int updateInterval,
        boolean sendVelocityInfo)
{
    String entityName = (String) EntityList.field_75626_c.get(entityClass);
    if (entityName == null)
    {
        throw new IllegalArgumentException(String.format("The ModLoader mod %s has tried to register an entity tracker for a non-existent entity type %s", Loader.instance().activeModContainer().getModId(), entityClass.getCanonicalName()));
    }
    instance().doModEntityRegistration(entityClass, entityName, entityTypeId, mod, updateRange, updateInterval, sendVelocityInfo);
    return instance().entityClassRegistrations.get(entityClass);
}
项目:RuneCraftery    文件:FMLNetworkHandler.java   
public static Packet getEntitySpawningPacket(Entity entity)
{
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false);
    if (er == null)
    {
        return null;
    }
    if (er.usesVanillaSpawning())
    {
        return null;
    }
    return PacketDispatcher.getPacket("FML", FMLPacket.makePacket(Type.ENTITYSPAWN, er, entity, instance().findNetworkModHandler(er.getContainer())));
}
项目:RuneCraftery    文件:EntityRegistry.java   
public EntityRegistration(ModContainer mc, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    this.container = mc;
    this.entityClass = entityClass;
    this.entityName = entityName;
    this.modId = id;
    this.trackingRange = trackingRange;
    this.updateFrequency = updateFrequency;
    this.sendsVelocityUpdates = sendsVelocityUpdates;
}
项目:RuneCraftery    文件:EntityRegistry.java   
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
    EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates);
    try
    {
        entityClassRegistrations.put(entityClass, er);
        entityNames.put(entityName, mc);
        if (!EntityList.classToStringMapping.containsKey(entityClass))
        {
            String entityModName = String.format("%s.%s", mc.getModId(), entityName);
            EntityList.classToStringMapping.put(entityClass, entityModName);
            EntityList.stringToClassMapping.put(entityModName, entityClass);
            FMLLog.finest("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName);
        }
        else
        {
            FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName());
        }
    }
    catch (IllegalArgumentException e)
    {
        FMLLog.log(Level.WARNING, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName());
        return;
    }
    entityRegistrations.put(mc, er);
}
项目:RuneCraftery    文件:EntityRegistry.java   
public EntityRegistration lookupModSpawn(ModContainer mc, int modEntityId)
{
    for (EntityRegistration er : entityRegistrations.get(mc))
    {
        if (er.getModEntityId() == modEntityId)
        {
            return er;
        }
    }
    return null;
}
项目:RuneCraftery    文件:EntityRegistry.java   
public boolean tryTrackingEntity(EntityTracker entityTracker, Entity entity)
{

    EntityRegistration er = lookupModSpawn(entity.getClass(), true);
    if (er != null)
    {
        entityTracker.addEntityToTracker(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates());
        return true;
    }
    return false;
}
项目:RuneCraftery    文件:EntityRegistry.java   
/**
 *
 * DO NOT USE THIS METHOD
 *
 * @param entityClass
 * @param entityTypeId
 * @param updateRange
 * @param updateInterval
 * @param sendVelocityInfo
 */
@Deprecated
public static EntityRegistration registerModLoaderEntity(Object mod, Class<? extends Entity> entityClass, int entityTypeId, int updateRange, int updateInterval,
        boolean sendVelocityInfo)
{
    String entityName = (String) EntityList.classToStringMapping.get(entityClass);
    if (entityName == null)
    {
        throw new IllegalArgumentException(String.format("The ModLoader mod %s has tried to register an entity tracker for a non-existent entity type %s", Loader.instance().activeModContainer().getModId(), entityClass.getCanonicalName()));
    }
    instance().doModEntityRegistration(entityClass, entityName, entityTypeId, mod, updateRange, updateInterval, sendVelocityInfo);
    return instance().entityClassRegistrations.get(entityClass);
}
项目:BetterNutritionMod    文件:FMLNetworkHandler.java   
public static Packet getEntitySpawningPacket(Entity entity)
{
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false);
    if (er == null)
    {
        return null;
    }
    if (er.usesVanillaSpawning())
    {
        return null;
    }
    return PacketDispatcher.getPacket("FML", FMLPacket.makePacket(Type.ENTITYSPAWN, er, entity, instance().findNetworkModHandler(er.getContainer())));
}
项目:BetterNutritionMod    文件:EntityRegistry.java   
public EntityRegistration(ModContainer mc, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    this.container = mc;
    this.entityClass = entityClass;
    this.entityName = entityName;
    this.modId = id;
    this.trackingRange = trackingRange;
    this.updateFrequency = updateFrequency;
    this.sendsVelocityUpdates = sendsVelocityUpdates;
}
项目:BetterNutritionMod    文件:EntityRegistry.java   
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
    EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates);
    try
    {
        entityClassRegistrations.put(entityClass, er);
        entityNames.put(entityName, mc);
        if (!EntityList.classToStringMapping.containsKey(entityClass))
        {
            String entityModName = String.format("%s.%s", mc.getModId(), entityName);
            EntityList.classToStringMapping.put(entityClass, entityModName);
            EntityList.stringToClassMapping.put(entityModName, entityClass);
            FMLLog.finest("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName);
        }
        else
        {
            FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName());
        }
    }
    catch (IllegalArgumentException e)
    {
        FMLLog.log(Level.WARNING, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName());
        return;
    }
    entityRegistrations.put(mc, er);
}
项目:BetterNutritionMod    文件:EntityRegistry.java   
public EntityRegistration lookupModSpawn(ModContainer mc, int modEntityId)
{
    for (EntityRegistration er : entityRegistrations.get(mc))
    {
        if (er.getModEntityId() == modEntityId)
        {
            return er;
        }
    }
    return null;
}
项目:BetterNutritionMod    文件:EntityRegistry.java   
public boolean tryTrackingEntity(EntityTracker entityTracker, Entity entity)
{

    EntityRegistration er = lookupModSpawn(entity.getClass(), true);
    if (er != null)
    {
        entityTracker.addEntityToTracker(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates());
        return true;
    }
    return false;
}
项目:BetterNutritionMod    文件:EntityRegistry.java   
/**
 *
 * DO NOT USE THIS METHOD
 *
 * @param entityClass
 * @param entityTypeId
 * @param updateRange
 * @param updateInterval
 * @param sendVelocityInfo
 */
@Deprecated
public static EntityRegistration registerModLoaderEntity(Object mod, Class<? extends Entity> entityClass, int entityTypeId, int updateRange, int updateInterval,
        boolean sendVelocityInfo)
{
    String entityName = (String) EntityList.classToStringMapping.get(entityClass);
    if (entityName == null)
    {
        throw new IllegalArgumentException(String.format("The ModLoader mod %s has tried to register an entity tracker for a non-existent entity type %s", Loader.instance().activeModContainer().getModId(), entityClass.getCanonicalName()));
    }
    instance().doModEntityRegistration(entityClass, entityName, entityTypeId, mod, updateRange, updateInterval, sendVelocityInfo);
    return instance().entityClassRegistrations.get(entityClass);
}
项目:MobSpawnControls2    文件:ModEntityRecognizer.java   
@SuppressWarnings("unchecked")
public static List<Class<? extends EntityLiving>> getEntityClasses(ModContainer c) {
    if (c == null)
        return getVanillaEntityClasses();
    List<EntityRegistration> regs = getRegistrations(c);
    List<Class<? extends EntityLiving>> cls = new ArrayList<Class<? extends EntityLiving>>(regs.size());
    for (EntityRegistration r : regs) {
        if (isValidEntityClass(r.getEntityClass()))
            cls.add((Class<? extends EntityLiving>) r.getEntityClass());
    }
    return cls;
}
项目:TRHS_Club_Mod_2016    文件:FMLMessage.java   
public EntitySpawnMessage(EntityRegistration er, Entity entity, ModContainer modContainer)
{
    super(entity);
    modId = modContainer.getModId();
    modEntityTypeId = er.getModEntityId();
}
项目:TRHS_Club_Mod_2016    文件:EntitySpawnHandler.java   
private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg)
{
    ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId);
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId);
    if (er == null)
    {
        throw new RuntimeException( "Could not spawn mod entity ModID: " + spawnMsg.modId + " EntityID: " + spawnMsg.modEntityTypeId +
                " at ( " + spawnMsg.scaledX + "," + spawnMsg.scaledY + ", " + spawnMsg.scaledZ + ") Please contact mod author or server admin.");
    }
    WorldClient wc = FMLClientHandler.instance().getWorldClient();
    Class<? extends Entity> cls = er.getEntityClass();
    try
    {
        Entity entity;
        if (er.hasCustomSpawning())
        {
            entity = er.doCustomSpawning(spawnMsg);
        } else
        {
            entity = (Entity) (cls.getConstructor(World.class).newInstance(wc));

            int offset = spawnMsg.entityId - entity.func_145782_y();
            entity.func_145769_d(spawnMsg.entityId);
            entity.func_70012_b(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch);
            if (entity instanceof EntityLiving)
            {
                ((EntityLiving) entity).field_70759_as = spawnMsg.scaledHeadYaw;
            }

            Entity parts[] = entity.func_70021_al();
            if (parts != null)
            {
                for (int j = 0; j < parts.length; j++)
                {
                    parts[j].func_145769_d(parts[j].func_145782_y() + offset);
                }
            }
        }

        entity.field_70118_ct = spawnMsg.rawX;
        entity.field_70117_cu = spawnMsg.rawY;
        entity.field_70116_cv = spawnMsg.rawZ;

        EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
        if (entity instanceof IThrowableEntity)
        {
            Entity thrower = clientPlayer.func_145782_y() == spawnMsg.throwerId ? clientPlayer : wc.func_73045_a(spawnMsg.throwerId);
            ((IThrowableEntity) entity).setThrower(thrower);
        }

        if (spawnMsg.dataWatcherList != null)
        {
            entity.func_70096_w().func_75687_a((List<?>) spawnMsg.dataWatcherList);
        }

        if (spawnMsg.throwerId > 0)
        {
            entity.func_70016_h(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ);
        }

        if (entity instanceof IEntityAdditionalSpawnData)
        {
            ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
        }
        wc.func_73027_a(spawnMsg.entityId, entity);
    } catch (Exception e)
    {
        FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity at ( " + spawnMsg.scaledX + "," + spawnMsg.scaledY + ", " + spawnMsg.scaledZ +")");
        throw Throwables.propagate(e);
    }
}
项目:CauldronGit    文件:FMLMessage.java   
public EntitySpawnMessage(EntityRegistration er, Entity entity, ModContainer modContainer)
{
    super(entity);
    modId = modContainer.getModId();
    modEntityTypeId = er.getModEntityId();
}
项目:CauldronGit    文件:EntitySpawnHandler.java   
private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg)
{
    ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId);
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId);
    WorldClient wc = FMLClientHandler.instance().getWorldClient();
    Class<? extends Entity> cls = er.getEntityClass();
    try
    {
        Entity entity;
        if (er.hasCustomSpawning())
        {
            entity = er.doCustomSpawning(spawnMsg);
        } else
        {
            entity = (Entity) (cls.getConstructor(World.class).newInstance(wc));

            int offset = spawnMsg.entityId - entity.getEntityId();
            entity.setEntityId(spawnMsg.entityId);
            entity.setLocationAndAngles(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch);
            if (entity instanceof EntityLiving)
            {
                ((EntityLiving) entity).rotationYawHead = spawnMsg.scaledHeadYaw;
            }

            Entity parts[] = entity.getParts();
            if (parts != null)
            {
                for (int j = 0; j < parts.length; j++)
                {
                    parts[j].setEntityId(parts[j].getEntityId() + offset);
                }
            }
        }

        entity.serverPosX = spawnMsg.rawX;
        entity.serverPosY = spawnMsg.rawY;
        entity.serverPosZ = spawnMsg.rawZ;

        EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
        if (entity instanceof IThrowableEntity)
        {
            Entity thrower = clientPlayer.getEntityId() == spawnMsg.throwerId ? clientPlayer : wc.getEntityByID(spawnMsg.throwerId);
            ((IThrowableEntity) entity).setThrower(thrower);
        }

        if (spawnMsg.dataWatcherList != null)
        {
            entity.getDataWatcher().updateWatchedObjectsFromList((List<?>) spawnMsg.dataWatcherList);
        }

        if (spawnMsg.throwerId > 0)
        {
            entity.setVelocity(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ);
        }

        if (entity instanceof IEntityAdditionalSpawnData)
        {
            ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
        }
        wc.addEntityToWorld(spawnMsg.entityId, entity);
    } catch (Exception e)
    {
        FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity");
        throw Throwables.propagate(e);
    }
}
项目:Cauldron    文件:FMLMessage.java   
public EntitySpawnMessage(EntityRegistration er, Entity entity, ModContainer modContainer)
{
    super(entity);
    modId = modContainer.getModId();
    modEntityTypeId = er.getModEntityId();
}
项目:Cauldron    文件:EntitySpawnHandler.java   
private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg)
{
    ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId);
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId);
    WorldClient wc = FMLClientHandler.instance().getWorldClient();
    Class<? extends Entity> cls = er.getEntityClass();
    try
    {
        Entity entity;
        if (er.hasCustomSpawning())
        {
            entity = er.doCustomSpawning(spawnMsg);
        } else
        {
            entity = (Entity) (cls.getConstructor(World.class).newInstance(wc));

            int offset = spawnMsg.entityId - entity.getEntityId();
            entity.setEntityId(spawnMsg.entityId);
            entity.setLocationAndAngles(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch);
            if (entity instanceof EntityLiving)
            {
                ((EntityLiving) entity).rotationYawHead = spawnMsg.scaledHeadYaw;
            }

            Entity parts[] = entity.getParts();
            if (parts != null)
            {
                for (int j = 0; j < parts.length; j++)
                {
                    parts[j].setEntityId(parts[j].getEntityId() + offset);
                }
            }
        }

        entity.serverPosX = spawnMsg.rawX;
        entity.serverPosY = spawnMsg.rawY;
        entity.serverPosZ = spawnMsg.rawZ;

        EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
        if (entity instanceof IThrowableEntity)
        {
            Entity thrower = clientPlayer.getEntityId() == spawnMsg.throwerId ? clientPlayer : wc.getEntityByID(spawnMsg.throwerId);
            ((IThrowableEntity) entity).setThrower(thrower);
        }

        if (spawnMsg.dataWatcherList != null)
        {
            entity.getDataWatcher().updateWatchedObjectsFromList((List<?>) spawnMsg.dataWatcherList);
        }

        if (spawnMsg.throwerId > 0)
        {
            entity.setVelocity(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ);
        }

        if (entity instanceof IEntityAdditionalSpawnData)
        {
            ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
        }
        wc.addEntityToWorld(spawnMsg.entityId, entity);
    } catch (Exception e)
    {
        FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity");
        throw Throwables.propagate(e);
    }
}
项目:Cauldron    文件:FMLMessage.java   
public EntitySpawnMessage(EntityRegistration er, Entity entity, ModContainer modContainer)
{
    super(entity);
    modId = modContainer.getModId();
    modEntityTypeId = er.getModEntityId();
}
项目:Cauldron    文件:EntitySpawnHandler.java   
private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg)
{
    ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId);
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId);
    WorldClient wc = FMLClientHandler.instance().getWorldClient();
    Class<? extends Entity> cls = er.getEntityClass();
    try
    {
        Entity entity;
        if (er.hasCustomSpawning())
        {
            entity = er.doCustomSpawning(spawnMsg);
        } else
        {
            entity = (Entity) (cls.getConstructor(World.class).newInstance(wc));

            int offset = spawnMsg.entityId - entity.getEntityId();
            entity.setEntityId(spawnMsg.entityId);
            entity.setLocationAndAngles(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch);
            if (entity instanceof EntityLiving)
            {
                ((EntityLiving) entity).rotationYawHead = spawnMsg.scaledHeadYaw;
            }

            Entity parts[] = entity.getParts();
            if (parts != null)
            {
                for (int j = 0; j < parts.length; j++)
                {
                    parts[j].setEntityId(parts[j].getEntityId() + offset);
                }
            }
        }

        entity.serverPosX = spawnMsg.rawX;
        entity.serverPosY = spawnMsg.rawY;
        entity.serverPosZ = spawnMsg.rawZ;

        EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
        if (entity instanceof IThrowableEntity)
        {
            Entity thrower = clientPlayer.getEntityId() == spawnMsg.throwerId ? clientPlayer : wc.getEntityByID(spawnMsg.throwerId);
            ((IThrowableEntity) entity).setThrower(thrower);
        }

        if (spawnMsg.dataWatcherList != null)
        {
            entity.getDataWatcher().updateWatchedObjectsFromList((List<?>) spawnMsg.dataWatcherList);
        }

        if (spawnMsg.throwerId > 0)
        {
            entity.setVelocity(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ);
        }

        if (entity instanceof IEntityAdditionalSpawnData)
        {
            ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
        }
        wc.addEntityToWorld(spawnMsg.entityId, entity);
    } catch (Exception e)
    {
        FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity");
        throw Throwables.propagate(e);
    }
}
项目:Cauldron    文件:FMLMessage.java   
public EntitySpawnMessage(EntityRegistration er, Entity entity, ModContainer modContainer)
{
    super(entity);
    modId = modContainer.getModId();
    modEntityTypeId = er.getModEntityId();
}