Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove y-value scaling #245

Merged
merged 2 commits into from
Mar 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

import java.util.logging.Level;

public class MVLinkChecker {
private final MultiverseNetherPortals plugin;
private final MVWorldManager worldManager;
Expand All @@ -33,23 +31,19 @@ public Location findNewTeleportLocation(Location fromLocation, String worldStrin
Logging.fine("Finding new teleport location for" + entityType + e.getName() + " to world " + worldString);

// Set the output location to the same XYZ coords but different world
MultiverseWorld tpFrom = this.worldManager.getMVWorld(fromLocation.getWorld().getName());

double fromScaling = tpFrom.getScaling();
double toScaling = this.worldManager.getMVWorld(tpTo.getName()).getScaling();
double yScaling = 1d * tpFrom.getCBWorld().getMaxHeight() / tpTo.getCBWorld().getMaxHeight();
double fromScaling = this.worldManager.getMVWorld(fromLocation.getWorld().getName()).getScaling();
double toScaling = tpTo.getScaling();

this.scaleLocation(fromLocation, fromScaling / toScaling, yScaling);
this.scaleLocation(fromLocation, fromScaling / toScaling);
fromLocation.setWorld(tpTo.getCBWorld());
return fromLocation;
}

return null;
}

private void scaleLocation(Location fromLocation, double scaling, double yScaling) {
private void scaleLocation(Location fromLocation, double scaling) {
fromLocation.setX(fromLocation.getX() * scaling);
fromLocation.setZ(fromLocation.getZ() * scaling);
fromLocation.setY(fromLocation.getY() * yScaling);
}
}