nesssistw
This commit is contained in:
parent
a6c30cb756
commit
0fb1194015
1 changed files with 21 additions and 23 deletions
|
|
@ -7,7 +7,6 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
|
@ -16,9 +15,6 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
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 java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class Bbsdfia extends JavaPlugin implements Listener {
|
public class Bbsdfia extends JavaPlugin implements Listener {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -41,43 +37,45 @@ 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);
|
||||||
World end = Bukkit.getServer().getWorld("world_the_end");
|
|
||||||
Location location = new Location(end, 100, 5, 0);
|
World nesssistw = Bukkit.getServer().getWorld("world_the_end");
|
||||||
|
Location location = new Location(nesssistw, 100, 5, 0);
|
||||||
|
|
||||||
FoliaLib foliaLib = new FoliaLib(this);
|
FoliaLib foliaLib = new FoliaLib(this);
|
||||||
|
|
||||||
|
|
||||||
if (movingTo != null && movingTo.getType() == Material.END_PORTAL) {
|
if (movingTo != null && movingTo.getType() == Material.END_PORTAL) {
|
||||||
// Debug message
|
// Debug message
|
||||||
getLogger().info("Falling block detected near end portal");
|
getLogger().info("Falling block detected near end portal");
|
||||||
|
|
||||||
//Entity Scheduler Task
|
//Entity Scheduler Task
|
||||||
//foliaLib.getImpl().runAtEntity(entity, () -> {
|
//foliaLib.getImpl().runAtEntity(entity, () -> {
|
||||||
// Debug message
|
// Debug message
|
||||||
getLogger().info("Spawning falling block in the end dimension");
|
getLogger().info("Spawning falling block in the end dimension");
|
||||||
|
|
||||||
// Get the material and data of the original falling block
|
//spawn new falling block in the end dimension and have same properties entity type and material same form entity that detect near end portal
|
||||||
Material material = ((FallingBlock) entity).getBlockData().getMaterial();
|
|
||||||
@NotNull BlockData data = ((FallingBlock) entity).getBlockData();
|
|
||||||
|
|
||||||
// Spawn a new falling block in the end dimension with the same material and data
|
FallingBlock dummy = nesssistw.spawnFallingBlock(location, ((FallingBlock) entity).getBlockData());
|
||||||
FallingBlock dummy = end.spawnFallingBlock(location, Bukkit.createBlockData(material, (Consumer<BlockData>) data));
|
Vector dummyVel = vel.clone();
|
||||||
Vector dummyVel = vel.clone();
|
dummy.setVelocity(dummyVel);
|
||||||
dummy.setVelocity(dummyVel);
|
|
||||||
|
|
||||||
// Debug message
|
// Debug message
|
||||||
getLogger().info("Setting velocity for the dummy falling block");
|
getLogger().info("Setting velocity for the dummy falling block");
|
||||||
|
|
||||||
// Set the velocity of the dummy falling block
|
//velocity to north
|
||||||
dummy.setVelocity(new Vector(0, 1, 0));
|
dummy.setVelocity(new Vector(0, 1, 0));
|
||||||
//dummy.setVelocity(new Vector(0, -1, 0)); // Uncomment this line if you want the block to fall downwards
|
//velocity to south
|
||||||
//dummy.setVelocity(new Vector(1, 0, 0)); // Uncomment these lines if you want the block to move horizontally
|
dummy.setVelocity(new Vector(0, -1, 0));
|
||||||
//dummy.setVelocity(new Vector(-1, 0, 0));
|
//velocity to east
|
||||||
|
dummy.setVelocity(new Vector(1, 0, 0));
|
||||||
|
//velocity to west
|
||||||
|
dummy.setVelocity(new Vector(-1, 0, 0));
|
||||||
//});
|
//});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Block getBlockMovingTo(Location loc, Vector vel){
|
Block getBlockMovingTo(Location loc, Vector vel){
|
||||||
double absMax = 0, max = 0;
|
double absMax = 0, max = 0;
|
||||||
char dir = ' ';
|
char dir = ' ';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue