Fix weather and spawning

This commit is contained in:
Ben Woo 2023-09-04 23:48:35 +08:00
parent 5278eccad2
commit f519639893
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
3 changed files with 14 additions and 4 deletions

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.listeners;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.inject.InjectableListener;
import com.onarandombox.MultiverseCore.worldnew.WorldManager;
import com.onarandombox.MultiverseCore.worldnew.WorldPurger;
@ -96,7 +97,10 @@ public class MVEntityListener implements InjectableListener {
worldManager.getMVWorld(event.getEntity().getWorld())
.peek((world) -> {
event.setCancelled(this.worldPurger.shouldWeKillThisCreature(world, event.getEntity()));
if (this.worldPurger.shouldWeKillThisCreature(world, event.getEntity())) {
Logging.finer("Cancelling Creature Spawn Event for: " + event.getEntity());
event.setCancelled(true);
}
});
}
}

View File

@ -55,9 +55,7 @@ public class MVWorld extends OfflineWorld {
if (spawnLocation == null || spawnLocation instanceof NullLocation) {
SpawnLocation newLocation = new SpawnLocation(readSpawnFromWorld(world));
worldConfig.setSpawnLocation(newLocation);
world.setSpawnLocation(newLocation.getBlockX(), newLocation.getBlockY(), newLocation.getBlockZ());
}
worldConfig.getSpawnLocation().setWorld(world);
}
private Location readSpawnFromWorld(World world) { // TODO: Refactor... this is copy pasted and bad

View File

@ -53,7 +53,8 @@ public class WorldConfigNodes {
if (world == null) { return; }
world.getBukkitWorld().peek(world -> {
if (!world.isClearWeather() && !newValue) {
world.setClearWeatherDuration(-1);
world.setThundering(false);
world.setStorm(false);
}
});
})
@ -164,6 +165,13 @@ public class WorldConfigNodes {
public final ConfigNode<Location> SPAWN_LOCATION = node(ConfigNode.builder("spawn-location", Location.class)
.defaultValue(new NullLocation())
.name("spawn-location")
.onSetValue((oldValue, newValue) -> {
if (world == null) { return; }
world.getBukkitWorld().peek(world -> {
world.setSpawnLocation(newValue.getBlockX(), newValue.getBlockY(), newValue.getBlockZ());
newValue.setWorld(world);
});
})
.build());
public final ConfigNode<Boolean> SPAWNING_ANIMALS = node(ConfigNode.builder("spawning.animals.spawn", Boolean.class)