当前位置: 首页>>代码示例>>Java>>正文


Java EntityList.createEntityByIDFromName方法代码示例

本文整理汇总了Java中net.minecraft.entity.EntityList.createEntityByIDFromName方法的典型用法代码示例。如果您正苦于以下问题:Java EntityList.createEntityByIDFromName方法的具体用法?Java EntityList.createEntityByIDFromName怎么用?Java EntityList.createEntityByIDFromName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.EntityList的用法示例。


在下文中一共展示了EntityList.createEntityByIDFromName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: spawnCreature

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
@Nullable

    /**
     * Spawns the creature specified by the egg's type in the location specified by the last three parameters.
     * Parameters: world, entityID, x, y, z.
     */
    public static Entity spawnCreature(World worldIn, @Nullable ResourceLocation entityID, double x, double y, double z)
    {
        if (entityID != null && EntityList.ENTITY_EGGS.containsKey(entityID))
        {
            Entity entity = null;

            for (int i = 0; i < 1; ++i)
            {
                entity = EntityList.createEntityByIDFromName(entityID, worldIn);

                if (entity instanceof EntityLiving)
                {
                    EntityLiving entityliving = (EntityLiving)entity;
                    entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(worldIn.rand.nextFloat() * 360.0F), 0.0F);
                    entityliving.rotationYawHead = entityliving.rotationYaw;
                    entityliving.renderYawOffset = entityliving.rotationYaw;
                    entityliving.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityliving)), (IEntityLivingData)null);
                    worldIn.spawnEntityInWorld(entity);
                    entityliving.playLivingSound();
                }
            }

            return entity;
        }
        else
        {
            return null;
        }
    }
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:ItemMonsterPlacer.java

示例2: spawnCreature

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
/**
 * Spawns the creature specified by the egg's type in the location specified by the last three parameters.
 * Parameters: world, entityID, x, y, z.
 */
@Nullable
public static Entity spawnCreature(World worldIn, @Nullable String entityID, double x, double y, double z)
{
    if (entityID != null && EntityList.ENTITY_EGGS.containsKey(entityID))
    {
        Entity entity = null;

        for (int i = 0; i < 1; ++i)
        {
            entity = EntityList.createEntityByIDFromName(entityID, worldIn);

            if (entity instanceof EntityLivingBase)
            {
                EntityLiving entityliving = (EntityLiving)entity;
                entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(worldIn.rand.nextFloat() * 360.0F), 0.0F);
                entityliving.rotationYawHead = entityliving.rotationYaw;
                entityliving.renderYawOffset = entityliving.rotationYaw;
                entityliving.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityliving)), (IEntityLivingData)null);
                worldIn.spawnEntityInWorld(entity);
                entityliving.playLivingSound();
            }
        }

        return entity;
    }
    else
    {
        return null;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:35,代码来源:ItemMonsterPlacer.java

示例3: getEntityFromStack

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
public Entity getEntityFromStack(ItemStack stack, World world, boolean withInfo) {
    Entity entity = EntityList.createEntityByIDFromName(new ResourceLocation(stack.getTagCompound().getString("entity")), world);
    if (withInfo) entity.readFromNBT(stack.getTagCompound());
    return entity;
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:6,代码来源:MobImprisonmentToolItem.java

示例4: initGui

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
@Override
public void initGui() {
	player = new EntityOtherPlayerMP(this.mc.world, new GameProfile(mc.player.getUniqueID(), "name"));
	for(ResourceLocation entry:ForgeRegistries.ENTITIES.getKeys()) {
		Entity entity=EntityList.createEntityByIDFromName(entry, this.mc.world);
		if(entity instanceof EntityLivingBase && ((entity.width + entity.height < 6 && entity.isNonBoss())||this.mc.player.capabilities.isCreativeMode)) {
			mobList.add((EntityLivingBase) entity);
			if(entity instanceof EntitySpy) {
				entity.getCapability(TF2weapons.WEAPONS_CAP, null).invisTicks=0;
			}
		}
	}
	Collections.sort(mobList, new Comparator<EntityLivingBase>() {

		@Override
		public int compare(EntityLivingBase o1, EntityLivingBase o2) {
			// TODO Auto-generated method stub
			return EntityList.getKey(o2).toString().compareTo(EntityList.getKey(o1).toString());
		}
		
	});
	Keyboard.enableRepeatEvents(true);
	this.playerNameField = new GuiTextField(6, this.fontRenderer, this.width / 2 + 26, this.height / 2 + 60, 108,
			19);
	this.playerNameField.setMaxStringLength(64);
	this.playerNameField.setFocused(true);
	this.buttonList.clear();
	for(int i=0;i<16;i++) {
		this.buttonList.add(new GuiButton(i, this.width / 2 - 135 + (i%2) * 70, this.height / 2 - 60+i/2*20, 70, 20,
				I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityZombie.class)), new Object[0])));
	}
	/*this.buttonList.add(new GuiButton(0, this.width / 2 - 135, this.height / 2 - 20, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityZombie.class)), new Object[0])));
	this.buttonList.add(new GuiButton(1, this.width / 2 - 65, this.height / 2 - 20, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityCreeper.class)), new Object[0])));
	this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height / 2 - 20, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityEnderman.class)), new Object[0])));
	this.buttonList.add(new GuiButton(7, this.width / 2 + 75, this.height / 2 - 20, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntitySpider.class)), new Object[0])));
	this.buttonList.add(new GuiButton(3, this.width / 2 - 135, this.height / 2 + 90, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityCow.class)), new Object[0])));
	this.buttonList.add(new GuiButton(4, this.width / 2 - 65, this.height / 2 + 90, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityPig.class)), new Object[0])));
	this.buttonList.add(new GuiButton(8, this.width / 2 + 5, this.height / 2 + 90, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityChicken.class)), new Object[0])));*/
	this.buttonList
			.add(playerDisguise = new GuiButton(30, this.width / 2 + 25, this.height / 2 + 80, 110, 20, "Player"));
	this.setButtons();

}
 
开发者ID:rafradek,项目名称:Mods,代码行数:51,代码来源:GuiDisguiseKit.java


注:本文中的net.minecraft.entity.EntityList.createEntityByIDFromName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。