commit
1f59a80a6d
2 changed files with 71 additions and 37 deletions
|
|
@ -1 +1 @@
|
||||||
rootProject.name = 'bbsdfia'
|
rootProject.name = 'FoliaFlow'
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
package xyz.hynse.foliaflow;
|
package xyz.hynse.foliaflow;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Location;
|
|
||||||
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;
|
||||||
|
|
@ -11,9 +8,13 @@ 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.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class FoliaFlow extends JavaPlugin implements Listener {
|
public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
private final Vector velocity1 = new Vector(0, 0.5, -1);
|
private final Vector velocity1 = new Vector(0, 0.5, -1);
|
||||||
private final Vector velocity2 = new Vector(-1, 0.5, 0);
|
private final Vector velocity2 = new Vector(-1, 0.5, 0);
|
||||||
|
|
@ -21,21 +22,45 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
private final Vector velocity4 = new Vector(1, 0.5, 0);
|
private final Vector velocity4 = new Vector(1, 0.5, 0);
|
||||||
private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4};
|
private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4};
|
||||||
private int counter = 0;
|
private int counter = 0;
|
||||||
|
//private final Set<Location> movingBlocks = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
getServer().getLogger().info("Bbsdfia plugin started");
|
getServer().getConsoleSender().sendMessage("");
|
||||||
|
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ ");
|
||||||
|
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " / ____/ ____/ /___ _ __");
|
||||||
|
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " / /_ / /_ / / __ \\ | /| / /");
|
||||||
|
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " / __/ / __/ / / /_/ / |/ |/ / ");
|
||||||
|
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "/_/ /_/ /_/\\____/|__/|__/ ");
|
||||||
|
getServer().getConsoleSender().sendMessage("");
|
||||||
|
getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "Plugin started successfully!");
|
||||||
|
getServer().getConsoleSender().sendMessage("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
getServer().getLogger().info("Bbsdfia plugin stopped");
|
debug("Plugin stopped successfully!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@EventHandler
|
||||||
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
|
Block obsidianBlock = obsidianLocation.getBlock();
|
||||||
|
if (event.getWorld() == endWorld && obsidianBlock.getType() == Material.OBSIDIAN) { // check if the chunk is in the end and the block is obsidian
|
||||||
|
obsidianBlock.setType(Material.AIR); // set the block to air
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockChange(org.bukkit.event.block.BlockFromToEvent event) {
|
||||||
|
if (event.getBlock().getLocation().equals(obsidianLocation)) { // check if the block change event is for the obsidian block location
|
||||||
|
event.setCancelled(true); // cancel the event to prevent the obsidian block from changing
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
||||||
|
|
@ -48,15 +73,18 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
|
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
|
||||||
Location spawnLoc = movingTo.getLocation();
|
Location spawnLoc = movingTo.getLocation();
|
||||||
spawnLoc.setX(spawnLoc.getX()+0.5);
|
spawnLoc.setX(spawnLoc.getX()+0.5);
|
||||||
spawnLoc.setY(spawnLoc.getY()+0.5);
|
spawnLoc.setY(spawnLoc.getY()-0.25);
|
||||||
spawnLoc.setZ(spawnLoc.getZ()+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());
|
||||||
|
dummy.setDropItem(false);
|
||||||
|
dummy.setHurtEntities(false);
|
||||||
|
dummy.setGravity(true);
|
||||||
Vector dummyVel = vel.clone();
|
Vector dummyVel = vel.clone();
|
||||||
dummyVel.setY(-dummyVel.getY());
|
dummyVel.setY(-dummyVel.getY());
|
||||||
dummyVel.multiply(new Vector(2, 2, 2));
|
dummyVel.multiply(new Vector(2, 1, 2));
|
||||||
|
|
||||||
dummyVel.add(new Vector(0, -0.2, 0));
|
dummyVel.add(new Vector(0, 1, 0));
|
||||||
|
|
||||||
dummy.setVelocity(dummyVel);
|
dummy.setVelocity(dummyVel);
|
||||||
}
|
}
|
||||||
|
|
@ -64,31 +92,32 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
public void onChunkLoadend(ChunkLoadEvent e) {
|
||||||
Entity entity = event.getEntity();
|
Chunk chunk = e.getChunk();
|
||||||
if (!(entity instanceof FallingBlock)) {
|
World world = chunk.getWorld();
|
||||||
return;
|
if (world.getEnvironment() == World.Environment.THE_END) {
|
||||||
}
|
// Iterate through all the entities in the chunk
|
||||||
if (entity.getWorld().getEnvironment() != World.Environment.THE_END) {
|
for (Entity entity : chunk.getEntities()) {
|
||||||
return;
|
if (entity.getType() == EntityType.FALLING_BLOCK) {
|
||||||
}
|
Location loc = entity.getLocation();
|
||||||
entity.remove();
|
|
||||||
Location fuck = new Location(Bukkit.getWorld("world_the_end"), 100, 49 ,0);
|
|
||||||
fuck.getBlock().setType(Material.AIR);
|
|
||||||
World world = entity.getWorld();
|
|
||||||
Location location = entity.getLocation();
|
|
||||||
byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0];
|
|
||||||
Material material = ((FallingBlock) entity).getBlockData().getMaterial();
|
|
||||||
|
|
||||||
|
debug("Falling block spawned at location " + loc);
|
||||||
|
|
||||||
|
// Set the initial velocity of the falling block
|
||||||
int index = counter % 4;
|
int index = counter % 4;
|
||||||
Vector velocity = velocities[index];
|
|
||||||
counter ++;
|
counter ++;
|
||||||
FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data);
|
Vector velocity = velocities[index];
|
||||||
newFallingBlock.setVelocity(velocity);
|
entity.setVelocity(velocity);
|
||||||
|
|
||||||
|
// Remove the block from the movingBlocks set after a delay, to prevent it from being immediately moved again
|
||||||
|
//getServer().getScheduler().runTaskLater(this, () -> movingBlocks.remove(loc.getBlock().getLocation()), 20L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Block getBlockMovingTo(Location loc, Vector vel) {
|
Block getBlockMovingTo(Location loc, Vector vel) {
|
||||||
|
|
@ -114,6 +143,11 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
case 'y' -> relative = loc.getBlock().getRelative(0, (int) Math.signum(max), 0);
|
case 'y' -> relative = loc.getBlock().getRelative(0, (int) Math.signum(max), 0);
|
||||||
case 'z' -> relative = loc.getBlock().getRelative(0, 0, (int) Math.signum(max));
|
case 'z' -> relative = loc.getBlock().getRelative(0, 0, (int) Math.signum(max));
|
||||||
}
|
}
|
||||||
|
debug("Moving falling block from location " + loc.toString() + " to location " + dir);
|
||||||
return relative;
|
return relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void debug(String message) {
|
||||||
|
getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[FoliaFlow] " + message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue