Possible fix for tiles

This commit is contained in:
Jesse Boyd 2016-06-29 02:39:07 +10:00
parent ff59a61046
commit 272a359c28
4 changed files with 80 additions and 40 deletions

View File

@ -72,7 +72,6 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
} }
public void setupAdapter(BukkitImplAdapter adapter) { public void setupAdapter(BukkitImplAdapter adapter) {
if (adapter == null) {
try { try {
WorldEditPlugin instance = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); WorldEditPlugin instance = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
Field fieldAdapter = WorldEditPlugin.class.getDeclaredField("bukkitAdapter"); Field fieldAdapter = WorldEditPlugin.class.getDeclaredField("bukkitAdapter");
@ -102,7 +101,6 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
Fawe.debug("========================================="); Fawe.debug("=========================================");
} }
} }
}
@Override @Override
public World getWorld(String world) { public World getWorld(String world) {

View File

@ -22,6 +22,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
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.List;
@ -595,8 +596,8 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], DataP
changeTask.run(previous); changeTask.run(previous);
} }
// Trim tiles // Trim tiles
Set<Entry<BlockPosition, TileEntity>> entryset = tiles.entrySet(); Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator();
Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = entryset.iterator(); HashMap<BlockPosition, TileEntity> toRemove = null;
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<BlockPosition, TileEntity> tile = iterator.next(); Map.Entry<BlockPosition, TileEntity> tile = iterator.next();
BlockPosition pos = tile.getKey(); BlockPosition pos = tile.getKey();
@ -610,9 +611,22 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], DataP
} }
int k = FaweCache.CACHE_J[ly][lx][lz]; int k = FaweCache.CACHE_J[ly][lx][lz];
if (array[k] != 0) { if (array[k] != 0) {
tile.getValue().invalidateBlockCache(); if (toRemove == null) {
iterator.remove(); toRemove = new HashMap<>();
} }
toRemove.put(tile.getKey(), tile.getValue());
}
}
if (toRemove != null) {
for (Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) {
BlockPosition bp = entry.getKey();
TileEntity tile = entry.getValue();
tiles.remove(bp);
tile.y();
nmsWorld.s(bp);
tile.invalidateBlockCache();
}
} }
// Set blocks // Set blocks
for (int j = 0; j < sections.length; j++) { for (int j = 0; j < sections.length; j++) {

View File

@ -20,6 +20,7 @@ import com.sk89q.worldedit.internal.Constants;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
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.List;
@ -271,8 +272,8 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
changeTask.run(previous); changeTask.run(previous);
} }
// Trim tiles // Trim tiles
Set<Map.Entry<BlockPosition, TileEntity>> entryset = tiles.entrySet(); Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator();
Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = entryset.iterator(); HashMap<BlockPosition, TileEntity> toRemove = null;
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<BlockPosition, TileEntity> tile = iterator.next(); Map.Entry<BlockPosition, TileEntity> tile = iterator.next();
BlockPosition pos = tile.getKey(); BlockPosition pos = tile.getKey();
@ -286,9 +287,22 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
} }
int k = FaweCache.CACHE_J[ly][lx][lz]; int k = FaweCache.CACHE_J[ly][lx][lz];
if (array[k] != 0) { if (array[k] != 0) {
tile.getValue().E(); if (toRemove == null) {
iterator.remove(); toRemove = new HashMap<>();
} }
toRemove.put(tile.getKey(), tile.getValue());
}
}
if (toRemove != null) {
for (Map.Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) {
BlockPosition bp = entry.getKey();
TileEntity tile = entry.getValue();
tiles.remove(bp);
tile.y();
nmsWorld.t(bp);
tile.E();
}
} }
HashSet<UUID> entsToRemove = fs.getEntityRemoves(); HashSet<UUID> entsToRemove = fs.getEntityRemoves();
if (entsToRemove.size() > 0) { if (entsToRemove.size() > 0) {

View File

@ -22,6 +22,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
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.List;
@ -593,8 +594,8 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
changeTask.run(previous); changeTask.run(previous);
} }
// Trim tiles // Trim tiles
Set<Entry<BlockPosition, TileEntity>> entryset = tiles.entrySet(); Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator();
Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = entryset.iterator(); HashMap<BlockPosition, TileEntity> toRemove = null;
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<BlockPosition, TileEntity> tile = iterator.next(); Map.Entry<BlockPosition, TileEntity> tile = iterator.next();
BlockPosition pos = tile.getKey(); BlockPosition pos = tile.getKey();
@ -608,9 +609,22 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
} }
int k = FaweCache.CACHE_J[ly][lx][lz]; int k = FaweCache.CACHE_J[ly][lx][lz];
if (array[k] != 0) { if (array[k] != 0) {
tile.getValue().invalidateBlockCache(); if (toRemove == null) {
iterator.remove(); toRemove = new HashMap<>();
} }
toRemove.put(tile.getKey(), tile.getValue());
}
}
if (toRemove != null) {
for (Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) {
BlockPosition bp = entry.getKey();
TileEntity tile = entry.getValue();
tiles.remove(bp);
tile.y();
nmsWorld.s(bp);
tile.invalidateBlockCache();
}
} }
// Set blocks // Set blocks
for (int j = 0; j < sections.length; j++) { for (int j = 0; j < sections.length; j++) {