Various unfinished

Start work on command GUI
Code cleanup
Add new lighting mode (see config)
Rename sponge -> sponge112
Fix sponge compile issues
Fix fuzzy region min/max not being set on first use
Fix clipboard on disk not closing on java 9
Start work on CFI chunk simplifier (for loading existing worlds)
Minor tile fixes for bukkit 1.12
This commit is contained in:
Jesse Boyd 2018-01-16 11:30:55 +11:00
parent d78d533acd
commit 134daefa24
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
69 changed files with 954 additions and 380 deletions

6
.gitignore vendored
View File

@ -20,6 +20,9 @@ gradle.log
/forge1710/build
/sponge/build
/sponge111/build
/nukkit/out
/sponge112/build
/core/out
/bukkit/build
/bukkit0/build
/bukkit19/build
@ -30,4 +33,5 @@ spigot-1.10
wiki_permissions.md
/textures
*.iml
/obj
/obj
*.jar

View File

@ -3,6 +3,7 @@ repositories {
}
dependencies {
compile project(':core')
compile 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
compile('com.destroystokyo.paper:paper-api:1.12-R0.1-SNAPSHOT') {
exclude group: 'net.md-5'
}
@ -30,6 +31,7 @@ dependencies {
compile 'org.bukkit.craftbukkit:CraftBukkit:1.8.8'
compile 'com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'
compile 'com.wasteofplastic:askyblock:3.0.8.2'
compile 'org.inventivetalent:mapmanager:1.4.0-SNAPSHOT'
}
processResources {

View File

@ -17,6 +17,7 @@ import com.boydti.fawe.bukkit.regions.PreciousStonesFeature;
import com.boydti.fawe.bukkit.regions.ResidenceFeature;
import com.boydti.fawe.bukkit.regions.TownyFeature;
import com.boydti.fawe.bukkit.regions.Worldguard;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.bukkit.util.BukkitTaskMan;
import com.boydti.fawe.bukkit.util.ItemUtil;
import com.boydti.fawe.bukkit.util.VaultUtil;
@ -374,7 +375,7 @@ public class FaweBukkit implements IFawe, Listener {
public FaweQueue getNewQueue(String world, boolean fast) {
if (playerChunk != (playerChunk = true)) {
try {
Field fieldDirtyCount = ReflectionUtils.getRefClass("{nms}.PlayerChunk").getField("dirtyCount").getRealField();
Field fieldDirtyCount = BukkitReflectionUtils.getRefClass("{nms}.PlayerChunk").getField("dirtyCount").getRealField();
fieldDirtyCount.setAccessible(true);
int mod = fieldDirtyCount.getModifiers();
if ((mod & Modifier.VOLATILE) == 0) {
@ -427,7 +428,7 @@ public class FaweBukkit implements IFawe, Listener {
if (fast) {
if (playerChunk != (playerChunk = true)) {
try {
Field fieldDirtyCount = ReflectionUtils.getRefClass("{nms}.PlayerChunk").getField("dirtyCount").getRealField();
Field fieldDirtyCount = BukkitReflectionUtils.getRefClass("{nms}.PlayerChunk").getField("dirtyCount").getRealField();
fieldDirtyCount.setAccessible(true);
int mod = fieldDirtyCount.getModifiers();
if ((mod & Modifier.VOLATILE) == 0) {

View File

@ -0,0 +1,109 @@
package com.boydti.fawe.bukkit.util;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.ReflectionUtils;
import java.lang.reflect.Method;
import org.bukkit.Bukkit;
import org.bukkit.Server;
public class BukkitReflectionUtils {
/**
* prefix of bukkit classes
*/
private static volatile String preClassB = null;
/**
* prefix of minecraft classes
*/
private static volatile String preClassM = null;
/**
* boolean value, TRUE if server uses forge or MCPC+
*/
private static boolean forge = false;
/**
* check server version and class names
*/
public static void init() {
if (Bukkit.getServer() != null) {
if (Bukkit.getVersion().contains("MCPC") || Bukkit.getVersion().contains("Forge")) {
forge = true;
}
final Server server = Bukkit.getServer();
final Class<?> bukkitServerClass = server.getClass();
String[] pas = bukkitServerClass.getName().split("\\.");
if (pas.length == 5) {
final String verB = pas[3];
preClassB = "org.bukkit.craftbukkit." + verB;
}
try {
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
final Object handle = getHandle.invoke(server);
final Class handleServerClass = handle.getClass();
pas = handleServerClass.getName().split("\\.");
if (pas.length == 5) {
final String verM = pas[3];
preClassM = "net.minecraft.server." + verM;
}
} catch (final Exception ignored) {
MainUtil.handleError(ignored);
}
}
}
/**
* @return true if server has forge classes
*/
public static boolean isForge() {
return forge;
}
/**
* Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace
* {nm} to net.minecraft
*
* @param classes possible class paths
* @return RefClass object
* @throws RuntimeException if no class found
*/
public static ReflectionUtils.RefClass getRefClass(final String... classes) throws RuntimeException {
if (preClassM == null) {
init();
}
for (String className : classes) {
try {
className = className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft");
return ReflectionUtils.getRefClass(Class.forName(className));
} catch (final ClassNotFoundException ignored) {
}
}
throw new RuntimeException("no class found: " + classes[0].replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft"));
}
public static Class<?> getNmsClass(final String name) {
final String className = "net.minecraft.server." + getVersion() + "." + name;
return ReflectionUtils.getClass(className);
}
public static Class<?> getCbClass(final String name) {
final String className = "org.bukkit.craftbukkit." + getVersion() + "." + name;
return ReflectionUtils.getClass(className);
}
public static Class<?> getUtilClass(final String name) {
try {
return Class.forName(name); //Try before 1.8 first
} catch (final ClassNotFoundException ex) {
try {
return Class.forName("net.minecraft.util." + name); //Not 1.8
} catch (final ClassNotFoundException ex2) {
return null;
}
}
}
public static String getVersion() {
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
return packageName.substring(packageName.lastIndexOf('.') + 1);
}
}

View File

@ -25,13 +25,13 @@ public class ItemUtil {
private SoftReference<Int2ObjectOpenHashMap<WeakReference<Tag>>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>());
public ItemUtil() throws Exception {
this.classCraftItemStack = ReflectionUtils.getCbClass("inventory.CraftItemStack");
this.classNMSItem = ReflectionUtils.getNmsClass("ItemStack");
this.classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack");
this.classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack");
this.methodAsNMSCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class));
this.methodHasTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("hasTag"));
this.methodGetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("getTag"));
this.fieldHandle = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredField("handle"));
Class<?> classNBTTagCompound = ReflectionUtils.getNmsClass("NBTTagCompound");
Class<?> classNBTTagCompound = BukkitReflectionUtils.getNmsClass("NBTTagCompound");
this.methodSetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("setTag", classNBTTagCompound));
this.methodAsBukkitCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asBukkitCopy", classNMSItem));
}

View File

@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.BukkitPlayer;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.bukkit.v1_12.packet.FaweChunkPacket;
import com.boydti.fawe.bukkit.v1_12.packet.MCAChunkPacket;
import com.boydti.fawe.example.CharFaweChunk;
@ -36,7 +37,6 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -59,7 +59,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
private static Method methodGetHandle;
static {
Class<?> classCraftChunk = ReflectionUtils.getCbClass("CraftChunk");
Class<?> classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
try {
methodGetHandle = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle"));
} catch (NoSuchMethodException e) {
@ -221,6 +221,11 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
return false;
}
@Override
public boolean removeSectionLighting(SECTION sections, int layer, boolean hasSky) {
return false;
}
public static void checkVersion(String supported) {
String version = Bukkit.getServer().getClass().getPackage().getName();
if (!version.contains(supported)) {

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.NullRelighter;
import com.boydti.fawe.example.Relighter;
@ -101,17 +102,17 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
static {
try {
ReflectionUtils.init();
classRegionFileCache = ReflectionUtils.getNmsClass("RegionFileCache");
classRegionFile = ReflectionUtils.getNmsClass("RegionFile");
classCraftChunk = ReflectionUtils.getCbClass("CraftChunk");
classNMSChunk = ReflectionUtils.getNmsClass("Chunk");
classCraftWorld = ReflectionUtils.getCbClass("CraftWorld");
classNMSWorld = ReflectionUtils.getNmsClass("World");
classChunkProviderServer = ReflectionUtils.getNmsClass("ChunkProviderServer");
classIChunkProvider = ReflectionUtils.getNmsClass("IChunkProvider");
classIChunkLoader = ReflectionUtils.getNmsClass("IChunkLoader");
classChunkRegionLoader = ReflectionUtils.getNmsClass("ChunkRegionLoader");
BukkitReflectionUtils.init();
classRegionFileCache = BukkitReflectionUtils.getNmsClass("RegionFileCache");
classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile");
classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk");
classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
classNMSWorld = BukkitReflectionUtils.getNmsClass("World");
classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer");
classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider");
classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader");
classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader");
methodGetHandleChunk = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle"));
methodGetHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle"));

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.ByteTag;
@ -82,13 +83,13 @@ public class FaweAdapter_All implements BukkitImplAdapter {
private Map<Class<? extends Tag>, Integer> TagToId = new ConcurrentHashMap<>();
public FaweAdapter_All() throws Throwable {
ReflectionUtils.init();
classCraftWorld = ReflectionUtils.getCbClass("CraftWorld");
classCraftBlock = ReflectionUtils.getCbClass("block.CraftBlock");
classCraftEntity = ReflectionUtils.getCbClass("entity.CraftEntity");
classBiomeBase = ReflectionUtils.getNmsClass("BiomeBase");
classWorld = ReflectionUtils.getNmsClass("World");
classTileEntity = ReflectionUtils.getNmsClass("TileEntity");
BukkitReflectionUtils.init();
classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
classCraftBlock = BukkitReflectionUtils.getCbClass("block.CraftBlock");
classCraftEntity = BukkitReflectionUtils.getCbClass("entity.CraftEntity");
classBiomeBase = BukkitReflectionUtils.getNmsClass("BiomeBase");
classWorld = BukkitReflectionUtils.getNmsClass("World");
classTileEntity = BukkitReflectionUtils.getNmsClass("TileEntity");
biomeToBiomeBase = ReflectionUtils.setAccessible(classCraftBlock.getDeclaredMethod("biomeToBiomeBase", Biome.class));
biomeBaseToBiome = ReflectionUtils.setAccessible(classCraftBlock.getDeclaredMethod("biomeBaseToBiome", classBiomeBase));
@ -97,7 +98,7 @@ public class FaweAdapter_All implements BukkitImplAdapter {
getHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle"));
getHandleEntity = ReflectionUtils.setAccessible(classCraftEntity.getDeclaredMethod("getHandle"));
try {
classBlockPosition = ReflectionUtils.getNmsClass("BlockPosition");
classBlockPosition = BukkitReflectionUtils.getNmsClass("BlockPosition");
} catch (Throwable ignore) {
}
if (classBlockPosition != null) {
@ -109,9 +110,9 @@ public class FaweAdapter_All implements BukkitImplAdapter {
getTileEntity2 = ReflectionUtils.setAccessible(classWorld.getDeclaredMethod("getTileEntity", int.class, int.class, int.class));
}
classNBTTagCompound = ReflectionUtils.getNmsClass("NBTTagCompound");
classNBTBase = ReflectionUtils.getNmsClass("NBTBase");
classNBTTagInt = ReflectionUtils.getNmsClass("NBTTagInt");
classNBTTagCompound = BukkitReflectionUtils.getNmsClass("NBTTagCompound");
classNBTBase = BukkitReflectionUtils.getNmsClass("NBTBase");
classNBTTagInt = BukkitReflectionUtils.getNmsClass("NBTTagInt");
newNBTTagInt = ReflectionUtils.setAccessible(classNBTTagInt.getConstructor(int.class));
setNBTTagCompound = ReflectionUtils.setAccessible(classNBTTagCompound.getDeclaredMethod("set", String.class, classNBTBase));
newNBTTagCompound = ReflectionUtils.setAccessible(classNBTTagCompound.getConstructor());
@ -139,7 +140,7 @@ public class FaweAdapter_All implements BukkitImplAdapter {
int noMods = Modifier.STATIC;
int hasMods = 0;
for (int i = 0; i < nmsClasses.size(); i++) {
Class<?> nmsClass = ReflectionUtils.getNmsClass(nmsClasses.get(i));
Class<?> nmsClass = BukkitReflectionUtils.getNmsClass(nmsClasses.get(i));
Class<? extends Tag> weClass = weClasses.get(i);
TagToId.put(weClass, ids[i]);
@ -217,15 +218,15 @@ public class FaweAdapter_All implements BukkitImplAdapter {
}
}
try {
classEntity = ReflectionUtils.getNmsClass("Entity");
classEntityTypes = ReflectionUtils.getNmsClass("EntityTypes");
classEntity = BukkitReflectionUtils.getNmsClass("Entity");
classEntityTypes = BukkitReflectionUtils.getNmsClass("EntityTypes");
getBukkitEntity = ReflectionUtils.setAccessible(classEntity.getDeclaredMethod("getBukkitEntity"));
addEntity = ReflectionUtils.setAccessible(classWorld.getDeclaredMethod("addEntity", classEntity, CreatureSpawnEvent.SpawnReason.class));
setLocation = ReflectionUtils.setAccessible(classEntity.getDeclaredMethod("setLocation", double.class, double.class, double.class, float.class, float.class));
try {
classMinecraftKey = ReflectionUtils.getNmsClass("MinecraftKey");
classMinecraftKey = BukkitReflectionUtils.getNmsClass("MinecraftKey");
newMinecraftKey = classMinecraftKey.getConstructor(String.class);
} catch (Throwable ignore) {
}

View File

@ -648,19 +648,15 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<net.minecraft.server.v1_10_R
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode != RelightMode.NONE) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
section.a(new NibbleArray()); // Emitted
if (sky) {
section.b(new NibbleArray()); // Skylight
}
}
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray());
}
return true;
}
return true;
return false;
}
@Override

View File

@ -650,19 +650,15 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<net.minecraft.server.v1_11_R
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode != RelightMode.NONE) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
section.a(new NibbleArray()); // Emitted
if (sky) {
section.b(new NibbleArray()); // Skylight
}
}
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray());
}
return true;
}
return true;
return false;
}
@Override

View File

@ -245,8 +245,10 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
if (copy != null) {
copy.storeEntity(entity);
}
removeEntity(entity);
iter.remove();
synchronized (BukkitQueue_0.class) {
removeEntity(entity);
}
}
}
}
@ -290,7 +292,9 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
copy.storeEntity(entity);
}
iter.remove();
removeEntity(entity);
synchronized (BukkitQueue_0.class) {
removeEntity(entity);
}
}
}
}
@ -340,7 +344,9 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
entity.f(tag);
}
entity.setLocation(x, y, z, yaw, pitch);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
synchronized (BukkitQueue_0.class) {
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
}
createdEntities.add(entity.getUniqueID());
}
}
@ -373,15 +379,16 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
}
}
if (toRemove != null) {
for (Map.Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) {
BlockPosition bp = entry.getKey();
TileEntity tile = entry.getValue();
tiles.remove(bp);
tile.z();
nmsWorld.s(bp);
tile.invalidateBlockCache();
synchronized (BukkitQueue_0.class) {
for (Map.Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) {
BlockPosition bp = entry.getKey();
TileEntity tile = entry.getValue();
tiles.remove(bp);
tile.z();
nmsWorld.s(bp);
tile.invalidateBlockCache();
}
}
}
// Set blocks
for (int j = 0; j < sections.length; j++) {
@ -485,16 +492,18 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
int y = (blockHash & 0xFF);
int z = (blockHash >> 8 & 0xF) + bz;
BlockPosition pos = new BlockPosition(x, y, z); // Set pos
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity != null) {
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_12.fromNative(nativeTag);
tag.set("x", new NBTTagInt(x));
tag.set("y", new NBTTagInt(y));
tag.set("z", new NBTTagInt(z));
if (BukkitQueue_1_12.methodTileEntityLoad != null) {
BukkitQueue_1_12.methodTileEntityLoad.invoke(tileEntity, tag); // ReadTagIntoTile
} else {
tileEntity.load(tag);
synchronized (BukkitQueue_0.class) {
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity != null) {
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_12.fromNative(nativeTag);
tag.set("x", new NBTTagInt(x));
tag.set("y", new NBTTagInt(y));
tag.set("z", new NBTTagInt(z));
if (BukkitQueue_1_12.methodTileEntityLoad != null) {
BukkitQueue_1_12.methodTileEntityLoad.invoke(tileEntity, tag); // ReadTagIntoTile
} else {
tileEntity.load(tag);
}
}
}
}

View File

@ -730,19 +730,15 @@ public class BukkitQueue_1_12 extends BukkitQueue_0<net.minecraft.server.v1_12_R
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode != RelightMode.NONE) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
section.a(new NibbleArray()); // Emitted
if (sky) {
section.b(new NibbleArray()); // Skylight
}
}
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(null);
if (sky) {
section.b(null);
}
return true;
}
return true;
return false;
}
@Override

View File

@ -549,19 +549,15 @@ public class BukkitQueue17 extends BukkitQueue_0<net.minecraft.server.v1_7_R4.Ch
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
section.setEmittedLightArray(null);
if (sky) {
section.setSkyLightArray(null);
}
}
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.setEmittedLightArray(null);
if (sky) {
section.setSkyLightArray(null);
}
return true;
}
return true;
return false;
}
@Override

View File

@ -542,19 +542,15 @@ public class BukkitQueue18R3 extends BukkitQueue_0<net.minecraft.server.v1_8_R3.
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray());
}
}
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray());
}
return true;
}
return true;
return false;
}
@Override

View File

@ -593,19 +593,15 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<net.minecraft.server.v1_9_
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray());
}
}
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray());
}
return true;
}
return true;
return false;
}
@Override

View File

@ -6,7 +6,6 @@ dependencies {
compile 'org.yaml:snakeyaml:1.16'
compile 'com.google.code.gson:gson:2.2.4'
compile 'net.fabiozumbi12:redprotect:1.9.6'
compile 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
compile group: "com.plotsquared", name: "plotsquared-api", version: "latest"
compile 'org.primesoft:BlocksHub:2.0'
compile 'com.github.luben:zstd-jni:1.1.1'
@ -15,7 +14,6 @@ dependencies {
compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.3-SNAPSHOT') {
exclude(module: 'bukkit-classloader-check')
}
compile 'org.inventivetalent:mapmanager:1.4.0-SNAPSHOT'
}
processResources {

View File

@ -6,6 +6,7 @@ import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.cui.CUI;
import com.boydti.fawe.util.gui.FormBuilder;
import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.world.World;
import java.io.File;
@ -58,4 +59,8 @@ public interface IFawe {
public default String getDebugInfo() {
return "";
}
public default FormBuilder getFormBuilder() {
return null;
}
}

View File

@ -394,9 +394,11 @@ public class Settings extends Config {
"The relighting mode to use:",
" - 0 = None (Do no relighting)",
" - 1 = Optimal (Relight changed light sources and changed blocks)",
" - 2 = All (Slowly relight every blocks)"
" - 2 = All (Slowly relight every blocks)",
})
public int MODE = 1;
@Comment({"If existing lighting should be removed before relighting"})
public boolean REMOVE_FIRST = false;
}
public void reload(File file) {

View File

@ -42,7 +42,11 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
getRelighter().fixLightingSafe(hasSky());
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
getRelighter().removeAndRelight(hasSky());
} else {
getRelighter().fixLightingSafe(hasSky());
}
}
});
}
@ -109,7 +113,18 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
public abstract void setFullbright(CHUNKSECTION sections);
public abstract boolean removeLighting(CHUNKSECTION sections, RelightMode mode, boolean hasSky);
public boolean removeLighting(CHUNKSECTION sections, RelightMode mode, boolean hasSky) {
boolean result = false;
for (int i = 0; i < 16; i++) {
SECTION section = getCachedSection(sections, i);
if (section != null) {
result |= removeSectionLighting(section, i, hasSky);
}
}
return result;
}
public abstract boolean removeSectionLighting(SECTION sections, int layer, boolean hasSky);
public boolean isSurrounded(final char[][] sections, final int x, final int y, final int z) {
return this.isSolid(this.getId(sections, x, y + 1, z))

View File

@ -40,6 +40,7 @@ public class NMSRelighter implements Relighter {
public final IntegerTrio mutableBlockPos = new IntegerTrio();
private static final int DISPATCH_SIZE = 64;
private boolean removeFirst;
public NMSRelighter(NMSMappedFaweQueue queue) {
this.queue = queue;
@ -55,6 +56,13 @@ public class NMSRelighter implements Relighter {
return skyToRelight.isEmpty() && lightQueue.isEmpty() && queuedSkyToRelight.isEmpty() && concurrentLightQueue.isEmpty();
}
@Override
public synchronized void removeAndRelight(boolean sky) {
removeFirst = true;
fixLightingSafe(true);
removeFirst = false;
}
private void set(int x, int y, int z, long[][][] map) {
long[][] m1 = map[z];
if (m1 == null) {
@ -392,6 +400,11 @@ public class NMSRelighter implements Relighter {
Object section = queue.getCachedSection(sections, layer);
if (section == null) continue;
chunk.smooth = false;
if (removeFirst && (y & 15) == 15) {
queue.removeSectionLighting(sections, y >> 4, true);
}
for (int j = 0; j <= maxY; j++) {
int x = cacheX[j];
int z = cacheZ[j];

View File

@ -22,6 +22,11 @@ public class NullRelighter implements Relighter {
}
@Override
public void removeLighting() {
}
@Override
public void fixBlockLighting() {

View File

@ -7,6 +7,13 @@ public interface Relighter {
void fixLightingSafe(boolean sky);
default void removeAndRelight(boolean sky) {
removeLighting();
fixLightingSafe(sky);
}
void removeLighting();
void fixBlockLighting();
void fixSkyLighting();

View File

@ -0,0 +1,19 @@
package com.boydti.fawe.jnbt.anvil;
public class ChunkSimplifier {
private final HeightMapMCAGenerator gen;
public ChunkSimplifier(HeightMapMCAGenerator gen) {
this.gen = gen;
}
public void simplify(MCAChunk chunk) {
// Copy biome
// Calculate water level
// Determine floor block
// Determine overlay block
// determine main block
// Copy bedrock
// copy anomalies to blocks
}
}

View File

@ -510,7 +510,6 @@ public class MCAChunk extends FaweChunk<Void> {
if (entities == null) {
entities = new HashMap<UUID, CompoundTag>();
}
long least = entityTag.getLong("UUIDLeast");
long most = entityTag.getLong("UUIDMost");
entities.put(new UUID(most, least), entityTag);
@ -733,16 +732,20 @@ public class MCAChunk extends FaweChunk<Void> {
public void removeLight() {
for (int i = 0; i < skyLight.length; i++) {
byte[] array1 = skyLight[i];
if (array1 == null) {
continue;
}
byte[] array2 = blockLight[i];
Arrays.fill(array1, (byte) 0);
Arrays.fill(array2, (byte) 0);
removeLight(i);
}
}
public void removeLight(int i) {
byte[] array1 = skyLight[i];
if (array1 == null) {
return;
}
byte[] array2 = blockLight[i];
Arrays.fill(array1, (byte) 0);
Arrays.fill(array2, (byte) 0);
}
public int getNibble(int index, byte[] array) {
int indexShift = index >> 1;
if ((index & 1) == 0) {

View File

@ -687,6 +687,22 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
}
}
@Override
public boolean removeSectionLighting(FaweChunk sections, int layer, boolean hasSky) {
if (sections.getClass() == MCAChunk.class) {
((MCAChunk) sections).removeLight(layer);
} else if (parentNMS != null) {
int cx = sections.getX();
int cz = sections.getZ();
parentNMS.ensureChunkLoaded(cx, cz);
Object parentSections = parentNMS.getCachedSections(parentNMS.getWorld(), cx, cz);
if (parentSections != null) {
parentNMS.removeSectionLighting(sections, layer, hasSky);
}
}
return true;
}
@Override
public boolean removeLighting(FaweChunk sections, RelightMode mode, boolean hasSky) {
if (mode != RelightMode.NONE) {

View File

@ -6,7 +6,6 @@ import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.changeset.AbstractDelegateChangeSet;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import java.lang.reflect.Constructor;
import org.bukkit.entity.Player;
import org.primesoft.blockshub.IBlocksHubApi;
import org.primesoft.blockshub.api.IPlayer;
import org.primesoft.blockshub.api.IWorld;
@ -15,7 +14,7 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet {
private static boolean initialized = false;
public static FaweChangeSet wrap(FawePlayer<Player> player, FaweChangeSet parent) {
public static FaweChangeSet wrap(FawePlayer player, FaweChangeSet parent) {
if (!initialized) {
initialized = true;
api = (IBlocksHubApi) Fawe.imp().getBlocksHubApi();

View File

@ -23,6 +23,7 @@ import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
@ -273,6 +274,16 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
clean.setAccessible(true);
clean.invoke(cleaner.invoke(cb));
} catch (Exception ex) {
try {
final Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
final Field theUnsafeField = unsafeClass.getDeclaredField("theUnsafe");
theUnsafeField.setAccessible(true);
final Object theUnsafe = theUnsafeField.get(null);
final Method invokeCleanerMethod = unsafeClass.getMethod("invokeCleaner", ByteBuffer.class);
invokeCleanerMethod.invoke(theUnsafe, cb);
} catch (Exception e) {
System.gc();
}
}
cb = null;
}

View File

@ -39,7 +39,7 @@ import java.io.Serializable;
* <p>
* A <code>SparseBitSet</code> is not safe for multithreaded use without
* external synchronization.
*
* @see <a href="https://github.com/brettwooldridge/SparseBitSet">source</a>
* @author Bruce K. Haddon
* @author Arthur van Hoff
* @author Michael McCloskey

View File

@ -0,0 +1,214 @@
package com.boydti.fawe.object.queue;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.SetQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.UUID;
import javax.annotation.Nullable;
public class NullFaweQueue implements FaweQueue {
private final String worldName;
public NullFaweQueue(String worldName) {
this.worldName = worldName;
}
@Override
public boolean setBlock(int x, int y, int z, int id, int data) {
return false;
}
@Override
public void setTile(int x, int y, int z, CompoundTag tag) {
}
@Override
public void setEntity(int x, int y, int z, CompoundTag tag) {
}
@Override
public void removeEntity(int x, int y, int z, UUID uuid) {
}
@Override
public boolean setBiome(int x, int z, BaseBiome biome) {
return false;
}
@Override
public FaweChunk getFaweChunk(int x, int z) {
return null;
}
@Override
public Collection<FaweChunk> getFaweChunks() {
return Collections.emptyList();
}
@Override
public void setChunk(FaweChunk chunk) {
}
@Override
public File getSaveFolder() {
return null;
}
@Override
public void setWorld(String world) {
}
@Override
public World getWEWorld() {
return null;
}
@Override
public String getWorldName() {
return worldName;
}
@Override
public long getModified() {
return 0;
}
@Override
public void setModified(long modified) {
}
@Override
public RunnableVal2<ProgressType, Integer> getProgressTask() {
return null;
}
@Override
public void setProgressTask(RunnableVal2<ProgressType, Integer> progressTask) {
}
@Override
public void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
}
@Override
public RunnableVal2<FaweChunk, FaweChunk> getChangeTask() {
return null;
}
@Override
public SetQueue.QueueStage getStage() {
return SetQueue.QueueStage.NONE;
}
@Override
public void setStage(SetQueue.QueueStage stage) {
}
@Override
public void addNotifyTask(Runnable runnable) {
runnable.run();
}
@Override
public void runTasks() {
}
@Override
public void addTask(Runnable whenFree) {
whenFree.run();
}
@Override
public boolean regenerateChunk(int x, int z, @Nullable BaseBiome biome, @Nullable Long seed) {
return false;
}
@Override
public void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) {
}
@Override
public boolean next(int amount, long time) {
return false;
}
@Override
public void sendChunk(FaweChunk chunk) {
}
@Override
public void sendChunk(int x, int z, int bitMask) {
}
@Override
public void clear() {
}
@Override
public void addNotifyTask(int x, int z, Runnable runnable) {
runnable.run();
}
@Override
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
return 0;
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return 0;
}
@Override
public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return 0;
}
@Override
public boolean hasSky() {
return true;
}
@Override
public int getSkyLight(int x, int y, int z) {
return 0;
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return 0;
}
@Override
public CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return null;
}
@Override
public int size() {
return 0;
}