Relight using starlight engine on Tuinity & perform heightmap updates (#1023)

* Relight using starlight engine on Tuinity

* Make use of invokeExact

* Cache MethodHandle

* Address some requested changes

* Remove random *

Co-authored-by: NotMyFault <mc.cache@web.de>

* Simplify and clean up sendChunk
Hopefully, that doesn't cause any issues

* Add naive HeightmapProcessor

* Make HeightmapProcessor more efficient

* Remove heightmap code from NMSRelighter

* Recognize fluid for waterlogged blocks

* Remove config option for heightmaps as they should always be updated

* Batch relighting for Starlight

* Dirty workaround for CharBlocks blocks NPE

* Revert "Dirty workaround for CharBlocks blocks NPE"

This reverts commit 737606a7
It only caused the heightmap to be wrong again and didn't help much with the original issue

* Adapt better chunk sending on older versions

* Adapt requested changes for HeightMapType

* Relight all changed chunks, batched
Also, address some requested changes

* Avoid deadlocks

* Clean up tuinity relighter and add some comments

* Minor changes to HeightmapProcessor

Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>
Co-authored-by: NotMyFault <mc.cache@web.de>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
This commit is contained in:
Hannes Greule
2021-05-13 17:29:11 +02:00
committed by GitHub
parent 46f1882496
commit ff728478c6
20 changed files with 653 additions and 263 deletions

View File

@ -19,6 +19,9 @@
package com.sk89q.worldedit.bukkit;
import com.boydti.fawe.beta.implementation.lighting.RelighterFactory;
import com.boydti.fawe.bukkit.NMSRelighterFactory;
import com.boydti.fawe.bukkit.adapter.mc1_16_5.TuinityRelighterFactory_1_16_5;
import com.google.common.collect.Sets;
import com.sk89q.bukkit.util.CommandInfo;
import com.sk89q.bukkit.util.CommandRegistration;
@ -32,15 +35,18 @@ import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
import com.sk89q.worldedit.extension.platform.Preference;
import com.sk89q.worldedit.extension.platform.Watchdog;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.registry.Registries;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.enginehub.piston.CommandManager;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
@ -56,10 +62,13 @@ import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
public class BukkitServerInterface extends AbstractPlatform implements MultiUserPlatform {
private static final Logger LOGGER = LogManagerCompat.getLogger();
public final Server server;
public final WorldEditPlugin plugin;
private final CommandRegistration dynamicCommands;
private final LazyReference<Watchdog> watchdog;
private final RelighterFactory religherFactory;
private boolean hookingEvents;
public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
@ -74,6 +83,16 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
}
return null;
});
RelighterFactory tempFactory;
try {
Class.forName("com.tuinity.tuinity.config.TuinityConfig");
tempFactory = new TuinityRelighterFactory_1_16_5();
LOGGER.info("Using Tuinity internals for relighting");
} catch (ClassNotFoundException e) {
tempFactory = new NMSRelighterFactory();
LOGGER.info("Using FAWE for relighting");
}
this.religherFactory = tempFactory;
}
CommandRegistration getDynamicCommands() {
@ -244,6 +263,11 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
return SUPPORTED_SIDE_EFFECTS;
}
@Override
public @NotNull RelighterFactory getRelighterFactory() {
return this.religherFactory;
}
public void unregisterCommands() {
dynamicCommands.unregisterCommands();
}