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


Java EntityList.createEntityFromNBT方法代码示例

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


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

示例1: DrawPrimitive

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
/** Spawn a single entity at the specified position.
 * @param e the actual entity to be spawned.
 * @param w the world in which to spawn the entity.
 * @throws Exception
 */
private void DrawPrimitive( DrawEntity e, World w ) throws Exception
{
    String entityName = e.getType().getValue();
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    nbttagcompound.setString("id", entityName);
    Entity entity;
    try
    {
        entity = EntityList.createEntityFromNBT(nbttagcompound, w);
        if (entity != null)
        {
            positionEntity(entity, e.getX().doubleValue(), e.getY().doubleValue(), e.getZ().doubleValue(), e.getYaw().floatValue(), e.getPitch().floatValue());
            entity.setVelocity(e.getXVel().doubleValue(), e.getYVel().doubleValue(), e.getZVel().doubleValue());
            w.spawnEntityInWorld(entity);
        }
    }
    catch (RuntimeException runtimeexception)
    {
        // Cannot summon this entity.
        throw new Exception("Couldn't create entity type: " + e.getType().getValue());
    }
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:28,代码来源:BlockDrawingHelper.java

示例2: addEntitiesToWorld

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.x));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.y));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.z));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch);
                worldIn.spawnEntity(entity);
            }
        }
    }
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:39,代码来源:HarshenTemplate.java

示例3: createEntityFromNBT

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
@Nullable
protected static Entity createEntityFromNBT(NBTTagCompound compound, World worldIn)
{
    try
    {
        return EntityList.createEntityFromNBT(compound, worldIn);
    }
    catch (RuntimeException var3)
    {
        return null;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:AnvilChunkLoader.java

示例4: addEntitiesToWorld

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.xCoord));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.yCoord));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.zCoord));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, f, entity.rotationPitch);
                worldIn.spawnEntityInWorld(entity);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:39,代码来源:Template.java

示例5: readSpawnData

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
@Override
public void readSpawnData(ByteBuf additionalData) {
	if(additionalData.readableBytes() == 0)
		return;
	try {
		PacketBuffer buff = new PacketBuffer(additionalData);
		if(buff.readBoolean()) {
			profile = new GameProfile(buff.readUniqueId(), buff.readString(16));
               int l = buff.readVarInt();
               int i1 = 0;

               for (; i1 < l; ++i1)
               {
                   String s = buff.readString(32767);
                   String s1 = buff.readString(32767);

                   if (buff.readBoolean())
                   {
                   	profile.getProperties().put(s, new Property(s, s1, buff.readString(32767)));
                   }
                   else
                   {
                   	profile.getProperties().put(s, new Property(s, s1));
                   }
               }
			final NetworkPlayerInfo info = new NetworkPlayerInfo(profile);
			this.entity = new EntityOtherPlayerMP(world, profile) {
				@Nullable
			    protected NetworkPlayerInfo getPlayerInfo()
			    {
			        return info;
			    }
			};
			this.entity.readFromNBT(buff.readCompoundTag());
			/*TF2EventsCommon.THREAD_POOL.submit(()->{
			if (profile.getId() != null)
				cap.skinType = DefaultPlayerSkin.getSkinType(profile.getId());
			Minecraft.getMinecraft().getSkinManager().loadProfileTextures(profile,
					new SkinManager.SkinAvailableCallback() {
						@Override
						public void skinAvailable(Type typeIn, ResourceLocation location,
								MinecraftProfileTexture profileTexture) {
							if (typeIn == Type.SKIN) {
								if (typeIn == Type.SKIN)
									cap.skinDisguise = location;
								cap.skinType = profileTexture.getMetadata("model");

								if (cap.skinType == null)
									cap.skinType = "default";
							}
						}
					}, false);
			});*/
		}
		else
			this.entity = (EntityLivingBase) EntityList.createEntityFromNBT(buff.readCompoundTag(), this.world);
		if(this.entity == null) {
			this.setDead();
			return;
		}
		this.entity.deathTime = 0;
		this.entity.hurtTime = 0;
		this.entity.limbSwingAmount = 0.5f;
		this.entity.ticksExisted = 15;
		this.entity.limbSwing += this.rand.nextFloat()*10;
		this.setSize(this.entity.width, this.entity.height);
		this.entity.setPosition(this.posX, this.posY, this.posZ);
		//this.prevRotationYaw = this.entity.prevRotationYaw;
		//this.rotationYaw = this.entity.rotationYaw;
		this.entity.rotationYawHead = this.rotationYaw;
		this.entity.renderYawOffset = this.rotationYaw;
		this.entity.prevRenderYawOffset = this.rotationYaw;
		
		if (buff.readBoolean()) {
			WeaponsCapability.get(this.entity).state = 1;
		}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:82,代码来源:EntityStatue.java


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