• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EntityRegistration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration的典型用法代码示例。如果您正苦于以下问题:Java EntityRegistration类的具体用法?Java EntityRegistration怎么用?Java EntityRegistration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EntityRegistration类属于cpw.mods.fml.common.registry.EntityRegistry包,在下文中一共展示了EntityRegistration类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
@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);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:17,代码来源:EntitySpawnPacket.java


示例2: lookupModSpawn

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:19,代码来源:EntityRegistry.java


示例3: getEntitySpawningPacket

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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()));
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:15,代码来源:FMLNetworkHandler.java


示例4: dump

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
@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;
}
 
开发者ID:Tonius,项目名称:NEI-Integration,代码行数:36,代码来源:EntityDumper.java


示例5: getEntitySpawningPacket

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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())));
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:14,代码来源:FMLNetworkHandler.java


示例6: EntityRegistration

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:11,代码来源:EntityRegistry.java


示例7: doModEntityRegistration

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:28,代码来源:EntityRegistry.java


示例8: tryTrackingEntity

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:12,代码来源:EntityRegistry.java


示例9: registerModLoaderEntity

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
/**
 *
 * 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);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:23,代码来源:EntityRegistry.java


示例10: doModEntityRegistration

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:28,代码来源:EntityRegistry.java


示例11: tryTrackingEntity

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:12,代码来源:EntityRegistry.java


示例12: registerModLoaderEntity

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
/**
 *
 * 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);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:23,代码来源:EntityRegistry.java


示例13: getEntityClasses

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
@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;
}
 
开发者ID:DavidGoldman,项目名称:MobSpawnControls2,代码行数:13,代码来源:ModEntityRecognizer.java


示例14: EntitySpawnMessage

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
public EntitySpawnMessage(EntityRegistration er, Entity entity, ModContainer modContainer)
{
    super(entity);
    modId = modContainer.getModId();
    modEntityTypeId = er.getModEntityId();
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:7,代码来源:FMLMessage.java


示例15: spawnEntity

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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);
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:72,代码来源:EntitySpawnHandler.java


示例16: spawnEntity

import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; //导入依赖的package包/类
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);
    }
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:67,代码来源:EntitySpawnHandler.java



注:本文中的cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RelativeBendpoints类代码示例发布时间:2022-05-22
下一篇:
Java BoundingXYVisitor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap