Java Code Examples for net.minecraft.entity.Entity#getUniqueID()

The following examples show how to use net.minecraft.entity.Entity#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: ModuleEffectBackup.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	if(world.isRemote) return true;

	Vec3d targetPos = spell.getTarget(world);
	EnumFacing facing = spell.getData(FACE_HIT);
	Entity caster = spell.getCaster(world);

	double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 20;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (targetPos == null) return true;
	if (!(caster instanceof EntityLivingBase)) return true;
	if (facing != null && !world.isAirBlock(new BlockPos(targetPos))) {
		targetPos = new Vec3d(new BlockPos(targetPos).offset(facing)).add(0.5, 0.5, 0.5);
	}

	UUID player = caster.getUniqueID();

	WizardryWorld world1 = WizardryWorldCapability.get(world);

	if(world1 == null) return true;

	if(world1.getBackupCount(player) < ConfigValues.maxZombies) {
		EntityBackupZombie zombie = new EntityBackupZombie(world, (EntityLivingBase) caster, (int) duration);
		zombie.setPosition(targetPos.x, targetPos.y, targetPos.z);
		zombie.forceSpawn = true;
		world.spawnEntity(zombie);
		world1.incBackupCount(player);
	}

	return true;
}
 
Example 2
Source File: OwnerData.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public OwnerData(Entity entity)
{
    UUID uuid = entity.getUniqueID();
    this.ownerUUID = uuid;
    this.ownerUUIDMost = uuid != null ? uuid.getMostSignificantBits() : 0;
    this.ownerUUIDLeast = uuid != null ? uuid.getLeastSignificantBits() : 0;
    this.ownerName = entity.getName();
    this.isPublic = true;
}
 
Example 3
Source File: SchematicCreationUtils.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void takeEntitiesFromWorldWithinChunk(LitematicaSchematic schematic, World world, int chunkX, int chunkZ,
        ImmutableMap<String, IntBoundingBox> volumes, ImmutableMap<String, SelectionBox> boxes, Set<UUID> existingEntities, BlockPos origin)
{
    for (Map.Entry<String, IntBoundingBox> entry : volumes.entrySet())
    {
        String regionName = entry.getKey();
        Box box = boxes.get(regionName);
        ISchematicRegion region = schematic.getSchematicRegion(regionName);
        List<EntityInfo> schematicEntityList = region != null ? region.getEntityList() : null;

        if (box == null || schematicEntityList == null)
        {
            InfoUtils.showGuiOrInGameMessage(MessageType.ERROR, "litematica.message.error.schematic_save.missing_entity_list", regionName);
            continue;
        }

        AxisAlignedBB bb = PositionUtils.createAABBFrom(entry.getValue());
        List<Entity> entities = world.getEntitiesInAABBexcluding(null, bb, null);
        BlockPos regionPosAbs = box.getPos1();

        for (Entity entity : entities)
        {
            UUID uuid = entity.getUniqueID();
            /*
            if (entity.posX >= bb.minX && entity.posX < bb.maxX &&
                entity.posY >= bb.minY && entity.posY < bb.maxY &&
                entity.posZ >= bb.minZ && entity.posZ < bb.maxZ)
            */
            if (existingEntities.contains(uuid) == false)
            {
                NBTTagCompound tag = new NBTTagCompound();

                if (entity.writeToNBTOptional(tag))
                {
                    Vec3d posVec = new Vec3d(entity.posX - regionPosAbs.getX(), entity.posY - regionPosAbs.getY(), entity.posZ - regionPosAbs.getZ());
                    NBTUtils.writeVec3dToListTag(posVec, tag);
                    schematicEntityList.add(new EntityInfo(posVec, tag));
                    existingEntities.add(uuid);
                }
            }
        }
    }
}
 
Example 4
Source File: ItemHandlerWrapperPermissions.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ItemHandlerWrapperPermissions(InventoryItem baseHandler, Entity entity)
{
    this.baseHandler = baseHandler;
    this.accessorUUID = entity != null ? entity.getUniqueID() : null;
}