Search in sources :

Example 11 with Path

use of net.minecraft.server.v1_15_R1.Path in project dishevelled by heuermh.

the class AssemblyModel method setPath.

/**
 * Set the selected path for this assembly model to <code>path</code>.
 *
 * <p>This is a bound property.</p>
 *
 * @param path selected path for this assembly model, if any
 */
void setPath(final Path path) {
    Path oldPath = this.path;
    this.path = path;
    traversals.clear();
    if (this.path != null && traversalsByPath.containsKey(path)) {
        traversals.addAll(traversalsByPath.get(path));
    }
    propertyChangeSupport.firePropertyChange("path", oldPath, this.path);
}
Also used : Path(org.dishevelled.bio.assembly.gfa1.Path)

Example 12 with Path

use of net.minecraft.server.v1_15_R1.Path in project UltraCosmetics by iSach.

the class PlayerFollower method follow.

@Override
public void follow(Player player) {
    if (player == null) {
        return;
    }
    if (UltraCosmeticsData.get().getPlugin().getPlayerManager().getUltraPlayer(player).getCurrentTreasureChest() != null) {
        return;
    }
    Entity petEntity;
    if (pet.isCustomEntity()) {
        petEntity = ((CustomEntityPet) pet).getCustomEntity();
    } else {
        petEntity = ((CraftEntity) pet.getEntity()).getHandle();
    }
    if (petEntity == null) {
        return;
    }
    // Run in sync... To enhance :S
    Bukkit.getScheduler().runTask(UltraCosmeticsData.get().getPlugin(), () -> {
        if (!player.isOnline())
            return;
        if (!player.getWorld().equals(petEntity.getBukkitEntity().getWorld())) {
            petEntity.getBukkitEntity().teleport(player.getLocation());
            return;
        }
        ((EntityInsentient) petEntity).getNavigation().a(2d);
        Location targetLocation = player.getLocation();
        PathEntity path = ((EntityInsentient) petEntity).getNavigation().a(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 1, 1);
        try {
            int distance = (int) Bukkit.getPlayer(player.getName()).getLocation().distance(petEntity.getBukkitEntity().getLocation());
            if (distance > 10 && petEntity.valid && player.isOnGround()) {
                petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
            }
            if (path != null && distance > 1.3) {
                double speed = 1.15d;
                if (pet.getType().getEntityType() == EntityType.ZOMBIE) {
                    speed *= 1.3;
                }
                ((EntityInsentient) petEntity).getNavigation().a(path, speed);
                ((EntityInsentient) petEntity).getNavigation().a(speed);
            }
        } catch (IllegalArgumentException exception) {
            petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
        // exception.printStackTrace();
        }
    });
}
Also used : PathEntity(net.minecraft.server.v1_15_R1.PathEntity) CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_15_R1.Entity) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) Location(org.bukkit.Location)

Example 13 with Path

use of net.minecraft.server.v1_15_R1.Path in project dishevelled-bio by heuermh.

the class ReassemblePaths method call.

@Override
public Integer call() throws Exception {
    BufferedReader reader = null;
    PrintWriter writer = null;
    try {
        reader = reader(inputGfa1File);
        writer = writer(outputGfa1File);
        final PrintWriter w = writer;
        final List<Path> paths = new ArrayList<Path>();
        final ListMultimap<String, Traversal> traversalsByPathName = ArrayListMultimap.create();
        Gfa1Reader.stream(reader, new Gfa1Listener() {

            @Override
            public boolean record(final Gfa1Record gfa1Record) {
                if (gfa1Record instanceof Path) {
                    Path path = (Path) gfa1Record;
                    paths.add(path);
                } else if (gfa1Record instanceof Traversal) {
                    Traversal traversal = (Traversal) gfa1Record;
                    traversalsByPathName.put(traversal.getPathName(), traversal);
                } else {
                    Gfa1Writer.write(gfa1Record, w);
                }
                return true;
            }
        });
        for (Path path : paths) {
            List<Traversal> traversals = traversalsByPathName.get(path.getName());
            Collections.sort(traversals, new Comparator<Traversal>() {

                @Override
                public int compare(final Traversal t0, final Traversal t1) {
                    return t0.getOrdinal() - t1.getOrdinal();
                }
            });
            List<Reference> segments = new ArrayList<Reference>();
            List<String> overlaps = new ArrayList<String>();
            for (Traversal traversal : traversals) {
                if (segments.isEmpty()) {
                    segments.add(traversal.getSource());
                }
                segments.add(traversal.getTarget());
                if (traversal.hasOverlap()) {
                    overlaps.add(traversal.getOverlap());
                }
            }
            Gfa1Writer.write(new Path(path.getName(), segments, overlaps.isEmpty() ? null : overlaps, path.getAnnotations()), w);
        }
        return 0;
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
        // ignore
        }
        try {
            writer.close();
        } catch (Exception e) {
        // ignore
        }
    }
}
Also used : Path(org.dishevelled.bio.assembly.gfa1.Path) Reference(org.dishevelled.bio.assembly.gfa1.Reference) ArrayList(java.util.ArrayList) Traversal(org.dishevelled.bio.assembly.gfa1.Traversal) Gfa1Listener(org.dishevelled.bio.assembly.gfa1.Gfa1Listener) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) Gfa1Record(org.dishevelled.bio.assembly.gfa1.Gfa1Record) BufferedReader(java.io.BufferedReader) PrintWriter(java.io.PrintWriter)

Example 14 with Path

use of net.minecraft.server.v1_15_R1.Path in project dishevelled-bio by heuermh.

the class TruncatePaths method call.

@Override
public Integer call() throws Exception {
    BufferedReader reader = null;
    PrintWriter writer = null;
    try {
        reader = reader(inputGfa1File);
        writer = writer(outputGfa1File);
        final PrintWriter w = writer;
        Gfa1Reader.stream(reader, new Gfa1Listener() {

            @Override
            public boolean record(final Gfa1Record gfa1Record) {
                if (gfa1Record instanceof Path) {
                    Path path = (Path) gfa1Record;
                    Gfa1Writer.write(new Path(path.getName(), EMPTY_SEGMENTS, null, path.getAnnotations()), w);
                } else {
                    Gfa1Writer.write(gfa1Record, w);
                }
                return true;
            }
        });
        return 0;
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
        // ignore
        }
        try {
            writer.close();
        } catch (Exception e) {
        // ignore
        }
    }
}
Also used : Path(org.dishevelled.bio.assembly.gfa1.Path) Gfa1Record(org.dishevelled.bio.assembly.gfa1.Gfa1Record) BufferedReader(java.io.BufferedReader) Gfa1Listener(org.dishevelled.bio.assembly.gfa1.Gfa1Listener) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) PrintWriter(java.io.PrintWriter)

Example 15 with Path

use of net.minecraft.server.v1_15_R1.Path in project SilkSpawners by timbru31.

the class NMSHandler method setMobNameOfSpawner.

@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
    // Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
    final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.LOWER_UNDERSCORE, mobID.replace(" ", "_")).toLowerCase(Locale.ENGLISH);
    final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
    try {
        final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
        tile.getSpawner().setMobName(IRegistry.ENTITY_TYPE.get(new MinecraftKey(safeMobID)));
        return true;
    } catch (IllegalArgumentException | IllegalAccessException e) {
        Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
        e.printStackTrace();
    }
    return false;
}
Also used : CraftCreatureSpawner(org.bukkit.craftbukkit.v1_15_R1.block.CraftCreatureSpawner) TileEntityMobSpawner(net.minecraft.server.v1_15_R1.TileEntityMobSpawner) MinecraftKey(net.minecraft.server.v1_15_R1.MinecraftKey)

Aggregations

Path (org.dishevelled.bio.assembly.gfa1.Path)7 Path (com.reprezen.kaizen.oasparser.model3.Path)5 BufferedReader (java.io.BufferedReader)5 ArrayList (java.util.ArrayList)5 PrintWriter (java.io.PrintWriter)4 CommandLineParseException (org.dishevelled.commandline.CommandLineParseException)4 HashMap (java.util.HashMap)3 Traversal (org.dishevelled.bio.assembly.gfa1.Traversal)3 HashBasedTable (com.google.common.collect.HashBasedTable)2 Table (com.google.common.collect.Table)2 Parameter (com.reprezen.kaizen.oasparser.model3.Parameter)2 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)2 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)2 TlvException (es.gob.jmulticard.asn1.TlvException)2 Odf (es.gob.jmulticard.asn1.der.pkcs15.Odf)2 Path (es.gob.jmulticard.asn1.der.pkcs15.Path)2 InvalidCardException (es.gob.jmulticard.card.InvalidCardException)2 FileNotFoundException (es.gob.jmulticard.card.iso7816four.FileNotFoundException)2 Iso7816FourCardException (es.gob.jmulticard.card.iso7816four.Iso7816FourCardException)2 FileReader (java.io.FileReader)2