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

Fix teleporting sync #7

Merged
merged 9 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {

// We shade these
implementation("com.github.cryptomorin:XSeries:11.1.0")
implementation("com.cjcrafter:foliascheduler:0.5.0")
implementation("com.cjcrafter:foliascheduler:0.6.0")
implementation("org.bstats:bstats-bukkit:3.0.1")
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=3.1.0
version=3.1.1
2 changes: 1 addition & 1 deletion src/main/java/com/cjcrafter/vivecraft/VSE.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class VSE extends JavaPlugin implements Listener {
public boolean debug = false;
public boolean vault;
FileConfiguration config = getConfig();
private ServerImplementation scheduler;
public ServerImplementation scheduler;
private TaskImplementation<Void> sendPosDataTask;

public static boolean isVive(Player p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ public void onProjectileLaunch(ProjectileLaunchEvent event) {
}

Location loc = new Location(proj.getWorld(), pos.getX() + aim.getX() * 0.6f, pos.getY() + aim.getY() * 0.6f, pos.getZ() + aim.getZ() * 0.6f);
final Vector finalAim = aim;
double velo = proj.getVelocity().length();
proj.teleport(loc); //paper sets velocity to 0 on teleport.
proj.setVelocity(new Vector(aim.getX() * velo, aim.getY() * velo, aim.getZ() * velo));
VSE.me.scheduler.teleportAsync(proj, loc).thenAccept((a) -> {
proj.setVelocity(new Vector(finalAim.getX() * velo, finalAim.getY() * velo, finalAim.getZ() * velo));
});
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cjcrafter.vivecraft.listeners;

import com.cryptomorin.xseries.XEntityType;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -36,8 +37,8 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
v.setY(Math.sin(pitch * 0.017453292F) * f2 + 0.1F);

Vector aim = vp.getControllerDir(0);
event.getItemDrop().teleport(vp.getControllerPos(0).add(0.2f * aim.getX(), 0.25f * aim.getY() - 0.2f, 0.2f * aim.getZ()));
event.getItemDrop().setVelocity(v);
Location target = vp.getControllerPos(0).add(0.2f * aim.getX(), 0.25f * aim.getY() - 0.2f, 0.2f * aim.getZ());
VSE.me.scheduler.teleportAsync(event.getItemDrop(), target).thenAccept((a) -> event.getItemDrop().setVelocity(v));
}
}
}