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);
}
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();
}
});
}
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
}
}
}
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
}
}
}
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;
}
Aggregations