w
This commit is contained in:
parent
a68b7d1d25
commit
bd0086b760
1 changed files with 12 additions and 50 deletions
|
|
@ -1,8 +1,5 @@
|
||||||
package xyz.hynse.bbsdfia;
|
package xyz.hynse.bbsdfia;
|
||||||
|
|
||||||
import io.papermc.paper.threadedregions.scheduler.EntityScheduler;
|
|
||||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
@ -12,13 +9,8 @@ import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
|
|
||||||
public class Bbsdfia extends JavaPlugin implements Listener {
|
public class Bbsdfia extends JavaPlugin implements Listener {
|
||||||
|
|
@ -42,52 +34,22 @@ 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);
|
||||||
Location loc2 = new Location(Bukkit.getWorld("world_the_end"), 100, 50, 0);
|
|
||||||
|
|
||||||
|
|
||||||
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
|
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
|
||||||
/*
|
Location spawnLoc = movingTo.getLocation();
|
||||||
World world = Bukkit.getServer().getWorld("world");
|
spawnLoc.setX(spawnLoc.getX()+0.5);
|
||||||
Location spawnLoc = new Location(world, 100, 50, 0);
|
spawnLoc.setY(spawnLoc.getY()+0.5);
|
||||||
*/
|
spawnLoc.setZ(spawnLoc.getZ()+0.5);
|
||||||
//Entity Scheduler Task
|
|
||||||
EntityScheduler scheduler = new EntityScheduler() {
|
|
||||||
@Override
|
|
||||||
public boolean execute(@NotNull Plugin plugin, @NotNull Runnable run, @Nullable Runnable retired, long delay) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
|
||||||
public @Nullable ScheduledTask run(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task, @Nullable Runnable retired) {
|
Vector dummyVel = vel.clone();
|
||||||
return null;
|
dummyVel.setY(-dummyVel.getY());
|
||||||
}
|
dummyVel.multiply(new Vector(2, 2, 2)); // double the velocity
|
||||||
|
|
||||||
@Override
|
// add a constant downward velocity to simulate gravity
|
||||||
public @Nullable ScheduledTask runDelayed(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task, @Nullable Runnable retired, long delayTicks) {
|
dummyVel.add(new Vector(0, 0.3, 0));
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable ScheduledTask runAtFixedRate(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task, @Nullable Runnable retired, long initialDelayTicks, long periodTicks) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
scheduler.runDelayed(this, scheduledTask -> {
|
|
||||||
|
|
||||||
//spawn new falling block in the end dimension and have same properties entity type and material same form entity that detect near end portal
|
|
||||||
FallingBlock dummy = (FallingBlock) loc2.getWorld().spawnEntity(loc2, EntityType.FALLING_BLOCK);
|
|
||||||
Vector dummyVel = vel.clone();
|
|
||||||
dummy.setVelocity(dummyVel);
|
|
||||||
//velocity to north
|
|
||||||
dummy.setVelocity(new Vector(0, 1, 0));
|
|
||||||
//velocity to south
|
|
||||||
dummy.setVelocity(new Vector(0, -1, 0));
|
|
||||||
//velocity to east
|
|
||||||
dummy.setVelocity(new Vector(1, 0, 0));
|
|
||||||
//velocity to west
|
|
||||||
dummy.setVelocity(new Vector(-1, 0, 0));
|
|
||||||
},null,1);
|
|
||||||
|
|
||||||
|
dummy.setVelocity(dummyVel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue