Fix ProtocolSupport compatibility

This commit is contained in:
Jesse Boyd 2019-04-14 12:13:41 +10:00
parent afda4c271c
commit ce0dda5931
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 19 additions and 5 deletions

View File

@ -120,6 +120,9 @@ public class FaweBukkit implements IFawe, Listener {
// Registered delayed Event Listeners // Registered delayed Event Listeners
TaskManager.IMP.task(() -> { TaskManager.IMP.task(() -> {
// Fix for ProtocolSupport
Settings.IMP.PROTOCOL_SUPPORT_FIX = Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport");
// This class // This class
Bukkit.getPluginManager().registerEvents(FaweBukkit.this, FaweBukkit.this.plugin); Bukkit.getPluginManager().registerEvents(FaweBukkit.this, FaweBukkit.this.plugin);

View File

@ -238,7 +238,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
if (current == null) { if (current == null) {
continue; continue;
} }
sectionPalettes[i] = copy(current); copy.sectionPalettes[i] = copy(current);
} }
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);

View File

@ -6,6 +6,7 @@ import com.boydti.fawe.bukkit.BukkitPlayer;
import com.boydti.fawe.bukkit.adapter.v1_13_1.BlockMaterial_1_13; import com.boydti.fawe.bukkit.adapter.v1_13_1.BlockMaterial_1_13;
import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2; import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0; import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.IntFaweChunk; import com.boydti.fawe.example.IntFaweChunk;
import com.boydti.fawe.jnbt.anvil.BitArray4096; import com.boydti.fawe.jnbt.anvil.BitArray4096;
import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweChunk;
@ -867,11 +868,17 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
// BlockStates // BlockStates
int bitsPerEntry = MathMan.log2nlz(num_palette - 1); int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
if (Settings.IMP.PROTOCOL_SUPPORT_FIX) {
bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry
} else {
bitsPerEntry = 1; // For some reason minecraft needs 4096 bits to store 0 entries
}
int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6; int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6;
if (num_palette == 1) { if (num_palette == 1) {
// Set a value, because minecraft needs it for some reason // Set a value, because minecraft needs it for some reason even if the array is empty
blockstates[0] = 0; for (int i = 0; i < blockBitArrayEnd; i++) blockstates[i] = 0;
blockBitArrayEnd = 1;
} else { } else {
BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry); BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry);
bitArray.fromRaw(blocksCopy); bitArray.fromRaw(blocksCopy);
@ -886,7 +893,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits); DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
DataPalette<IBlockData> palette; DataPalette<IBlockData> palette;
// DataPaletteHash<IBlockData> hash = new DataPaletteHash<>(Block.REGISTRY_ID, num_palette, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a); // DataPaletteHash<IBlockData> hash = new DataPaletteHash<>(Block.REGISTRY_ID, num_palette, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a);
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, num_palette, dataPaletteBlocks, GameProfileSerializer::d); palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d);
// set palette // set palette
for (int i = 0; i < num_palette; i++) { for (int i = 0; i < num_palette; i++) {
int ordinal = paletteToBlock[i]; int ordinal = paletteToBlock[i];
@ -903,6 +910,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
} catch (IllegalAccessException | NoSuchFieldException e) { } catch (IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return section; return section;
} catch (Throwable e){ } catch (Throwable e){
Arrays.fill(blockToPalette, Integer.MAX_VALUE); Arrays.fill(blockToPalette, Integer.MAX_VALUE);

View File

@ -9,6 +9,9 @@ public class Settings extends Config {
@Ignore @Ignore
public static final Settings IMP = new Settings(); public static final Settings IMP = new Settings();
@Ignore
public boolean PROTOCOL_SUPPORT_FIX = false;
@Comment("These first 6 aren't configurable") // This is a comment @Comment("These first 6 aren't configurable") // This is a comment
@Final // Indicates that this value isn't configurable @Final // Indicates that this value isn't configurable
public String ISSUES = "https://github.com/boy0001/FastAsyncWorldedit/issues"; public String ISSUES = "https://github.com/boy0001/FastAsyncWorldedit/issues";