EntityScheduler

This commit is contained in:
MidnightTale 2023-04-12 00:16:24 +07:00
commit edb8a106ea

View file

@ -5,7 +5,6 @@ import com.tcoded.folialib.FoliaLib;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -38,13 +37,9 @@ public class Bbsdfia extends JavaPlugin implements Listener {
Location loc = entity.getLocation(); Location loc = entity.getLocation();
Vector vel = entity.getVelocity(); Vector vel = entity.getVelocity();
Block movingTo = getBlockMovingTo(loc, vel); Block movingTo = getBlockMovingTo(loc, vel);
foliaLib.getImpl().runAtEntity(entity, () -> {/* Code */
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
Location spawnLoc = movingTo.getLocation(); Location spawnLoc = new Location(Bukkit.getWorld("world_the_end"), 100, 50 ,0);
spawnLoc.setX(spawnLoc.getX()+0.5); foliaLib.getImpl().runAtEntity(entity, () -> {
spawnLoc.setY(spawnLoc.getY()+0.5);
spawnLoc.setZ(spawnLoc.getZ()+0.5);
FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
Vector dummyVel = vel.clone(); Vector dummyVel = vel.clone();
dummyVel.setY(-dummyVel.getY()); dummyVel.setY(-dummyVel.getY());
@ -54,10 +49,10 @@ public class Bbsdfia extends JavaPlugin implements Listener {
dummyVel.add(new Vector(0, 0.3, 0)); dummyVel.add(new Vector(0, 0.3, 0));
dummy.setVelocity(dummyVel); dummy.setVelocity(dummyVel);
}
}); });
} }
} }
}