Fix FAWE killing chunk ticks. Also allow ticking for set blocks. (#439)

* Fix FAWE killing chunk ticks. Also allow ticking for set blocks.

* Reduce for-loop to being one loop in createPalette

* set the value in the set array and break so we don't continue onwards in the set's ordinal switch statement
This commit is contained in:
dordsor21
2020-05-03 17:50:09 +01:00
committed by GitHub
parent a6f2cd0fb5
commit 0ca81e9d67
4 changed files with 121 additions and 49 deletions

View File

@@ -9,12 +9,15 @@ import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import net.jpountz.util.UnsafeUtils;
import net.minecraft.server.v1_15_R1.*;
@@ -197,11 +200,12 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get();
try {
int[] num_palette_buffer = new int[1];
Map<BlockVector3, Integer> ticking_blocks = new HashMap<>();
int air;
if (get == null) {
air = createPalette(blockToPalette, paletteToBlock, blocksCopy, num_palette_buffer, set);
air = createPalette(blockToPalette, paletteToBlock, blocksCopy, num_palette_buffer, set, ticking_blocks);
} else {
air = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy, num_palette_buffer, get, set);
air = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy, num_palette_buffer, get, set, ticking_blocks);
}
int num_palette = num_palette_buffer[0];
// BlockStates
@@ -243,7 +247,11 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
fieldBits.set(dataPaletteBlocks, nmsBits);
fieldPalette.set(dataPaletteBlocks, palette);
fieldSize.set(dataPaletteBlocks, bitsPerEntry);
setCount(0, 4096 - air, section);
setCount(ticking_blocks.size(), 4096 - air, section);
ticking_blocks.forEach((pos, ordinal) -> {
section.setType(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(),
Block.getByCombinedId(ordinal));
});
} catch (final IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(e);
}