mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-24 19:46:34 +01:00
Fix for craftbukkit 1.10
This commit is contained in:
parent
8e5e2ccafa
commit
e57f2cb193
@ -20,13 +20,13 @@ import com.sk89q.worldedit.internal.Constants;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -81,6 +81,7 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
|
|
||||||
private static IBlockData air;
|
private static IBlockData air;
|
||||||
private static Field fieldBits;
|
private static Field fieldBits;
|
||||||
|
private static Method getEntitySlices;
|
||||||
|
|
||||||
public BukkitQueue_1_10(final String world) {
|
public BukkitQueue_1_10(final String world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -92,6 +93,7 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
air = (IBlockData) fieldAir.get(null);
|
air = (IBlockData) fieldAir.get(null);
|
||||||
fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
||||||
fieldBits.setAccessible(true);
|
fieldBits.setAccessible(true);
|
||||||
|
getEntitySlices = net.minecraft.server.v1_10_R1.Chunk.class.getDeclaredMethod("getEntitySlices");
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
setupAdapter(new com.boydti.fawe.bukkit.v1_10.FaweAdapter_1_10());
|
setupAdapter(new com.boydti.fawe.bukkit.v1_10.FaweAdapter_1_10());
|
||||||
Fawe.debug("Using adapter: " + adapter);
|
Fawe.debug("Using adapter: " + adapter);
|
||||||
@ -248,78 +250,82 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
net.minecraft.server.v1_10_R1.Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
|
try {
|
||||||
ChunkCoordIntPair pos = nmsChunk.k(); // getPosition()
|
net.minecraft.server.v1_10_R1.Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
|
||||||
WorldServer w = (WorldServer) nmsChunk.getWorld();
|
ChunkCoordIntPair pos = nmsChunk.k(); // getPosition()
|
||||||
PlayerChunkMap chunkMap = w.getPlayerChunkMap();
|
WorldServer w = (WorldServer) nmsChunk.getWorld();
|
||||||
PlayerChunk playerChunk = chunkMap.getChunk(pos.x, pos.z);
|
PlayerChunkMap chunkMap = w.getPlayerChunkMap();
|
||||||
if (playerChunk == null) {
|
PlayerChunk playerChunk = chunkMap.getChunk(pos.x, pos.z);
|
||||||
return;
|
if (playerChunk == null) {
|
||||||
}
|
return;
|
||||||
HashSet<EntityPlayer> set = new HashSet<EntityPlayer>(playerChunk.c);
|
|
||||||
EntityTracker tracker = w.getTracker();
|
|
||||||
// Get players
|
|
||||||
final HashSet<EntityPlayer> players = new HashSet<>();
|
|
||||||
for (EntityHuman human : w.players) {
|
|
||||||
if (set.contains(human)) {
|
|
||||||
players.add((EntityPlayer) human);
|
|
||||||
}
|
}
|
||||||
}
|
HashSet<EntityPlayer> set = new HashSet<EntityPlayer>(playerChunk.c);
|
||||||
if (players.size() == 0) {
|
EntityTracker tracker = w.getTracker();
|
||||||
return;
|
// Get players
|
||||||
}
|
final HashSet<EntityPlayer> players = new HashSet<>();
|
||||||
HashSet<EntityTrackerEntry> entities = new HashSet<>();
|
for (EntityHuman human : w.players) {
|
||||||
List<Entity>[] entitieSlices = nmsChunk.getEntitySlices();
|
if (set.contains(human)) {
|
||||||
for (List<Entity> slice : entitieSlices) {
|
players.add((EntityPlayer) human);
|
||||||
if (slice == null) {
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
for (Entity ent : slice) {
|
if (players.size() == 0) {
|
||||||
EntityTrackerEntry entry = tracker.trackedEntities.get(ent.getId());
|
return;
|
||||||
if (entry == null) {
|
}
|
||||||
|
HashSet<EntityTrackerEntry> entities = new HashSet<>();
|
||||||
|
Collection<Entity>[] entitieSlices = (Collection<Entity>[]) getEntitySlices.invoke(nmsChunk);
|
||||||
|
for (Collection<Entity> slice : entitieSlices) {
|
||||||
|
if (slice == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
entities.add(entry);
|
for (Entity ent : slice) {
|
||||||
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ent.getId());
|
EntityTrackerEntry entry = tracker.trackedEntities.get(ent.getId());
|
||||||
for (EntityPlayer player : players) {
|
if (entry == null) {
|
||||||
player.playerConnection.sendPacket(packet);
|
continue;
|
||||||
|
}
|
||||||
|
entities.add(entry);
|
||||||
|
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ent.getId());
|
||||||
|
for (EntityPlayer player : players) {
|
||||||
|
player.playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for (EntityPlayer player : players) {
|
||||||
for (EntityPlayer player : players) {
|
player.playerConnection.networkManager.a();
|
||||||
player.playerConnection.networkManager.a();
|
|
||||||
}
|
|
||||||
// Send chunks
|
|
||||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535);
|
|
||||||
for (EntityPlayer player : players) {
|
|
||||||
player.playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
// send ents
|
|
||||||
for (List<Entity> slice : entitieSlices) {
|
|
||||||
if (slice == null) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
for (final Entity ent : slice) {
|
// Send chunks
|
||||||
final EntityTrackerEntry entry = tracker.trackedEntities.get(ent.getId());
|
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535);
|
||||||
if (entry == null) {
|
for (EntityPlayer player : players) {
|
||||||
|
player.playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
// send ents
|
||||||
|
for (Collection<Entity> slice : entitieSlices) {
|
||||||
|
if (slice == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
for (final Entity ent : slice) {
|
||||||
TaskManager.IMP.later(new Runnable() {
|
final EntityTrackerEntry entry = tracker.trackedEntities.get(ent.getId());
|
||||||
@Override
|
if (entry == null) {
|
||||||
public void run() {
|
continue;
|
||||||
for (EntityPlayer player : players) {
|
}
|
||||||
boolean result = entry.trackedPlayers.remove(player);
|
try {
|
||||||
if (result && ent != player) {
|
TaskManager.IMP.later(new Runnable() {
|
||||||
entry.updatePlayer(player);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (EntityPlayer player : players) {
|
||||||
|
boolean result = entry.trackedPlayers.remove(player);
|
||||||
|
if (result && ent != player) {
|
||||||
|
entry.updatePlayer(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}, 2);
|
||||||
}, 2);
|
} catch (Throwable e) {
|
||||||
} catch (Throwable e) {
|
MainUtil.handleError(e);
|
||||||
MainUtil.handleError(e);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user