Java Code Examples for net.minecraft.nbt.NBTTagCompound#getUniqueId()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#getUniqueId() .
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 static LPRoutedItem readFromNBT(NBTTagCompound compound, TileGenericPipe holder) { double x = compound.getDouble("posX"); double y = compound.getDouble("posY"); double z = compound.getDouble("posZ"); UUID id = compound.getUniqueId("UID"); ItemStack content = new ItemStack(compound.getCompoundTag("inventory")); int ticks = compound.getInteger("ticks"); Deque<EnumFacing> routingInfo = new ArrayDeque<>(); NBTTagList routeList = (NBTTagList) compound.getTag("route"); for(Iterator<NBTBase> i = routeList.iterator(); i.hasNext();) { NBTTagCompound node = (NBTTagCompound) i.next(); EnumFacing nodeTuple = EnumFacing.values()[node.getInteger("heading")]; routingInfo.add(nodeTuple); } LPRoutedItem item = new LPRoutedItem(x, y, z, content, ticks, id); item.setHeading(EnumFacing.VALUES[compound.getInteger("heading")]); item.setHolding(holder); item.route = routingInfo; return item; }
Example 2
Source File: LPRoutedFluid.java From Logistics-Pipes-2 with MIT License | 6 votes |
public static LPRoutedFluid readFromNBT(NBTTagCompound compound, TileGenericPipe holder) { double x = compound.getDouble("posX"); double y = compound.getDouble("posY"); double z = compound.getDouble("posZ"); UUID id = compound.getUniqueId("UID"); FluidStack content = FluidStack.loadFluidStackFromNBT(compound.getCompoundTag("inventory")); int ticks = compound.getInteger("ticks"); Deque<EnumFacing> routingInfo = new ArrayDeque<>(); NBTTagList routeList = (NBTTagList) compound.getTag("route"); for(Iterator<NBTBase> i = routeList.iterator(); i.hasNext();) { NBTTagCompound node = (NBTTagCompound) i.next(); EnumFacing nodeTuple = EnumFacing.values()[node.getInteger("heading")]; routingInfo.add(nodeTuple); } LPRoutedFluid item = new LPRoutedFluid(x, y, z, content, ticks, id); item.setHeading(EnumFacing.VALUES[compound.getInteger("heading")]); item.setHolding(holder); item.route = routingInfo; return item; }
Example 3
Source File: DamageXpHandler.java From TinkersToolLeveling with MIT License | 6 votes |
@Override public void deserializeNBT(NBTTagList nbt) { playerToDamageMap = new HashMap<>(); for(int i = 0; i < nbt.tagCount(); i++) { NBTTagCompound tag = nbt.getCompoundTagAt(i); UUID playerUuid = tag.getUniqueId(TAG_PLAYER_UUID); NBTTagList data = tag.getTagList(TAG_DAMAGE_LIST, 10); Map<ItemStack, Float> damageMap = new HashMap<>(); for(int j = 0; j < data.tagCount(); j++) { deserializeTagToMapEntry(damageMap, data.getCompoundTagAt(j)); } playerToDamageMap.put(playerUuid, damageMap); } }
Example 4
Source File: GTTileIDSU.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); if (nbt.hasUniqueId("owner")) { this.owner = nbt.getUniqueId("owner"); this.ownerName = nbt.getString("ownerName"); this.getNetwork().updateTileGuiField(this, "ownerName"); } }
Example 5
Source File: GTTilePlayerDetector.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); if (nbt.hasUniqueId("owner")) { this.owner = nbt.getUniqueId("owner"); } this.mode = nbt.getInteger("mode"); }
Example 6
Source File: GTTileEchotron.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); if (nbt.hasUniqueId("owner")) { this.owner = nbt.getUniqueId("owner"); } }
Example 7
Source File: TileEntityPassengerChair.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound compound) { if (compound.getBoolean("has_chair_entity")) { chairEntityUUID = compound.getUniqueId("chair_entity_uuid"); } else { chairEntityUUID = null; } super.readFromNBT(compound); }
Example 8
Source File: Herd.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public void readFromNBT(NBTTagCompound nbt, IslandMap map) { NBTTagList invList = nbt.getTagList("animalList", 10); for(int i = 0; i < invList.tagCount(); i++) { VirtualAnimal a = new VirtualAnimal("", null); a.readFromNBT((NBTTagCompound)invList.get(i)); animals.add(a); } brain.readFromNBT(nbt, map); animalType = nbt.getString("animalType"); uuid = nbt.getUniqueId("uuid"); }
Example 9
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); } } }