Fix regen issues

This commit is contained in:
Jesse Boyd 2017-09-14 14:33:47 +10:00
parent 671dc29c94
commit b2252a1cf6
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
5 changed files with 41 additions and 26 deletions

View File

@ -148,21 +148,17 @@ public class FaweBukkit implements IFawe, Listener {
@Override
public CUI getCUI(FawePlayer player) {
if (Settings.IMP.EXPERIMENTAL.VANILLA_CUI) {
switch (getVersion()) {
case v1_12_R1: {
if (listeningCui && cuiListener == null) return null;
listeningCui = true;
if (cuiListener == null) {
Plugin protocolLib = Bukkit.getPluginManager().getPlugin("ProtocolLib");
if (protocolLib != null && protocolLib.isEnabled()) {
cuiListener = new CUIListener(plugin);
} else {
return null;
}
}
return new StructureCUI(player);
if (listeningCui && cuiListener == null) return null;
listeningCui = true;
if (cuiListener == null) {
Plugin protocolLib = Bukkit.getPluginManager().getPlugin("ProtocolLib");
if (protocolLib != null && protocolLib.isEnabled()) {
cuiListener = new CUIListener(plugin);
} else {
return null;
}
}
return new StructureCUI(player);
}
return null;
}

View File

@ -8,6 +8,7 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.injector.PacketConstructor;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
@ -105,16 +106,32 @@ public class StructureCUI extends CUI {
return NbtFactory.fromNMSCompound(nmsTag);
}
private void sendNbt(Vector pos, NbtCompound compound) {
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketContainer containter = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA);
containter.getBlockPositionModifier().write(0, new BlockPosition(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()));
containter.getIntegers().write(0, 7);
containter.getNbtModifier().write(0, compound);
private void sendOp() {
Player player = this.<Player>getPlayer().parent;
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketConstructor statusCtr = manager.createPacketConstructor(PacketType.Play.Server.ENTITY_STATUS, player, (byte) 28);
PacketContainer status = statusCtr.createPacket(player, (byte) 28);
try {
manager.sendServerPacket(player, containter);
manager.sendServerPacket(player, status);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
private void sendNbt(Vector pos, NbtCompound compound) {
Player player = this.<Player>getPlayer().parent;
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketContainer blockNbt = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA);
blockNbt.getBlockPositionModifier().write(0, new BlockPosition(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()));
blockNbt.getIntegers().write(0, 7);
blockNbt.getNbtModifier().write(0, compound);
try {
manager.sendServerPacket(player, blockNbt);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
@ -123,6 +140,7 @@ public class StructureCUI extends CUI {
public synchronized void update() {
Player player = this.<Player>getPlayer().parent;
Location playerLoc = player.getLocation();
boolean setOp = remove == null && !player.isOp();
if (remove != null) {
int cx = playerLoc.getBlockX() >> 4;
int cz = playerLoc.getBlockZ() >> 4;
@ -172,6 +190,7 @@ public class StructureCUI extends CUI {
Location blockLoc = new Location(player.getWorld(), x, y, z);
player.sendBlockChange(blockLoc, Material.STRUCTURE_BLOCK, (byte) 0);
if (setOp) sendOp();
sendNbt(remove, compound);
}
}

View File

@ -233,10 +233,11 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
return world.regenerateChunk(x, z);
if (!keepLoaded.isEmpty()) keepLoaded.remove(MathMan.pairInt(x, z));
boolean result = world.regenerateChunk(x, z);
return result;
}
@Override
public CharFaweChunk getPrevious(CharFaweChunk fs, CHUNKSECTIONS sections, Map<?, ?> tiles, Collection<?>[] entities, Set<UUID> createdEntities, boolean all) throws Exception {
return fs;

View File

@ -52,7 +52,7 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
}
public MCAQueue(FaweQueue parent) {
super(parent.getWEWorld(), new MCAQueueMap());
super(parent.getWorldName(), new MCAQueueMap());
this.parent = parent;
if (parent instanceof NMSMappedFaweQueue) {
parentNMS = (NMSMappedFaweQueue) parent;

View File

@ -61,7 +61,6 @@ import com.boydti.fawe.object.mask.ResettableMask;
import com.boydti.fawe.object.pattern.ExistingPattern;
import com.boydti.fawe.object.progress.ChatProgressTracker;
import com.boydti.fawe.object.progress.DefaultProgressTracker;
import com.boydti.fawe.object.visitor.FastChunkIterator;
import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.MaskTraverser;
import com.boydti.fawe.util.MathMan;
@ -3408,7 +3407,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
final Set<Vector2D> chunks = region.getChunks();
MutableBlockVector mutable = new MutableBlockVector();
MutableBlockVector2D mutable2D = new MutableBlockVector2D();
for (Vector2D chunk : new FastChunkIterator(chunks, this)) {
for (Vector2D chunk : chunks) {
final int cx = chunk.getBlockX();
final int cz = chunk.getBlockZ();
final int bx = cx << 4;