Java Code Examples for net.minecraft.nbt.NBTTagCompound#hasUniqueId()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#hasUniqueId() .
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: Nyan.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { final Entity entity = event.getEntity(); final World world = entity.getEntityWorld(); if(world.isRemote) { return; } final MinecraftServer server = world.getMinecraftServer(); final NBTTagCompound data = entity.getEntityData(); if(data.hasUniqueId(NYANED_ENTITY_UUID_KEY)) { final Entity nyanedEntity = server.getEntityFromUuid(data.getUniqueId(NYANED_ENTITY_UUID_KEY)); if(nyanedEntity == null || nyanedEntity.isDead) { world.removeEntity(entity); return; } } if(data.getBoolean(HAS_NYAN_ENTITY_KEY)) { updateNyanEntity(server, (WorldServer) world, entity, data); } else if(!data.hasKey(HAS_NYAN_ENTITY_KEY)) { if(entity instanceof EntityPlayer || random.nextInt(10) == 0) { data.setBoolean(HAS_NYAN_ENTITY_KEY, true); updateNyanEntity(server, (WorldServer) world, entity, data); } else { data.setBoolean(HAS_NYAN_ENTITY_KEY, false); } } }
Example 2
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 3
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 4
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 5
Source File: MiscCapabilityStorage.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readNBT(Capability<IMiscCapability> capability, IMiscCapability instance, EnumFacing side, NBTBase nbt) { NBTTagCompound tag = (NBTTagCompound) nbt; if (tag.hasUniqueId("fairy_selected")) { instance.setSelectedFairy(NBTHelper.getUniqueId(tag, "fairy_selected")); } else instance.setSelectedFairy(null); }
Example 6
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 ); }