use of lumien.randomthings.network.messages.MessageFlooParticles in project Random-Things by lumien231.
the class FlooNetworkHandler method teleport.
public boolean teleport(World world, BlockPos originPos, TileEntityFlooBrick originTE, EntityPlayerMP player, String enteredDestination) {
FlooFireplace targetFirePlace = null;
double closest = Double.MAX_VALUE;
for (FlooFireplace firePlace : firePlaces) {
String firePlaceName = firePlace.getName();
if (firePlaceName != null) {
double sim = stringSim.distance(firePlaceName, enteredDestination);
if (sim < closest) {
closest = sim;
targetFirePlace = firePlace;
}
}
}
if (targetFirePlace != null) {
if (originPos != null && targetFirePlace.lastKnownPosition.equals(originPos)) {
player.sendMessage(new TextComponentTranslation("floo.info.same"));
return false;
} else {
BlockPos targetPos = targetFirePlace.getLastKnownPosition();
TileEntity te = world.getTileEntity(targetPos);
if (te instanceof TileEntityFlooBrick) {
TileEntityFlooBrick targetTE = (TileEntityFlooBrick) te;
if (targetTE.isMaster()) {
EnumFacing tpFacing = targetTE.getFacing();
BlockPos teleportTarget = targetPos.up();
player.connection.setPlayerLocation(teleportTarget.getX() + 0.5, teleportTarget.getY(), teleportTarget.getZ() + 0.5, tpFacing.getHorizontalAngle(), 0);
player.sendMessage(new TextComponentTranslation("floo.info.teleport", targetFirePlace.getName()));
// Particles
if (originPos != null && originTE != null) {
List<BlockPos> originPositions = new ArrayList<BlockPos>();
originPositions.add(originPos);
originPositions.addAll(originTE.getChildren());
MessageFlooParticles p1 = new MessageFlooParticles(originPositions);
MessageUtil.sendToAllWatchingPos(player.world, originPos, p1);
}
List<BlockPos> destinationPositions = new ArrayList<BlockPos>();
destinationPositions.add(targetPos);
destinationPositions.addAll(targetTE.getChildren());
MessageFlooParticles p2 = new MessageFlooParticles(destinationPositions);
MessageUtil.sendToAllWatchingPos(player.world, targetPos, p2);
PacketHandler.INSTANCE.sendTo(p2, player);
return true;
}
}
firePlaces.remove(targetFirePlace);
this.markDirty();
return teleport(world, originPos, originTE, player, enteredDestination);
}
}
return false;
}
Aggregations