Possible fix for tiles
This commit is contained in:
parent
ff59a61046
commit
272a359c28
@ -72,35 +72,33 @@ 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");
|
fieldAdapter.setAccessible(true);
|
||||||
fieldAdapter.setAccessible(true);
|
if ((this.adapter = adapter) != null) {
|
||||||
if ((this.adapter = adapter) != null) {
|
fieldAdapter.set(instance, adapter);
|
||||||
fieldAdapter.set(instance, adapter);
|
} else {
|
||||||
} else {
|
this.adapter = fieldAdapter.get(instance);
|
||||||
this.adapter = fieldAdapter.get(instance);
|
|
||||||
}
|
|
||||||
for (Method method : this.adapter.getClass().getDeclaredMethods()) {
|
|
||||||
switch (method.getName()) {
|
|
||||||
case "toNative":
|
|
||||||
methodToNative = method;
|
|
||||||
methodToNative.setAccessible(true);
|
|
||||||
break;
|
|
||||||
case "fromNative":
|
|
||||||
methodFromNative = method;
|
|
||||||
methodFromNative.setAccessible(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Fawe.debug("====== NO NATIVE WORLDEDIT ADAPTER ======");
|
|
||||||
Fawe.debug("Try updating WorldEdit: ");
|
|
||||||
Fawe.debug(" - http://builds.enginehub.org/job/worldedit?branch=master");
|
|
||||||
Fawe.debug("See also: http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters");
|
|
||||||
Fawe.debug("=========================================");
|
|
||||||
}
|
}
|
||||||
|
for (Method method : this.adapter.getClass().getDeclaredMethods()) {
|
||||||
|
switch (method.getName()) {
|
||||||
|
case "toNative":
|
||||||
|
methodToNative = method;
|
||||||
|
methodToNative.setAccessible(true);
|
||||||
|
break;
|
||||||
|
case "fromNative":
|
||||||
|
methodFromNative = method;
|
||||||
|
methodFromNative.setAccessible(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Fawe.debug("====== NO NATIVE WORLDEDIT ADAPTER ======");
|
||||||
|
Fawe.debug("Try updating WorldEdit: ");
|
||||||
|
Fawe.debug(" - http://builds.enginehub.org/job/worldedit?branch=master");
|
||||||
|
Fawe.debug("See also: http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters");
|
||||||
|
Fawe.debug("=========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,10 +611,23 @@ 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++) {
|
||||||
int count = fs.getCount(j);
|
int count = fs.getCount(j);
|
||||||
|
@ -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,10 +287,23 @@ 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) {
|
||||||
for (int i = 0; i < entities.length; i++) {
|
for (int i = 0; i < entities.length; i++) {
|
||||||
|
@ -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,10 +609,23 @@ 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++) {
|
||||||
int count = fs.getCount(j);
|
int count = fs.getCount(j);
|
||||||
|
Loading…
Reference in New Issue
Block a user