Fixes the behavior of backwards portals
Fixes a bug where backwards portals only rotated the player Fixes the rotation being wrong when teleporting from a backwards portal
This commit is contained in:
parent
fff4d8d78b
commit
0c29788a31
@ -102,13 +102,12 @@ public class BlockLocation extends Location {
|
||||
* @param depth <p>The amount of blocks to go downwards when looking the opposite direction from the yaw</p>
|
||||
* @param distance <p>The amount of blocks to go outwards when looking the opposite direction from the yaw</p>
|
||||
* @param portalYaw <p>The yaw when looking out from the portal</p>
|
||||
* @param yaw <p>The yaw of the travelling entity</p>
|
||||
* @return A new location relative to this block location
|
||||
*/
|
||||
public Location getRelativeLocation(double right, double depth, double distance, float portalYaw, float yaw) {
|
||||
public Location getRelativeLocation(double right, double depth, double distance, float portalYaw) {
|
||||
Vector realVector = DirectionHelper.getCoordinateVectorFromRelativeVector(right, depth, distance, portalYaw);
|
||||
return makeRelativeLocation(0.5 + realVector.getBlockX(), realVector.getBlockY(),
|
||||
0.5 + realVector.getBlockZ(), yaw);
|
||||
0.5 + realVector.getBlockZ(), portalYaw);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +118,7 @@ public class PlayerEventListener implements Listener {
|
||||
horse.setOwner(player);
|
||||
}
|
||||
}
|
||||
destination.teleport((Vehicle) playerVehicle, entrancePortal);
|
||||
destination.teleport((Vehicle) playerVehicle);
|
||||
} else {
|
||||
destination.teleport(player, entrancePortal, event);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class VehicleEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Stargate.debug("vehicleTeleport", destinationPortal.getWorld() + " " + destinationPortal.getSignLocation());
|
||||
destinationPortal.teleport(vehicle, entrancePortal);
|
||||
destinationPortal.teleport(vehicle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public class VehicleEventListener implements Listener {
|
||||
}
|
||||
|
||||
Stargate.sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
destinationPortal.teleport(vehicle, entrancePortal);
|
||||
destinationPortal.teleport(vehicle);
|
||||
entrancePortal.close(false);
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ public class Portal {
|
||||
Location exit = getExit(player, traveller);
|
||||
|
||||
//Rotate the player to face out from the portal
|
||||
adjustRotation(exit, origin);
|
||||
adjustRotation(exit);
|
||||
|
||||
//Call the StargatePortalEvent to allow plugins to change destination
|
||||
if (!origin.equals(this)) {
|
||||
@ -514,11 +514,10 @@ public class Portal {
|
||||
* Adjusts the rotation of the player to face out from the portal
|
||||
*
|
||||
* @param exit <p>The location the player will exit from</p>
|
||||
* @param origin <p>The portal the player entered from</p>
|
||||
*/
|
||||
private void adjustRotation(Location exit, Portal origin) {
|
||||
private void adjustRotation(Location exit) {
|
||||
int adjust = 0;
|
||||
if (options.isBackwards() != origin.options.isBackwards()) {
|
||||
if (options.isBackwards()) {
|
||||
adjust = 180;
|
||||
}
|
||||
float newYaw = (this.getYaw() + adjust) % 360;
|
||||
@ -530,9 +529,8 @@ public class Portal {
|
||||
* Teleports a vehicle to this portal
|
||||
*
|
||||
* @param vehicle <p>The vehicle to teleport</p>
|
||||
* @param origin <p>The portal the vehicle entered</p>
|
||||
*/
|
||||
public void teleport(final Vehicle vehicle, Portal origin) {
|
||||
public void teleport(final Vehicle vehicle) {
|
||||
Location traveller = vehicle.getLocation();
|
||||
Location exit = getExit(vehicle, traveller);
|
||||
|
||||
@ -544,7 +542,7 @@ public class Portal {
|
||||
//Get new velocity
|
||||
Vector newVelocityDirection = DirectionHelper.getDirectionVectorFromYaw(this.getYaw());
|
||||
Vector newVelocity = newVelocityDirection.multiply(velocity);
|
||||
adjustRotation(exit, origin);
|
||||
adjustRotation(exit);
|
||||
|
||||
List<Entity> passengers = vehicle.getPassengers();
|
||||
|
||||
@ -632,11 +630,11 @@ public class Portal {
|
||||
RelativeBlockVector relativeExit = gate.getLayout().getExit();
|
||||
if (relativeExit != null) {
|
||||
BlockLocation exit = getBlockAt(relativeExit);
|
||||
float yaw = traveller.getYaw();
|
||||
float portalYaw = this.getYaw();
|
||||
if (options.isBackwards()) {
|
||||
yaw += 180;
|
||||
portalYaw += 180;
|
||||
}
|
||||
exitLocation = exit.getRelativeLocation(0D, 0D, 1, this.getYaw(), yaw);
|
||||
exitLocation = exit.getRelativeLocation(0D, 0D, 1, portalYaw);
|
||||
|
||||
if (entity != null) {
|
||||
double entitySize = EntityHelper.getEntityMaxSize(entity);
|
||||
|
Loading…
x
Reference in New Issue
Block a user