test
This commit is contained in:
parent
8721778686
commit
873cc7a356
1 changed files with 13 additions and 9 deletions
|
|
@ -30,9 +30,13 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
private final Map<Entity, Vector> velocitiesMap = new HashMap<>(); // Create a map to store velocities
|
private final Map<Entity, Vector> velocitiesMap = new HashMap<>(); // Create a map to store velocities
|
||||||
private ScheduledTask blockktask;
|
private ScheduledTask blockktask;
|
||||||
|
|
||||||
|
|
||||||
@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 {
|
||||||
|
|
@ -69,15 +73,14 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
public void checkFallingBlock(Location centerLocation, double radius) {
|
||||||
public void onFallingBlockToBlockTheEnd(EntityChangeBlockEvent e) {
|
World world = centerLocation.getWorld();
|
||||||
Entity entity = e.getEntity();
|
double x = centerLocation.getX();
|
||||||
if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) {
|
double y = centerLocation.getY();
|
||||||
getLogger().info("found falling block main" + entity);
|
double z = centerLocation.getZ();
|
||||||
Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0);
|
|
||||||
Location loc = entity.getLocation();
|
for (Entity entity : world.getNearbyEntities(centerLocation, radius, radius, radius)) {
|
||||||
if (loc.distance(centerLoc) <= 2) {
|
if (entity instanceof FallingBlock && entity.getLocation().getBlockY() == y && entity.getLocation().getBlockX() == x && entity.getLocation().getBlockZ() == z) {
|
||||||
// Set the initial velocity of the falling block only if it doesn't have a velocity stored
|
|
||||||
if (!velocitiesMap.containsKey(entity)) {
|
if (!velocitiesMap.containsKey(entity)) {
|
||||||
getLogger().info("add velocity falling block" + entity);
|
getLogger().info("add velocity falling block" + entity);
|
||||||
int index = counter % 4;
|
int index = counter % 4;
|
||||||
|
|
@ -98,6 +101,7 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@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