ehhh
This commit is contained in:
parent
873cc7a356
commit
faa0cf94c8
1 changed files with 56 additions and 39 deletions
|
|
@ -34,24 +34,21 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
Location centerLocation = new Location(Bukkit.getWorld("world_the_end"), 100, 48.5, 0);
|
|
||||||
double radius = 1.0;
|
|
||||||
checkFallingBlock(centerLocation, radius);
|
|
||||||
|
|
||||||
// Get the region scheduler for the server
|
// Get the region scheduler for the server
|
||||||
try {
|
try {
|
||||||
RegionScheduler schedulerblock = getServer().getRegionScheduler();
|
RegionScheduler schedulerblock = getServer().getRegionScheduler();
|
||||||
|
|
||||||
// Schedule a repeating task to run every tick using runAtFixedRate() method
|
// Schedule a repeating task to run every tick using runAtFixedRate() method
|
||||||
blockktask = schedulerblock.runAtFixedRate(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> {
|
blockktask = schedulerblock.runAtFixedRate(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> {
|
||||||
Block block = Objects.requireNonNull(Bukkit.getWorld("world_the_end")).getBlockAt(100, 48, 0);
|
Block block = Objects.requireNonNull(Bukkit.getWorld("world_the_end")).getBlockAt(100, 48, 0);
|
||||||
if (block.getType() == Material.OBSIDIAN) {
|
if (block.getType() == Material.OBSIDIAN) {
|
||||||
block.setType(Material.COBBLED_DEEPSLATE_SLAB);
|
block.setType(Material.COBBLED_DEEPSLATE_SLAB);
|
||||||
Slab slab = (Slab) block.getBlockData();
|
Slab slab = (Slab) block.getBlockData();
|
||||||
slab.setType(Slab.Type.BOTTOM);
|
slab.setType(Slab.Type.BOTTOM);
|
||||||
block.setBlockData(slab);
|
block.setBlockData(slab);
|
||||||
}
|
}
|
||||||
}, 1L, 1L);
|
}, 1L, 1L);
|
||||||
} catch (NullPointerException block) {
|
} catch (NullPointerException block) {
|
||||||
getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)");
|
getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)");
|
||||||
}
|
}
|
||||||
|
|
@ -73,35 +70,55 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkFallingBlock(Location centerLocation, double radius) {
|
// @EventHandler
|
||||||
World world = centerLocation.getWorld();
|
// public void onFallingBlockLand(EntityChangeBlockEvent event) {
|
||||||
double x = centerLocation.getX();
|
// Entity entity = event.getEntity();
|
||||||
double y = centerLocation.getY();
|
// if (entity instanceof FallingBlock && entity.getWorld().getEnvironment() == World.Environment.THE_END) {
|
||||||
double z = centerLocation.getZ();
|
// getLogger().info("found falling block" + entity);
|
||||||
|
// Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0);
|
||||||
|
// Location loc = entity.getLocation();
|
||||||
|
// if (loc.distance(centerLoc) <= 1) {
|
||||||
|
// if (!velocitiesMap.containsKey(entity)) {
|
||||||
|
// getLogger().info("add velocity falling block" + entity);
|
||||||
|
// int index = counter % 4;
|
||||||
|
// getLogger().info("[1]" + entity);
|
||||||
|
// counter++;
|
||||||
|
// getLogger().info("[2]" + entity);
|
||||||
|
// Vector velocity = velocities[index];
|
||||||
|
// getLogger().info("[3]" + entity);
|
||||||
|
// entity.setVelocity(velocity);
|
||||||
|
// getLogger().info("[4]" + entity);
|
||||||
|
// velocitiesMap.put(entity, velocity); // Store the velocity in the map
|
||||||
|
// getLogger().info("[5]" + entity);
|
||||||
|
// movingBlocks.add(entity.getLocation()); // Add the location to the set
|
||||||
|
// getLogger().info("[6]" + entity);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
for (Entity entity : world.getNearbyEntities(centerLocation, radius, radius, radius)) {
|
@EventHandler
|
||||||
if (entity instanceof FallingBlock && entity.getLocation().getBlockY() == y && entity.getLocation().getBlockX() == x && entity.getLocation().getBlockZ() == z) {
|
public void onFallingBlockLand(EntityChangeBlockEvent event) {
|
||||||
if (!velocitiesMap.containsKey(entity)) {
|
// Check if the entity is a falling block and has landed in the End dimension
|
||||||
getLogger().info("add velocity falling block" + entity);
|
Entity entity = event.getEntity();
|
||||||
int index = counter % 4;
|
if (entity instanceof FallingBlock && entity.getWorld().getEnvironment() == World.Environment.THE_END) {
|
||||||
getLogger().info("[1]" + entity);
|
// Spawn a new falling block entity with velocity to the north and upward
|
||||||
counter++;
|
World world = entity.getWorld();
|
||||||
getLogger().info("[2]" + entity);
|
Location location = entity.getLocation();
|
||||||
Vector velocity = velocities[index];
|
Vector velocity = new Vector(0, 1.2, -6);
|
||||||
getLogger().info("[3]" + entity);
|
Material material = ((FallingBlock) entity).getBlockData().getMaterial();
|
||||||
entity.setVelocity(velocity);
|
byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0];
|
||||||
getLogger().info("[4]" + entity);
|
FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data);
|
||||||
velocitiesMap.put(entity, velocity); // Store the velocity in the map
|
newFallingBlock.setVelocity(velocity);
|
||||||
getLogger().info("[5]" + entity);
|
|
||||||
movingBlocks.add(entity.getLocation()); // Add the location to the set
|
// Remove the original falling block entity
|
||||||
getLogger().info("[6]" + entity);
|
entity.remove();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
||||||
if(e.getEntityType() == EntityType.FALLING_BLOCK){
|
if(e.getEntityType() == EntityType.FALLING_BLOCK){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue