Java Code Examples for net.minecraft.nbt.NBTTagCompound#setUniqueId()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#setUniqueId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LPRoutedItem.java From Logistics-Pipes-2 with MIT License | 6 votes |
public NBTTagCompound writeToNBT() { NBTTagCompound tag = new NBTTagCompound(); Triple<Double, Double, Double> pos = getPosition(); tag.setDouble("posX", pos.getFirst()); tag.setDouble("posY", pos.getSecnd()); tag.setDouble("posZ", pos.getThird()); tag.setInteger("heading", heading.ordinal()); tag.setUniqueId("UID", this.ID); tag.setTag("inventory", stack.serializeNBT()); tag.setInteger("ticks", this.ticks); NBTTagList routeList = new NBTTagList(); for(EnumFacing node : route) { NBTTagCompound nodeTag = new NBTTagCompound(); //nodeTag.setUniqueId("UID", node.getKey()); nodeTag.setInteger("heading", node.ordinal()); routeList.appendTag(nodeTag); } tag.setTag("route", routeList); return tag; }
Example 2
Source File: LPRoutedFluid.java From Logistics-Pipes-2 with MIT License | 6 votes |
public NBTTagCompound writeToNBT() { NBTTagCompound tag = new NBTTagCompound(); Triple<Double, Double, Double> pos = getPosition(); tag.setDouble("posX", pos.getFirst()); tag.setDouble("posY", pos.getSecnd()); tag.setDouble("posZ", pos.getThird()); tag.setInteger("heading", heading.ordinal()); tag.setUniqueId("UID", this.ID); tag.setTag("inventory", stack.writeToNBT(new NBTTagCompound())); tag.setInteger("ticks", this.ticks); NBTTagList routeList = new NBTTagList(); for(EnumFacing node : route) { NBTTagCompound nodeTag = new NBTTagCompound(); //nodeTag.setUniqueId("UID", node.getKey()); nodeTag.setInteger("heading", node.ordinal()); routeList.appendTag(nodeTag); } tag.setTag("route", routeList); return tag; }
Example 3
Source File: GTTileIDSU.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); if (this.owner != null) { nbt.setUniqueId("owner", this.owner); nbt.setString("ownerName", this.ownerName); } return nbt; }
Example 4
Source File: GTTilePlayerDetector.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); if (this.owner != null) { nbt.setUniqueId("owner", this.owner); } nbt.setInteger("mode", this.mode); return nbt; }
Example 5
Source File: GTTileEchotron.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); if (this.owner != null) { nbt.setUniqueId("owner", this.owner); } return nbt; }
Example 6
Source File: GTIDSUStorageManager.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { NBTTagList list = new NBTTagList(); for (Entry<UUID, EnergyWrapper> entry : wrappers.entrySet()) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setUniqueId("owner", entry.getKey()); nbt.setInteger("Energy", entry.getValue().getStoredEnergy()); list.appendTag(nbt); } compound.setTag("data", list); return compound; }
Example 7
Source File: TileEntityPassengerChair.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setBoolean("has_chair_entity", chairEntityUUID != null); if (chairEntityUUID != null) { compound.setUniqueId("chair_entity_uuid", chairEntityUUID); } return super.writeToNBT(compound); }
Example 8
Source File: DamageXpHandler.java From TinkersToolLeveling with MIT License | 5 votes |
private NBTTagCompound convertPlayerDataToTag(UUID uuid, Map<ItemStack, Float> itemStackFloatMap) { NBTTagCompound tag = new NBTTagCompound(); tag.setUniqueId(TAG_PLAYER_UUID, uuid); NBTTagList damageTag = new NBTTagList(); itemStackFloatMap.forEach((itemStack, damage) -> damageTag.appendTag(convertItemDamageDataToTag(itemStack, damage))); tag.setTag(TAG_DAMAGE_LIST, damageTag); return tag; }
Example 9
Source File: Herd.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public void writeToNBT(NBTTagCompound nbt) { NBTTagList animalList = new NBTTagList(); for(int i = 0; i < animals.size(); i++) { VirtualAnimal a = animals.get(i); NBTTagCompound animalTag = new NBTTagCompound(); a.writeToNBT(animalTag); animalList.appendTag(animalTag); } nbt.setTag("animalList", animalList); brain.writeToNBT(nbt); nbt.setString("animalType", animalType); nbt.setUniqueId("uuid", uuid); }
Example 10
Source File: Nyan.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
private static void updateNyanEntity(MinecraftServer server, WorldServer world, Entity entity, NBTTagCompound data) { Entity nyanEntity = null; if(data.hasUniqueId(NYAN_ENTITY_UUID_KEY)) { nyanEntity = server.getEntityFromUuid(data.getUniqueId(NYAN_ENTITY_UUID_KEY)); } boolean shouldSpawn = false; if(nyanEntity == null || nyanEntity.isDead) { nyanEntity = newNyanEntity(world); nyanEntity.getEntityData().setUniqueId(NYANED_ENTITY_UUID_KEY, entity.getUniqueID()); data.setUniqueId(NYAN_ENTITY_UUID_KEY, nyanEntity.getUniqueID()); shouldSpawn = true; } final BlockPos entityPos = entity.getPosition(); double entityHeightMultiplier = world.getTotalWorldTime() % 2 == 0 ? 3.5 : 4.0; //Account for dab particles if(entity instanceof EntityPlayer) { entityHeightMultiplier += 2.0; } //I *could* disable the AI, but this is more fun nyanEntity.setPositionAndRotation( entityPos.getX(), entityPos.getY() + entity.height * entityHeightMultiplier + nyanEntity.height, entityPos.getZ(), entity.rotationYaw, entity.rotationPitch ); nyanEntity.setRotationYawHead(entity.getRotationYawHead()); nyanEntity.setEntityInvulnerable(true); if(shouldSpawn) { world.spawnEntity(nyanEntity); } final BlockPos nyanPos = nyanEntity.getPosition(); final NyanDirection direction = NyanDirection.getDirectionFacing(nyanEntity, Rotation.CLOCKWISE_90); world.spawnParticle( //Wool EnumParticleTypes.REDSTONE, //Not long distance false, nyanPos.getX() + direction.getXDirection() * 12.0, nyanPos.getY() - 2.5, nyanPos.getZ() + direction.getZDirection() * 12.0, //Number of particles 10, direction.getXDirection() * 5.0, 0.0, direction.getZDirection() * 5.0, //Speed 10.0 ); }
Example 11
Source File: TemplateEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public void addEntitiesToWorld(World world, BlockPos posStart) { if (this.placement.getIgnoreEntities()) { return; } Mirror mirror = this.placement.getMirror(); Rotation rotation = this.placement.getRotation(); BlockPos posEnd = posStart.add(PositionUtils.getRelativeEndPositionFromAreaSize(this.size)); BlockPos pos1 = PositionUtils.getMinCorner(posStart, posEnd); BlockPos pos2 = PositionUtils.getMaxCorner(posStart, posEnd).add(1, 1, 1); List<Entity> existingEntities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(pos1, pos2)); for (TemplateEnderUtilities.TemplateEntityInfo entityInfo : this.entities) { BlockPos pos = transformedBlockPos(this.placement, entityInfo.blockPos).add(posStart); NBTTagCompound nbt = entityInfo.entityData; UUID uuidOriginal = nbt.getUniqueId("UUID"); Vec3d vec3d = PositionUtils.transformedVec3d(entityInfo.pos, mirror, rotation); Vec3d vec3d1 = vec3d.add((double)posStart.getX(), (double)posStart.getY(), (double)posStart.getZ()); NBTTagList tagList = new NBTTagList(); tagList.appendTag(new NBTTagDouble(vec3d1.x)); tagList.appendTag(new NBTTagDouble(vec3d1.y)); tagList.appendTag(new NBTTagDouble(vec3d1.z)); nbt.setTag("Pos", tagList); nbt.setUniqueId("UUID", UUID.randomUUID()); Entity entity; try { entity = EntityList.createEntityFromNBT(nbt, world); } catch (Exception e) { entity = null; } if (entity != null) { if (entity instanceof EntityPainting) { entity.getMirroredYaw(mirror); entity.getRotatedYaw(rotation); entity.setPosition(pos.getX(), pos.getY(), pos.getZ()); entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, entity.rotationYaw, entity.rotationPitch); } else { float f = entity.getMirroredYaw(mirror); f = f + (entity.rotationYaw - entity.getRotatedYaw(rotation)); entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch); // FIXME should call updateFacingWithBoundingBox(EnumFacing) for EntityHanging, otherwise a world reload is needed // for ItemFrames for example to visually update to the correct facing } // Use the original UUID if possible. If there is an entity with the same UUID within the pasted area, // then the old one will be killed. Otherwise if there is no entity currently in the world with // the same UUID, then the original UUID will be used. Entity existing = EntityUtils.findEntityByUUID(existingEntities, uuidOriginal); if (existing != null) { world.removeEntityDangerously(existing); entity.setUniqueId(uuidOriginal); } else if (world instanceof WorldServer && ((WorldServer) world).getEntityFromUuid(uuidOriginal) == null) { entity.setUniqueId(uuidOriginal); } world.spawnEntity(entity); } } }