mirror of
https://github.com/ViaVersion/ViaRewind-Legacy-Support.git
synced 2025-02-15 00:51:37 +01:00
elytra flight
This commit is contained in:
parent
8aa27a0e23
commit
354a927399
@ -3,6 +3,7 @@ package de.gerrygames.viarewind.legacysupport;
|
||||
import de.gerrygames.viarewind.legacysupport.injector.LilyPadFixer;
|
||||
import de.gerrygames.viarewind.legacysupport.listener.BounceListener;
|
||||
import de.gerrygames.viarewind.legacysupport.listener.BrewingListener;
|
||||
import de.gerrygames.viarewind.legacysupport.listener.ElytraListener;
|
||||
import de.gerrygames.viarewind.legacysupport.listener.EnchantingListener;
|
||||
import de.gerrygames.viarewind.legacysupport.listener.SoundListener;
|
||||
import de.gerrygames.viarewind.legacysupport.versioninfo.VersionInformer;
|
||||
@ -32,6 +33,8 @@ public class BukkitPlugin extends JavaPlugin {
|
||||
Bukkit.getPluginManager().registerEvents(new SoundListener(), this);
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL>5 && config.getBoolean("slime-fix"))
|
||||
Bukkit.getPluginManager().registerEvents(new BounceListener(), this);
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL>76 && config.getBoolean("elytra-fix"))
|
||||
Bukkit.getPluginManager().registerEvents(new ElytraListener(), this);
|
||||
if (config.getBoolean("versioninfo.active")) new VersionInformer();
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
package de.gerrygames.viarewind.legacysupport.listener;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
public class ElytraListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (!p.isGliding()) return;
|
||||
if (Via.getAPI().getPlayerVersion(p)>76) return;
|
||||
|
||||
Location loc = p.getLocation();
|
||||
Vector velocity = p.getVelocity();
|
||||
Vector direction = loc.getDirection();
|
||||
double motionX = velocity.getX();
|
||||
double motionY = velocity.getY();
|
||||
double motionZ = velocity.getZ();
|
||||
|
||||
float pitch = loc.getPitch() * 0.017453292F;
|
||||
double directionH = Math.sqrt(direction.getX() * direction.getX() + direction.getZ() * direction.getZ());
|
||||
double speedH = Math.sqrt(motionX * motionX + motionZ * motionZ);
|
||||
float speedV = (float) Math.cos(pitch);
|
||||
speedV = (float)(speedV * speedV * Math.min(1.0D, direction.length() / 0.4D));
|
||||
motionY += -0.08D + speedV * 0.06D;
|
||||
if ((motionY < 0.0D) && (directionH > 0.0D)) {
|
||||
double d2 = motionY * -0.1D * speedV;
|
||||
motionY += d2;
|
||||
motionX += direction.getX() * d2 / directionH;
|
||||
motionZ += direction.getZ() * d2 / directionH;
|
||||
}
|
||||
if (pitch < 0.0F) {
|
||||
double speed = speedH * -Math.sin(pitch) * 0.04D;
|
||||
motionY += speed * 3.2D;
|
||||
motionX -= direction.getX() * speed / directionH;
|
||||
motionZ -= direction.getZ() * speed / directionH;
|
||||
}
|
||||
if (directionH > 0.0D) {
|
||||
motionX += (direction.getX() / directionH * speedH - motionX) * 0.1D;
|
||||
motionZ += (direction.getZ() / directionH * speedH - motionZ) * 0.1D;
|
||||
}
|
||||
motionX *= 0.9900000095367432D;
|
||||
motionY *= 0.9800000190734863D;
|
||||
motionZ *= 0.9900000095367432D;
|
||||
velocity.setX(motionX);
|
||||
velocity.setY(motionY);
|
||||
velocity.setZ(motionZ);
|
||||
|
||||
p.setVelocity(velocity);
|
||||
}
|
||||
}
|
@ -8,6 +8,8 @@ lily-pad-fix: true
|
||||
sound-fix: true
|
||||
#If set to true, this plugin will apply velocity to 1.7 if they fall onto slime blocks
|
||||
slime-fix: true
|
||||
#If this plugin should apply velocity to 1.8 and lower clients to emulate elytra flight
|
||||
elytra-fix: true
|
||||
#Inform your players that they are using an outdated minecraft version
|
||||
#max-version specifies the maximum protocol version of players being notified. See http://wiki.vg/Protocol_version_numbers for protocol version numbers
|
||||
#interval can be set to JOIN to notify players when joining the server. If you set it to any integer number it will broadcast the message every x ticks.
|
||||
|
Loading…
Reference in New Issue
Block a user