Various
centralize error handling fix tile entities (undo/redo)
This commit is contained in:
parent
ee38591c37
commit
54864b73d2
@ -20,6 +20,7 @@ import com.boydti.fawe.object.FaweCommand;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
@ -72,7 +73,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
Bukkit.getServer().shutdown();
|
Bukkit.getServer().shutdown();
|
||||||
}
|
}
|
||||||
TaskManager.IMP.task(new Runnable() {
|
TaskManager.IMP.task(new Runnable() {
|
||||||
@ -158,7 +159,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
this.version[2] = Integer.parseInt(split[2]);
|
this.version[2] = Integer.parseInt(split[2]);
|
||||||
}
|
}
|
||||||
} catch (final NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
||||||
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
||||||
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
||||||
@ -235,7 +236,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
managers.add(new Worldguard(worldguardPlugin, this));
|
managers.add(new Worldguard(worldguardPlugin, this));
|
||||||
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
|
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Plugin plotmePlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotMe");
|
final Plugin plotmePlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotMe");
|
||||||
@ -244,7 +245,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
managers.add(new PlotMeFeature(plotmePlugin, this));
|
managers.add(new PlotMeFeature(plotmePlugin, this));
|
||||||
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
|
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
|
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
|
||||||
@ -253,7 +254,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
managers.add(new TownyFeature(townyPlugin, this));
|
managers.add(new TownyFeature(townyPlugin, this));
|
||||||
Fawe.debug("Plugin 'Towny' found. Using it now.");
|
Fawe.debug("Plugin 'Towny' found. Using it now.");
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions");
|
final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions");
|
||||||
@ -270,7 +271,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
managers.add(new FactionsOneFeature(factionsPlugin, this));
|
managers.add(new FactionsOneFeature(factionsPlugin, this));
|
||||||
Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
|
Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
|
||||||
} catch (Throwable e3) {
|
} catch (Throwable e3) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -282,7 +283,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
managers.add(new ResidenceFeature(residencePlugin, this));
|
managers.add(new ResidenceFeature(residencePlugin, this));
|
||||||
Fawe.debug("Plugin 'Residence' found. Using it now.");
|
Fawe.debug("Plugin 'Residence' found. Using it now.");
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
|
final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
|
||||||
@ -291,7 +292,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
|
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
|
||||||
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
|
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
|
final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
|
||||||
@ -300,7 +301,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
|
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
|
||||||
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
|
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return managers;
|
return managers;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.bukkit;
|
package com.boydti.fawe.bukkit;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -89,7 +90,7 @@ public class Metrics {
|
|||||||
gzos = new GZIPOutputStream(baos);
|
gzos = new GZIPOutputStream(baos);
|
||||||
gzos.write(input.getBytes("UTF-8"));
|
gzos.write(input.getBytes("UTF-8"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (gzos != null) {
|
if (gzos != null) {
|
||||||
try {
|
try {
|
||||||
@ -243,7 +244,7 @@ public class Metrics {
|
|||||||
// Each post thereafter will be a ping
|
// Each post thereafter will be a ping
|
||||||
this.firstPost = false;
|
this.firstPost = false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
if (Metrics.this.debug) {
|
if (Metrics.this.debug) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||||
}
|
}
|
||||||
@ -431,7 +432,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.bukkit.regions;
|
|||||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.Perm;
|
import com.boydti.fawe.util.Perm;
|
||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -106,7 +107,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.boydti.fawe.example.CharFaweChunk;
|
|||||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||||
@ -246,13 +247,13 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk getChunk(int x, int z) {
|
public FaweChunk getFaweChunk(int x, int z) {
|
||||||
return new CharFaweChunk<Chunk>(this, x, z) {
|
return new CharFaweChunk<Chunk>(this, x, z) {
|
||||||
@Override
|
@Override
|
||||||
public Chunk getNewChunk() {
|
public Chunk getNewChunk() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.bukkit.v0;
|
package com.boydti.fawe.bukkit.v0;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -20,7 +21,17 @@ public class BukkitQueue_All extends BukkitQueue_0<Chunk, Chunk, Chunk> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk getCachedChunk(World impWorld, int cx, int cz) {
|
public Chunk getCachedSections(World impWorld, int cx, int cz) {
|
||||||
return impWorld.getChunkAt(cx, cz);
|
return impWorld.getChunkAt(cx, cz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getChunk(World world, int x, int z) {
|
||||||
|
return world.getChunkAt(x, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.boydti.fawe.object.FaweLocation;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
import com.boydti.fawe.object.PseudoRandom;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -68,11 +69,11 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
||||||
return getCachedChunk(world, x, z) != null;
|
return getCachedSections(world, x, z) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkSection[] getCachedChunk(World world, int x, int z) {
|
public ChunkSection[] getCachedSections(World world, int x, int z) {
|
||||||
Chunk chunk = world.getChunkAt(x, z);
|
Chunk chunk = world.getChunkAt(x, z);
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -103,7 +104,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
|
|||||||
public CharFaweChunk getPrevious(CharFaweChunk fs, ChunkSection[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
public CharFaweChunk getPrevious(CharFaweChunk fs, ChunkSection[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
||||||
Map<BlockPosition, TileEntity> tiles = (Map<BlockPosition, TileEntity>) tilesGeneric;
|
Map<BlockPosition, TileEntity> tiles = (Map<BlockPosition, TileEntity>) tilesGeneric;
|
||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = new char[16][];
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
@ -126,16 +127,15 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
|
|||||||
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
||||||
TileEntity tile = entry.getValue();
|
TileEntity tile = entry.getValue();
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
tile.b(tag); // readTileEntityIntoTag
|
|
||||||
BlockPosition pos = entry.getKey();
|
BlockPosition pos = entry.getKey();
|
||||||
CompoundTag nativeTag = (CompoundTag) methodToNative.invoke(adapter, tag);
|
CompoundTag nativeTag = getTag(tile);
|
||||||
previous.setTile(pos.getX(), pos.getY(), pos.getZ(), nativeTag);
|
previous.setTile(pos.getX() & 15, pos.getY(), pos.getZ() & 15, nativeTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entities != null) {
|
if (entities != null) {
|
||||||
for (Collection<Entity> entityList : entities) {
|
for (Collection<Entity> entityList : entities) {
|
||||||
for (Entity ent : entityList) {
|
for (Entity ent : entityList) {
|
||||||
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && !createdEntities.contains(ent.getUniqueID()))) {
|
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && createdEntities.contains(ent.getUniqueID()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int x = ((int) Math.round(ent.locX) & 15);
|
int x = ((int) Math.round(ent.locX) & 15);
|
||||||
@ -164,6 +164,33 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
|
|||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CompoundTag getTag(TileEntity tile) {
|
||||||
|
try {
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
tile.b(tag); // readTagIntoEntity
|
||||||
|
return (CompoundTag) methodToNative.invoke(adapter, tag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MainUtil.handleError(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockPosition.MutableBlockPosition pos = new BlockPosition.MutableBlockPosition(0, 0, 0);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||||
|
Map<BlockPosition, TileEntity> tiles = ((CraftChunk) chunk).getHandle().getTileEntities();
|
||||||
|
pos.c(x, y, z);
|
||||||
|
TileEntity tile = tiles.get(pos);
|
||||||
|
return tile != null ? getTag(tile) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getChunk(World world, int x, int z) {
|
||||||
|
return world.getChunkAt(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setComponents(FaweChunk fc, RunnableVal<FaweChunk> changeTask) {
|
public boolean setComponents(FaweChunk fc, RunnableVal<FaweChunk> changeTask) {
|
||||||
CharFaweChunk<Chunk> fs = (CharFaweChunk<Chunk>) fc;
|
CharFaweChunk<Chunk> fs = (CharFaweChunk<Chunk>) fc;
|
||||||
@ -342,7 +369,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
sendChunk(fc, null);
|
sendChunk(fc, null);
|
||||||
return true;
|
return true;
|
||||||
@ -418,7 +445,6 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
|
|||||||
int X = fc.getX() << 4;
|
int X = fc.getX() << 4;
|
||||||
int Z = fc.getZ() << 4;
|
int Z = fc.getZ() << 4;
|
||||||
|
|
||||||
BlockPosition.MutableBlockPosition pos = new BlockPosition.MutableBlockPosition(0, 0, 0);
|
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
ChunkSection section = sections[j];
|
ChunkSection section = sections[j];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
@ -483,7 +509,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
|
|||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.bukkit.v1_9;
|
|||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.example.CharFaweChunk;
|
import com.boydti.fawe.example.CharFaweChunk;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import net.minecraft.server.v1_9_R2.Block;
|
import net.minecraft.server.v1_9_R2.Block;
|
||||||
@ -78,7 +79,7 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk> {
|
|||||||
value.sectionPalettes[i] = paletteBlock;
|
value.sectionPalettes[i] = paletteBlock;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -8,6 +8,7 @@ import com.boydti.fawe.object.BytePair;
|
|||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
import com.boydti.fawe.object.PseudoRandom;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -70,7 +71,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkSection[] getCachedChunk(World world, int cx, int cz) {
|
public ChunkSection[] getCachedSections(World world, int cx, int cz) {
|
||||||
CraftChunk chunk = (CraftChunk) world.getChunkAt(cx, cz);
|
CraftChunk chunk = (CraftChunk) world.getChunkAt(cx, cz);
|
||||||
return chunk.getHandle().getSections();
|
return chunk.getHandle().getSections();
|
||||||
}
|
}
|
||||||
@ -134,7 +135,6 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
net.minecraft.server.v1_9_R2.World w = c.world;
|
net.minecraft.server.v1_9_R2.World w = c.world;
|
||||||
final int X = chunk.getX() << 4;
|
final int X = chunk.getX() << 4;
|
||||||
final int Z = chunk.getZ() << 4;
|
final int Z = chunk.getZ() << 4;
|
||||||
BlockPosition.MutableBlockPosition pos = new BlockPosition.MutableBlockPosition(0, 0, 0);
|
|
||||||
for (int j = sections.length - 1; j >= 0; j--) {
|
for (int j = sections.length - 1; j >= 0; j--) {
|
||||||
final Object section = sections[j];
|
final Object section = sections[j];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
@ -202,7 +202,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
return true;
|
return true;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -282,7 +282,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
public CharFaweChunk getPrevious(CharFaweChunk fs, ChunkSection[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
public CharFaweChunk getPrevious(CharFaweChunk fs, ChunkSection[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
||||||
Map<BlockPosition, TileEntity> tiles = (Map<BlockPosition, TileEntity>) tilesGeneric;
|
Map<BlockPosition, TileEntity> tiles = (Map<BlockPosition, TileEntity>) tilesGeneric;
|
||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
// Copy blocks
|
// Copy blocks
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = new char[16][];
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
@ -320,17 +320,16 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
||||||
TileEntity tile = entry.getValue();
|
TileEntity tile = entry.getValue();
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
tile.save(tag); // readTagIntoEntity
|
|
||||||
BlockPosition pos = entry.getKey();
|
BlockPosition pos = entry.getKey();
|
||||||
CompoundTag nativeTag = (CompoundTag) methodToNative.invoke(adapter, tag);
|
CompoundTag nativeTag = getTag(tile);
|
||||||
previous.setTile(pos.getX(), pos.getY(), pos.getZ(), nativeTag);
|
previous.setTile(pos.getX() & 15, pos.getY(), pos.getZ() & 15, nativeTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Copy entities
|
// Copy entities
|
||||||
if (entities != null) {
|
if (entities != null) {
|
||||||
for (Collection<Entity> entityList : entities) {
|
for (Collection<Entity> entityList : entities) {
|
||||||
for (Entity ent : entityList) {
|
for (Entity ent : entityList) {
|
||||||
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && !createdEntities.contains(ent.getUniqueID()))) {
|
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && createdEntities.contains(ent.getUniqueID()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int x = ((int) Math.round(ent.locX) & 15);
|
int x = ((int) Math.round(ent.locX) & 15);
|
||||||
@ -359,6 +358,32 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockPosition.MutableBlockPosition pos = new BlockPosition.MutableBlockPosition(0, 0, 0);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||||
|
Map<BlockPosition, TileEntity> tiles = ((CraftChunk) chunk).getHandle().getTileEntities();
|
||||||
|
pos.c(x, y, z);
|
||||||
|
TileEntity tile = tiles.get(pos);
|
||||||
|
return tile != null ? getTag(tile) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getTag(TileEntity tile) {
|
||||||
|
try {
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
tile.save(tag); // readTagIntoEntity
|
||||||
|
return (CompoundTag) methodToNative.invoke(adapter, tag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MainUtil.handleError(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getChunk(World world, int x, int z) {
|
||||||
|
return world.getChunkAt(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setComponents(final FaweChunk fc, RunnableVal<FaweChunk> changeTask) {
|
public boolean setComponents(final FaweChunk fc, RunnableVal<FaweChunk> changeTask) {
|
||||||
final BukkitChunk_1_9 fs = (BukkitChunk_1_9) fc;
|
final BukkitChunk_1_9 fs = (BukkitChunk_1_9) fc;
|
||||||
@ -396,6 +421,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
}
|
}
|
||||||
int j = FaweCache.CACHE_J[y][x][z];
|
int j = FaweCache.CACHE_J[y][x][z];
|
||||||
if (array[j] != 0) {
|
if (array[j] != 0) {
|
||||||
|
// System.out.println("REMOVE ENT (blocked): " + entity);
|
||||||
nmsWorld.removeEntity(entity);
|
nmsWorld.removeEntity(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,6 +433,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||||
for (Entity entity : ents) {
|
for (Entity entity : ents) {
|
||||||
if (entsToRemove.contains(entity.getUniqueID())) {
|
if (entsToRemove.contains(entity.getUniqueID())) {
|
||||||
|
// System.out.println("REMOVE ENT (action): " + entity);
|
||||||
nmsWorld.removeEntity(entity);
|
nmsWorld.removeEntity(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -445,6 +472,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
entity.setLocation(x, y, z, yaw, pitch);
|
entity.setLocation(x, y, z, yaw, pitch);
|
||||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
createdEntities.add(entity.getUniqueID());
|
createdEntities.add(entity.getUniqueID());
|
||||||
|
// System.out.println("CREATE ENT (action): " + entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Change task?
|
// Change task?
|
||||||
@ -568,7 +596,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
final int[][] biomes = fs.getBiomeArray();
|
final int[][] biomes = fs.getBiomeArray();
|
||||||
final Biome[] values = Biome.values();
|
final Biome[] values = Biome.values();
|
||||||
@ -602,7 +630,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk getChunk(int x, int z) {
|
public FaweChunk getFaweChunk(int x, int z) {
|
||||||
return new BukkitChunk_1_9(this, x, z);
|
return new BukkitChunk_1_9(this, x, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ public class Fawe {
|
|||||||
try {
|
try {
|
||||||
BundledBlockData.getInstance().loadFromResource();
|
BundledBlockData.getInstance().loadFromResource();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
File jar = MainUtil.getJarFile();
|
File jar = MainUtil.getJarFile();
|
||||||
File file = MainUtil.copyFile(jar, "extrablocks.json", null);
|
File file = MainUtil.copyFile(jar, "extrablocks.json", null);
|
||||||
@ -288,7 +288,7 @@ public class Fawe {
|
|||||||
PlatformManager.inject(); // Async brushes / tools
|
PlatformManager.inject(); // Async brushes / tools
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
debug("====== UPDATE WORLDEDIT TO 6.1.1 ======");
|
debug("====== UPDATE WORLDEDIT TO 6.1.1 ======");
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e, false);
|
||||||
debug("=======================================");
|
debug("=======================================");
|
||||||
debug("Update the plugin, or contact the Author!");
|
debug("Update the plugin, or contact the Author!");
|
||||||
if (IMP.getPlatform().equals("bukkit")) {
|
if (IMP.getPlatform().equals("bukkit")) {
|
||||||
@ -301,7 +301,7 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
debug("====== FAWE FAILED TO INITIALIZE ======");
|
debug("====== FAWE FAILED TO INITIALIZE ======");
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e, false);
|
||||||
debug("=======================================");
|
debug("=======================================");
|
||||||
debug("Things to check: ");
|
debug("Things to check: ");
|
||||||
debug(" - Using WorldEdit 6.1.1");
|
debug(" - Using WorldEdit 6.1.1");
|
||||||
@ -326,7 +326,7 @@ public class Fawe {
|
|||||||
} catch (Throwable ignore) {}
|
} catch (Throwable ignore) {}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
debug("====== LZ4 COMPRESSION BINDING NOT FOUND ======");
|
debug("====== LZ4 COMPRESSION BINDING NOT FOUND ======");
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e, false);
|
||||||
debug("===============================================");
|
debug("===============================================");
|
||||||
debug("FAWE will still work, but some things may be slower");
|
debug("FAWE will still work, but some things may be slower");
|
||||||
debug(" - Try updating your JVM / OS");
|
debug(" - Try updating your JVM / OS");
|
||||||
@ -378,7 +378,7 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
debug("====== MEMORY LISTENER ERROR ======");
|
debug("====== MEMORY LISTENER ERROR ======");
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e, false);
|
||||||
debug("===================================");
|
debug("===================================");
|
||||||
debug("FAWE needs access to the JVM memory system:");
|
debug("FAWE needs access to the JVM memory system:");
|
||||||
debug(" - Change your Java security settings");
|
debug(" - Change your Java security settings");
|
||||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.object.RegionWrapper;
|
|||||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MemUtil;
|
import com.boydti.fawe.util.MemUtil;
|
||||||
import com.boydti.fawe.util.SetQueue;
|
import com.boydti.fawe.util.SetQueue;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
@ -327,7 +328,7 @@ public class FaweAPI {
|
|||||||
*/
|
*/
|
||||||
public static void fixLighting(String world, int x, int z, FaweQueue.RelightMode mode) {
|
public static void fixLighting(String world, int x, int z, FaweQueue.RelightMode mode) {
|
||||||
FaweQueue queue = SetQueue.IMP.getNewQueue(world, true, false);
|
FaweQueue queue = SetQueue.IMP.getNewQueue(world, true, false);
|
||||||
queue.fixLighting(queue.getChunk(x, z), mode);
|
queue.fixLighting(queue.getFaweChunk(x, z), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -337,7 +338,7 @@ public class FaweAPI {
|
|||||||
*/
|
*/
|
||||||
public static void fixLighting(final Chunk chunk, FaweQueue.RelightMode mode) {
|
public static void fixLighting(final Chunk chunk, FaweQueue.RelightMode mode) {
|
||||||
FaweQueue queue = SetQueue.IMP.getNewQueue(chunk.getWorld().getName(), true, false);
|
FaweQueue queue = SetQueue.IMP.getNewQueue(chunk.getWorld().getName(), true, false);
|
||||||
queue.fixLighting(queue.getChunk(chunk.getX(), chunk.getZ()), mode);
|
queue.fixLighting(queue.getFaweChunk(chunk.getX(), chunk.getZ()), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,7 +370,7 @@ public class FaweAPI {
|
|||||||
final FileInputStream is = new FileInputStream(file);
|
final FileInputStream is = new FileInputStream(file);
|
||||||
streamSchematic(is, loc);
|
streamSchematic(is, loc);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +388,7 @@ public class FaweAPI {
|
|||||||
final InputStream is = Channels.newInputStream(rbc);
|
final InputStream is = Channels.newInputStream(rbc);
|
||||||
streamSchematic(is, loc);
|
streamSchematic(is, loc);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class FixLighting extends FaweCommand {
|
|||||||
FaweQueue queue = SetQueue.IMP.getNewQueue(loc.world, true, false);
|
FaweQueue queue = SetQueue.IMP.getNewQueue(loc.world, true, false);
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; x++) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
queue.sendChunk(queue.getChunk(x, z), FaweQueue.RelightMode.ALL);
|
queue.sendChunk(queue.getFaweChunk(x, z), FaweQueue.RelightMode.ALL);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.config;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -257,7 +258,7 @@ public enum BBC {
|
|||||||
yml.save(file);
|
yml.save(file);
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.config;
|
|||||||
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -77,7 +78,7 @@ public class Settings {
|
|||||||
try {
|
try {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
final YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||||
@ -168,7 +169,7 @@ public class Settings {
|
|||||||
try {
|
try {
|
||||||
config.save(file);
|
config.save(file);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ public abstract class CharFaweChunk<T> extends FaweChunk<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharFaweChunk<T> copy(boolean shallow) {
|
public CharFaweChunk<T> copy(boolean shallow) {
|
||||||
CharFaweChunk<T> copy = (CharFaweChunk<T>) getParent().getChunk(getX(), getZ());
|
CharFaweChunk<T> copy = (CharFaweChunk<T>) getParent().getFaweChunk(getX(), getZ());
|
||||||
if (shallow) {
|
if (shallow) {
|
||||||
copy.ids = ids;
|
copy.ids = ids;
|
||||||
copy.air = air;
|
copy.air = air;
|
||||||
|
@ -7,6 +7,7 @@ import com.boydti.fawe.object.IntegerPair;
|
|||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.SetQueue;
|
import com.boydti.fawe.util.SetQueue;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -53,7 +54,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
try {
|
try {
|
||||||
thread.join();
|
thread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,11 +78,11 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
public abstract boolean setComponents(FaweChunk fc, RunnableVal<FaweChunk> changeTask);
|
public abstract boolean setComponents(FaweChunk fc, RunnableVal<FaweChunk> changeTask);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract FaweChunk getChunk(int x, int z);
|
public abstract FaweChunk getFaweChunk(int x, int z);
|
||||||
|
|
||||||
public abstract boolean loadChunk(WORLD world, int x, int z, boolean generate);
|
public abstract boolean loadChunk(WORLD world, int x, int z, boolean generate);
|
||||||
|
|
||||||
public abstract CHUNK getCachedChunk(WORLD world, int cx, int cz);
|
public abstract CHUNK getCachedSections(WORLD world, int cx, int cz);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChunkLoaded(int x, int z) {
|
public boolean isChunkLoaded(int x, int z) {
|
||||||
@ -105,7 +106,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
long pair = (long) (x) << 32 | (z) & 0xFFFFFFFFL;
|
long pair = (long) (x) << 32 | (z) & 0xFFFFFFFFL;
|
||||||
FaweChunk result = this.blocks.get(pair);
|
FaweChunk result = this.blocks.get(pair);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = this.getChunk(x, z);
|
result = this.getFaweChunk(x, z);
|
||||||
result.addNotifyTask(runnable);
|
result.addNotifyTask(runnable);
|
||||||
FaweChunk previous = this.blocks.put(pair, result);
|
FaweChunk previous = this.blocks.put(pair, result);
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
@ -137,7 +138,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
||||||
lastWrappedChunk = this.blocks.get(pair);
|
lastWrappedChunk = this.blocks.get(pair);
|
||||||
if (lastWrappedChunk == null) {
|
if (lastWrappedChunk == null) {
|
||||||
lastWrappedChunk = this.getChunk(x >> 4, z >> 4);
|
lastWrappedChunk = this.getFaweChunk(x >> 4, z >> 4);
|
||||||
lastWrappedChunk.setBlock(x & 15, y, z & 15, id, data);
|
lastWrappedChunk.setBlock(x & 15, y, z & 15, id, data);
|
||||||
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
|
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
@ -165,7 +166,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
||||||
lastWrappedChunk = this.blocks.get(pair);
|
lastWrappedChunk = this.blocks.get(pair);
|
||||||
if (lastWrappedChunk == null) {
|
if (lastWrappedChunk == null) {
|
||||||
lastWrappedChunk = this.getChunk(x >> 4, z >> 4);
|
lastWrappedChunk = this.getFaweChunk(x >> 4, z >> 4);
|
||||||
lastWrappedChunk.setTile(x & 15, y, z & 15, tag);
|
lastWrappedChunk.setTile(x & 15, y, z & 15, tag);
|
||||||
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
|
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
@ -192,7 +193,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
||||||
lastWrappedChunk = this.blocks.get(pair);
|
lastWrappedChunk = this.blocks.get(pair);
|
||||||
if (lastWrappedChunk == null) {
|
if (lastWrappedChunk == null) {
|
||||||
lastWrappedChunk = this.getChunk(x >> 4, z >> 4);
|
lastWrappedChunk = this.getFaweChunk(x >> 4, z >> 4);
|
||||||
lastWrappedChunk.setEntity(tag);
|
lastWrappedChunk.setEntity(tag);
|
||||||
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
|
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
@ -219,7 +220,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
||||||
lastWrappedChunk = this.blocks.get(pair);
|
lastWrappedChunk = this.blocks.get(pair);
|
||||||
if (lastWrappedChunk == null) {
|
if (lastWrappedChunk == null) {
|
||||||
lastWrappedChunk = this.getChunk(x >> 4, z >> 4);
|
lastWrappedChunk = this.getFaweChunk(x >> 4, z >> 4);
|
||||||
lastWrappedChunk.removeEntity(uuid);
|
lastWrappedChunk.removeEntity(uuid);
|
||||||
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
|
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
@ -238,7 +239,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
long pair = (long) (x >> 4) << 32 | (z >> 4) & 0xFFFFFFFFL;
|
long pair = (long) (x >> 4) << 32 | (z >> 4) & 0xFFFFFFFFL;
|
||||||
FaweChunk result = this.blocks.get(pair);
|
FaweChunk result = this.blocks.get(pair);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = this.getChunk(x >> 4, z >> 4);
|
result = this.getFaweChunk(x >> 4, z >> 4);
|
||||||
FaweChunk previous = this.blocks.put(pair, result);
|
FaweChunk previous = this.blocks.put(pair, result);
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
this.blocks.put(pair, previous);
|
this.blocks.put(pair, previous);
|
||||||
@ -268,7 +269,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -283,7 +284,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
try {
|
try {
|
||||||
run.run();
|
run.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,16 +346,16 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
public int lastChunkZ = Integer.MIN_VALUE;
|
public int lastChunkZ = Integer.MIN_VALUE;
|
||||||
public int lastChunkY = Integer.MIN_VALUE;
|
public int lastChunkY = Integer.MIN_VALUE;
|
||||||
|
|
||||||
private CHUNK lastChunk;
|
public CHUNK lastChunkSections;
|
||||||
private SECTION lastSection;
|
public SECTION lastSection;
|
||||||
|
|
||||||
public SECTION getCachedSection(CHUNK chunk, int cy) {
|
public SECTION getCachedSection(CHUNK chunk, int cy) {
|
||||||
return (SECTION) lastChunk;
|
return (SECTION) lastChunkSections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int getCombinedId4Data(SECTION section, int x, int y, int z);
|
public abstract int getCombinedId4Data(SECTION section, int x, int y, int z);
|
||||||
|
|
||||||
private final RunnableVal<IntegerPair> loadChunk = new RunnableVal<IntegerPair>() {
|
public final RunnableVal<IntegerPair> loadChunk = new RunnableVal<IntegerPair>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(IntegerPair coord) {
|
public void run(IntegerPair coord) {
|
||||||
loadChunk(getWorld(), coord.x, coord.z, true);
|
loadChunk(getWorld(), coord.x, coord.z, true);
|
||||||
@ -389,13 +390,13 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastChunk = getCachedChunk(getWorld(), cx, cz);
|
lastChunkSections = getCachedSections(getWorld(), cx, cz);
|
||||||
lastSection = getCachedSection(lastChunk, cy);
|
lastSection = getCachedSection(lastChunkSections, cy);
|
||||||
} else if (cy != lastChunkY) {
|
} else if (cy != lastChunkY) {
|
||||||
if (lastChunk == null) {
|
if (lastChunkSections == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lastSection = getCachedSection(lastChunk, cy);
|
lastSection = getCachedSection(lastChunkSections, cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastSection == null) {
|
if (lastSection == null) {
|
||||||
|
@ -2,8 +2,10 @@ package com.boydti.fawe.example;
|
|||||||
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -41,4 +43,24 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
|||||||
public abstract void refreshChunk(WORLD world, CHUNK chunk);
|
public abstract void refreshChunk(WORLD world, CHUNK chunk);
|
||||||
|
|
||||||
public abstract CharFaweChunk getPrevious(CharFaweChunk fs, CHUNKSECTION sections, Map<?, ?> tiles, Collection<?>[] entities, Set<UUID> createdEntities, boolean all) throws Exception;
|
public abstract CharFaweChunk getPrevious(CharFaweChunk fs, CHUNKSECTION sections, Map<?, ?> tiles, Collection<?>[] entities, Set<UUID> createdEntities, boolean all) throws Exception;
|
||||||
|
|
||||||
|
public abstract CompoundTag getTileEntity(CHUNK chunk, int x, int y, int z);
|
||||||
|
|
||||||
|
public abstract CHUNK getChunk(WORLD world, int x, int z);
|
||||||
|
|
||||||
|
private CHUNK lastChunk;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||||
|
if (y < 0 || y > 255) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int cx = x >> 4;
|
||||||
|
int cz = z >> 4;
|
||||||
|
lastChunk = getChunk(getWorld(), cx, cz);
|
||||||
|
if (lastChunk == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getTileEntity(lastChunk, x, y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.object;
|
package com.boydti.fawe.object;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
|
||||||
public abstract class FaweCommand<T> {
|
public abstract class FaweCommand<T> {
|
||||||
@ -41,7 +42,7 @@ public abstract class FaweCommand<T> {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.boydti.fawe.config.Settings;
|
|||||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||||
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
|
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
|
||||||
import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard;
|
import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.util.WEManager;
|
import com.boydti.fawe.util.WEManager;
|
||||||
import com.boydti.fawe.wrappers.PlayerWrapper;
|
import com.boydti.fawe.wrappers.PlayerWrapper;
|
||||||
@ -66,7 +67,7 @@ public abstract class FawePlayer<T> {
|
|||||||
Player player = (Player) fieldBasePlayer.get(actor);
|
Player player = (Player) fieldBasePlayer.get(actor);
|
||||||
return wrap(player);
|
return wrap(player);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return Fawe.imp().wrap(actor.getName());
|
return Fawe.imp().wrap(actor.getName());
|
||||||
}
|
}
|
||||||
} else if (obj instanceof PlayerWrapper){
|
} else if (obj instanceof PlayerWrapper){
|
||||||
@ -77,7 +78,7 @@ public abstract class FawePlayer<T> {
|
|||||||
fieldPlayer.setAccessible(true);
|
fieldPlayer.setAccessible(true);
|
||||||
return wrap(fieldPlayer.get(actor));
|
return wrap(fieldPlayer.get(actor));
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return Fawe.imp().wrap(actor.getName());
|
return Fawe.imp().wrap(actor.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +104,7 @@ public abstract class FawePlayer<T> {
|
|||||||
}
|
}
|
||||||
loadClipboardFromDisk();
|
loadClipboardFromDisk();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
Fawe.debug("Failed to load history for: " + getName());
|
Fawe.debug("Failed to load history for: " + getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +131,7 @@ public abstract class FawePlayer<T> {
|
|||||||
}
|
}
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
Fawe.debug("====== INVALID CLIPBOARD ======");
|
Fawe.debug("====== INVALID CLIPBOARD ======");
|
||||||
ignore.printStackTrace();
|
MainUtil.handleError(ignore, false);
|
||||||
Fawe.debug("===============---=============");
|
Fawe.debug("===============---=============");
|
||||||
Fawe.debug("This shouldn't result in any failure");
|
Fawe.debug("This shouldn't result in any failure");
|
||||||
Fawe.debug("File: " + file.getName() + " (len:" + file.length() + ")");
|
Fawe.debug("File: " + file.getName() + " (len:" + file.length() + ")");
|
||||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.object;
|
|||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -59,7 +60,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
if (!FaweCache.hasData(id)) {
|
if (!FaweCache.hasData(id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int data = id & 0xF;
|
int data = combined & 0xF;
|
||||||
if (data == block.getData()) {
|
if (data == block.getData()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -72,8 +73,10 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
this.changeSet.add(location, getBlock(location), block);
|
CompoundTag tag = queue.getTileEntity(x, y, z);
|
||||||
|
this.changeSet.add(location, new BaseBlock(id, combined & 0xF, tag), block);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
this.changeSet.add(x, y, z, combined, block);
|
this.changeSet.add(x, y, z, combined, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.IntegerPair;
|
import com.boydti.fawe.object.IntegerPair;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
import com.sk89q.jnbt.NBTOutputStream;
|
import com.sk89q.jnbt.NBTOutputStream;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -144,7 +145,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
|||||||
osENTCT = null;
|
osENTCT = null;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return flushed;
|
return flushed;
|
||||||
}
|
}
|
||||||
@ -305,7 +306,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
|||||||
summary.add(x, z, ((combined2 << 4) + (combined1 >> 4)));
|
summary.add(x, z, ((combined2 << 4) + (combined1 >> 4)));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return summary;
|
return summary;
|
||||||
@ -331,7 +332,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
|||||||
fis.close();
|
fis.close();
|
||||||
gis.close();
|
gis.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new IntegerPair(ox, oz);
|
return new IntegerPair(ox, oz);
|
||||||
|
@ -47,7 +47,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
|||||||
BaseBlock to = change.getCurrent();
|
BaseBlock to = change.getCurrent();
|
||||||
add(loc, from, to);
|
add(loc, from, to);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
|||||||
add(x, y, z, combinedFrom, combinedTo);
|
add(x, y, z, combinedFrom, combinedTo);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
|||||||
add(x, y, z, combinedFrom, combinedTo);
|
add(x, y, z, combinedFrom, combinedTo);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
} finally {
|
} finally {
|
||||||
waiting.decrementAndGet();
|
waiting.decrementAndGet();
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.config.Settings;
|
|||||||
import com.boydti.fawe.object.change.MutableBlockChange;
|
import com.boydti.fawe.object.change.MutableBlockChange;
|
||||||
import com.boydti.fawe.object.change.MutableEntityChange;
|
import com.boydti.fawe.object.change.MutableEntityChange;
|
||||||
import com.boydti.fawe.object.change.MutableTileChange;
|
import com.boydti.fawe.object.change.MutableTileChange;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
import com.sk89q.jnbt.NBTOutputStream;
|
import com.sk89q.jnbt.NBTOutputStream;
|
||||||
@ -109,7 +110,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
stream.write(((combinedTo) >> 8) & 0xff);
|
stream.write(((combinedTo) >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
NBTOutputStream nbtos = getTileCreateOS();
|
NBTOutputStream nbtos = getTileCreateOS();
|
||||||
nbtos.writeNamedTag(tileCreateSize++ + "", tag);
|
nbtos.writeNamedTag(tileCreateSize++ + "", tag);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
NBTOutputStream nbtos = getTileRemoveOS();
|
NBTOutputStream nbtos = getTileRemoveOS();
|
||||||
nbtos.writeNamedTag(tileRemoveSize++ + "", tag);
|
nbtos.writeNamedTag(tileRemoveSize++ + "", tag);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
NBTOutputStream nbtos = getEntityRemoveOS();
|
NBTOutputStream nbtos = getEntityRemoveOS();
|
||||||
nbtos.writeNamedTag(entityRemoveSize++ + "", tag);
|
nbtos.writeNamedTag(entityRemoveSize++ + "", tag);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +158,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
NBTOutputStream nbtos = getEntityCreateOS();
|
NBTOutputStream nbtos = getEntityCreateOS();
|
||||||
nbtos.writeNamedTag(entityCreateSize++ + "", tag);
|
nbtos.writeNamedTag(entityCreateSize++ + "", tag);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +197,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
}
|
}
|
||||||
return change;
|
return change;
|
||||||
} catch (Exception ignoreEOF) {
|
} catch (Exception ignoreEOF) {
|
||||||
ignoreEOF.printStackTrace();
|
MainUtil.handleError(ignoreEOF);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -212,7 +213,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -258,7 +259,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -276,7 +277,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,7 +309,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -326,7 +327,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,7 +371,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return new ArrayList<Change>().iterator();
|
return new ArrayList<Change>().iterator();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.object.changeset;
|
package com.boydti.fawe.object.changeset;
|
||||||
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
import com.sk89q.jnbt.NBTOutputStream;
|
import com.sk89q.jnbt.NBTOutputStream;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -78,7 +79,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.boydti.fawe.config.Settings;
|
|||||||
import com.boydti.fawe.object.BufferedRandomAccessFile;
|
import com.boydti.fawe.object.BufferedRandomAccessFile;
|
||||||
import com.boydti.fawe.object.IntegerTrio;
|
import com.boydti.fawe.object.IntegerTrio;
|
||||||
import com.boydti.fawe.object.RunnableVal2;
|
import com.boydti.fawe.object.RunnableVal2;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
@ -94,7 +95,7 @@ public class DiskOptimizedClipboard extends FaweClipboard {
|
|||||||
clipboard.setOrigin(new Vector(ox, oy, oz));
|
clipboard.setOrigin(new Vector(ox, oy, oz));
|
||||||
return clipboard;
|
return clipboard;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -115,7 +116,7 @@ public class DiskOptimizedClipboard extends FaweClipboard {
|
|||||||
}
|
}
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ public class DiskOptimizedClipboard extends FaweClipboard {
|
|||||||
raf.write((byte) (offset.getBlockZ() >> 8));
|
raf.write((byte) (offset.getBlockZ() >> 8));
|
||||||
raf.write((byte) (offset.getBlockZ()));
|
raf.write((byte) (offset.getBlockZ()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ public class DiskOptimizedClipboard extends FaweClipboard {
|
|||||||
file.setWritable(true);
|
file.setWritable(true);
|
||||||
System.gc();
|
System.gc();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ public class DiskOptimizedClipboard extends FaweClipboard {
|
|||||||
tmp = null;
|
tmp = null;
|
||||||
System.gc();
|
System.gc();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +253,7 @@ public class DiskOptimizedClipboard extends FaweClipboard {
|
|||||||
task.run(pos, block);
|
task.run(pos, block);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +286,7 @@ public class DiskOptimizedClipboard extends FaweClipboard {
|
|||||||
}
|
}
|
||||||
return block;
|
return block;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return EditSession.nullBlock;
|
return EditSession.nullBlock;
|
||||||
}
|
}
|
||||||
@ -313,7 +314,7 @@ public class DiskOptimizedClipboard extends FaweClipboard {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public abstract class FaweQueue {
|
|||||||
|
|
||||||
public abstract boolean setBiome(final int x, final int z, final BaseBiome biome);
|
public abstract boolean setBiome(final int x, final int z, final BaseBiome biome);
|
||||||
|
|
||||||
public abstract FaweChunk<?> getChunk(int x, int z);
|
public abstract FaweChunk<?> getFaweChunk(int x, int z);
|
||||||
|
|
||||||
public abstract void setChunk(final FaweChunk<?> chunk);
|
public abstract void setChunk(final FaweChunk<?> chunk);
|
||||||
|
|
||||||
@ -139,6 +139,8 @@ public abstract class FaweQueue {
|
|||||||
|
|
||||||
public abstract int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException;
|
public abstract int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException;
|
||||||
|
|
||||||
|
public abstract CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException;
|
||||||
|
|
||||||
public int getCombinedId4Data(int x, int y, int z, int def) {
|
public int getCombinedId4Data(int x, int y, int z, int def) {
|
||||||
try {
|
try {
|
||||||
return getCombinedId4Data(x, y, z);
|
return getCombinedId4Data(x, y, z);
|
||||||
|
@ -22,6 +22,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -79,7 +80,7 @@ public class MainUtil {
|
|||||||
URL url = Fawe.class.getProtectionDomain().getCodeSource().getLocation();
|
URL url = Fawe.class.getProtectionDomain().getCodeSource().getLocation();
|
||||||
return new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath());
|
return new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath());
|
||||||
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
|
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return new File(Fawe.imp().getDirectory().getParentFile(), "FastAsyncWorldEdit.jar");
|
return new File(Fawe.imp().getDirectory().getParentFile(), "FastAsyncWorldEdit.jar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +131,7 @@ public class MainUtil {
|
|||||||
return newFile;
|
return newFile;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
Fawe.debug("&cCould not save " + resource);
|
Fawe.debug("&cCould not save " + resource);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -172,10 +173,76 @@ public class MainUtil {
|
|||||||
BBC.COMPRESSED.send(actor, saved, ratio);
|
BBC.COMPRESSED.send(actor, saved, ratio);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void handleError(Throwable e) {
|
||||||
|
handleError(e, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handleError(Throwable e, boolean debug) {
|
||||||
|
if (e == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!debug) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String header = "====== FAWE: " + e.getLocalizedMessage() + " ======";
|
||||||
|
Fawe.debug(header);
|
||||||
|
String[] trace = getTrace(e);
|
||||||
|
for (int i = 0; i < trace.length && i < 8; i++) {
|
||||||
|
Fawe.debug(" - " + trace[i]);
|
||||||
|
}
|
||||||
|
String[] cause = getTrace(e.getCause());
|
||||||
|
Fawe.debug("Cause: " + (cause.length == 0 ? "N/A" : ""));
|
||||||
|
for (int i = 0; i < cause.length && i < 8; i++) {
|
||||||
|
Fawe.debug(" - " + cause[i]);
|
||||||
|
}
|
||||||
|
Fawe.debug(StringMan.repeat("=", header.length()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getTrace(Throwable e) {
|
||||||
|
if (e == null) {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
StackTraceElement[] elems = e.getStackTrace();
|
||||||
|
String[] msg = new String[elems.length];//[elems.length + 1];
|
||||||
|
// HashSet<String> packages = new HashSet<>();
|
||||||
|
for (int i = 0; i < elems.length; i++) {
|
||||||
|
StackTraceElement elem = elems[i];
|
||||||
|
elem.getLineNumber();
|
||||||
|
String methodName = elem.getMethodName();
|
||||||
|
int index = elem.getClassName().lastIndexOf('.');
|
||||||
|
String className = elem.getClassName();
|
||||||
|
// if (!(index == -1 || className.startsWith("io.netty") || className.startsWith("javax") || className.startsWith("java") || className.startsWith("sun") || className.startsWith("net.minecraft") || className.startsWith("org.spongepowered") || className.startsWith("org.bukkit") || className.startsWith("com.google"))) {
|
||||||
|
// packages.add(className.substring(0, index-1));
|
||||||
|
// }
|
||||||
|
String name = className.substring(index == -1 ? 0 : index + 1);
|
||||||
|
name = name.length() == 0 ? elem.getClassName() : name;
|
||||||
|
String argString = "(...)";
|
||||||
|
try {
|
||||||
|
for (Method method : Class.forName(elem.getClassName()).getDeclaredMethods()) {
|
||||||
|
if (method.getName().equals(methodName)) {
|
||||||
|
Class<?>[] params = method.getParameterTypes();
|
||||||
|
argString = "";
|
||||||
|
String prefix = "";
|
||||||
|
for (Class param : params) {
|
||||||
|
argString += prefix + param.getSimpleName();
|
||||||
|
prefix = ",";
|
||||||
|
}
|
||||||
|
argString = "[" + method.getReturnType().getSimpleName() + "](" + argString + ")";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Throwable ignore) {}
|
||||||
|
msg[i] = name + "." + methodName + argString + ":" + elem.getLineNumber();
|
||||||
|
}
|
||||||
|
// msg[msg.length-1] = StringMan.getString(packages);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
public static void smoothArray(int[] data, int width, int radius, int weight) {
|
public static void smoothArray(int[] data, int width, int radius, int weight) {
|
||||||
int[] copy = data.clone();
|
int[] copy = data.clone();
|
||||||
int length = data.length / width;
|
int length = data.length / width;
|
||||||
|
@ -53,7 +53,7 @@ public class ReflectionUtils {
|
|||||||
preClassM = "net.minecraft.server." + verM;
|
preClassM = "net.minecraft.server." + verM;
|
||||||
}
|
}
|
||||||
} catch (final Exception ignored) {
|
} catch (final Exception ignored) {
|
||||||
ignored.printStackTrace();
|
MainUtil.handleError(ignored);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ public static <T, V> Map<T, V> getMap(Map<T, V> map) {
|
|||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
return (Map<T, V>) m.get(map);
|
return (Map<T, V>) m.get(map);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ public static <T> List<T> getList(List<T> list) {
|
|||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
return (List<T>) m.get(list);
|
return (List<T>) m.get(list);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,12 +103,12 @@ public class SetQueue {
|
|||||||
try {
|
try {
|
||||||
thread.join();
|
thread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
} finally {
|
} finally {
|
||||||
// Enable it again (note that we are still on the main thread)
|
// Enable it again (note that we are still on the main thread)
|
||||||
SET_TASK.value2.endSet(true);
|
SET_TASK.value2.endSet(true);
|
||||||
|
@ -164,7 +164,7 @@ public abstract class TaskManager {
|
|||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
this.value = e;
|
this.value = e;
|
||||||
} catch (Throwable neverHappens) {
|
} catch (Throwable neverHappens) {
|
||||||
neverHappens.printStackTrace();
|
MainUtil.handleError(neverHappens);
|
||||||
} finally {
|
} finally {
|
||||||
running.set(false);
|
running.set(false);
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ public abstract class TaskManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
if (run.value != null) {
|
if (run.value != null) {
|
||||||
throw run.value;
|
throw run.value;
|
||||||
|
@ -29,7 +29,7 @@ public class WEManager {
|
|||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(parent, new NullExtent((Extent) field.get(parent), reason));
|
field.set(parent, new NullExtent((Extent) field.get(parent), reason));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ public class WEManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, false, false);
|
}, false, false);
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.wrappers;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.EditSessionFactory;
|
import com.sk89q.worldedit.EditSessionFactory;
|
||||||
@ -200,7 +201,7 @@ public class PlayerWrapper implements Player {
|
|||||||
session.remember(edit);
|
session.remember(edit);
|
||||||
}
|
}
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,6 +5,7 @@ import com.boydti.fawe.object.RunnableVal;
|
|||||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
import com.sk89q.worldedit.BlockVector2D;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -97,7 +98,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
try {
|
try {
|
||||||
this.value = parent.generateTree(editSession, pt);
|
this.value = parent.generateTree(editSession, pt);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -111,7 +112,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
try {
|
try {
|
||||||
this.value = parent.generateBigTree(editSession, pt);
|
this.value = parent.generateBigTree(editSession, pt);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -125,7 +126,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
try {
|
try {
|
||||||
this.value = parent.generateBirchTree(editSession, pt);
|
this.value = parent.generateBirchTree(editSession, pt);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -139,7 +140,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
try {
|
try {
|
||||||
this.value = parent.generateRedwoodTree(editSession, pt);
|
this.value = parent.generateRedwoodTree(editSession, pt);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -153,7 +154,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
try {
|
try {
|
||||||
this.value = parent.generateTallRedwoodTree(editSession, pt);
|
this.value = parent.generateTallRedwoodTree(editSession, pt);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -333,7 +334,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
try {
|
try {
|
||||||
this.value = parent.generateTree(editSession, position);
|
this.value = parent.generateTree(editSession, position);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -42,6 +42,7 @@ import com.boydti.fawe.object.extent.NullExtent;
|
|||||||
import com.boydti.fawe.object.extent.ProcessedWEExtent;
|
import com.boydti.fawe.object.extent.ProcessedWEExtent;
|
||||||
import com.boydti.fawe.object.progress.DefaultProgressTracker;
|
import com.boydti.fawe.object.progress.DefaultProgressTracker;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MemUtil;
|
import com.boydti.fawe.util.MemUtil;
|
||||||
import com.boydti.fawe.util.Perm;
|
import com.boydti.fawe.util.Perm;
|
||||||
import com.boydti.fawe.util.SetQueue;
|
import com.boydti.fawe.util.SetQueue;
|
||||||
@ -659,7 +660,7 @@ public class EditSession implements Extent {
|
|||||||
BaseBlock block = this.world.getBlock(new Vector(x, y, z));
|
BaseBlock block = this.world.getBlock(new Vector(x, y, z));
|
||||||
return block;
|
return block;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
return FaweCache.CACHE_BLOCK[combinedId4Data];
|
return FaweCache.CACHE_BLOCK[combinedId4Data];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
|||||||
|
|
||||||
final int id = block.getId();
|
final int id = block.getId();
|
||||||
final byte data = (byte) block.getData();
|
final byte data = (byte) block.getData();
|
||||||
final FaweChunk<?> fc = queue.getChunk(0, 0);
|
final FaweChunk<?> fc = queue.getFaweChunk(0, 0);
|
||||||
fc.fillCuboid(0, 15, minY, maxY, 0, 15, id, data);
|
fc.fillCuboid(0, 15, minY, maxY, 0, 15, id, data);
|
||||||
fc.optimize();
|
fc.optimize();
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
|||||||
newChunk = fc.copy(true);
|
newChunk = fc.copy(true);
|
||||||
newChunk.setLoc(queue, value[0], value[1]);
|
newChunk.setLoc(queue, value[0], value[1]);
|
||||||
} else {
|
} else {
|
||||||
newChunk = queue.getChunk(value[0], value[1]);
|
newChunk = queue.getFaweChunk(value[0], value[1]);
|
||||||
newChunk.fillCuboid(value[2] & 15, value[4] & 15, minY, maxY, value[3] & 15, value[5] & 15, id, data);
|
newChunk.fillCuboid(value[2] & 15, value[4] & 15, minY, maxY, value[3] & 15, value[5] & 15, id, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.platform;
|
|||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
@ -413,7 +414,7 @@ public class PlatformManager {
|
|||||||
} else {
|
} else {
|
||||||
actor.printError("Please report this error: [See console]");
|
actor.printError("Please report this error: [See console]");
|
||||||
actor.printRaw(e.getClass().getName() + ": " + e.getMessage());
|
actor.printRaw(e.getClass().getName() + ": " + e.getMessage());
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,7 +501,7 @@ public class PlatformManager {
|
|||||||
} else {
|
} else {
|
||||||
player.printError("Please report this error: [See console]");
|
player.printError("Please report this error: [See console]");
|
||||||
player.printRaw(e.getClass().getName() + ": " + e.getMessage());
|
player.printRaw(e.getClass().getName() + ": " + e.getMessage());
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.jpountz.lz4;
|
package net.jpountz.lz4;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -99,7 +100,7 @@ public class LZ4StreamTest {
|
|||||||
assertEquals(-1, is.read(new byte[100]));
|
assertEquals(-1, is.read(new byte[100]));
|
||||||
assertEquals(-1, is.read());
|
assertEquals(-1, is.read());
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
t.printStackTrace();
|
MainUtil.handleError(t);
|
||||||
Assert.fail("Exception was thrown. Seed value was " + seed);
|
Assert.fail("Exception was thrown. Seed value was " + seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.object.FaweCommand;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -39,7 +40,7 @@ public class FaweForge implements IFawe {
|
|||||||
try {
|
try {
|
||||||
Fawe.set(this);
|
Fawe.set(this);
|
||||||
} catch (InstanceAlreadyExistsException e) {
|
} catch (InstanceAlreadyExistsException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
package com.boydti.fawe.forge;
|
package com.boydti.fawe.forge;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
import cpw.mods.fml.common.Loader;
|
import cpw.mods.fml.common.Loader;
|
||||||
@ -361,7 +362,7 @@ public class ForgeMetrics {
|
|||||||
gzos = new GZIPOutputStream(baos);
|
gzos = new GZIPOutputStream(baos);
|
||||||
gzos.write(input.getBytes("UTF-8"));
|
gzos.write(input.getBytes("UTF-8"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (gzos != null) try {
|
if (gzos != null) try {
|
||||||
gzos.close();
|
gzos.close();
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package com.boydti.fawe.forge;
|
package com.boydti.fawe.forge;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
|
||||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
|
||||||
|
|
||||||
public class ForgeTaskMan extends TaskManager {
|
public class ForgeTaskMan extends TaskManager {
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
later(this, interval);
|
later(this, interval);
|
||||||
}
|
}
|
||||||
@ -68,7 +69,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
item.run();
|
item.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
laterAsync(this, interval);
|
laterAsync(this, interval);
|
||||||
}
|
}
|
||||||
@ -127,7 +128,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -149,7 +150,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
async(r);
|
async(r);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
import com.boydti.fawe.object.IntegerPair;
|
import com.boydti.fawe.object.IntegerPair;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
import com.boydti.fawe.object.PseudoRandom;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -69,12 +70,40 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||||
return getCachedChunk(world, x, z) != null;
|
Map<ChunkPosition, TileEntity> tiles = chunk.chunkTileEntityMap;
|
||||||
|
ChunkPosition pos = new ChunkPosition(x, y, z);
|
||||||
|
TileEntity tile = tiles.get(pos);
|
||||||
|
return tile != null ? getTag(tile) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getTag(TileEntity tile) {
|
||||||
|
try {
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
tile.readFromNBT(tag); // readTagIntoEntity
|
||||||
|
return (CompoundTag) methodToNative.invoke(null, tag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MainUtil.handleError(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExtendedBlockStorage[] getCachedChunk(World world, int cx, int cz) {
|
public Chunk getChunk(World world, int x, int z) {
|
||||||
|
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
|
||||||
|
if (chunk != null && !chunk.isChunkLoaded) {
|
||||||
|
chunk.onChunkLoad();
|
||||||
|
}
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
||||||
|
return getCachedSections(world, x, z) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
|
||||||
Chunk chunk = world.getChunkProvider().provideChunk(cx, cz);
|
Chunk chunk = world.getChunkProvider().provideChunk(cx, cz);
|
||||||
if (chunk != null && !chunk.isChunkLoaded) {
|
if (chunk != null && !chunk.isChunkLoaded) {
|
||||||
chunk.onChunkLoad();
|
chunk.onChunkLoad();
|
||||||
@ -173,7 +202,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
mcChunk.populateChunk(chunkProvider, chunkProvider, x, z);
|
mcChunk.populateChunk(chunkProvider, chunkProvider, x, z);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
MainUtil.handleError(t);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -416,7 +445,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
int[][] biomes = fs.biomes;
|
int[][] biomes = fs.biomes;
|
||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
@ -452,7 +481,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
public CharFaweChunk getPrevious(CharFaweChunk fs, ExtendedBlockStorage[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
public CharFaweChunk getPrevious(CharFaweChunk fs, ExtendedBlockStorage[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
||||||
Map<ChunkPosition, TileEntity> tiles = (Map<ChunkPosition, TileEntity>) tilesGeneric;
|
Map<ChunkPosition, TileEntity> tiles = (Map<ChunkPosition, TileEntity>) tilesGeneric;
|
||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = new char[16][];
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
@ -486,7 +515,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
if (entities != null) {
|
if (entities != null) {
|
||||||
for (Collection<Entity> entityList : entities) {
|
for (Collection<Entity> entityList : entities) {
|
||||||
for (Entity ent : entityList) {
|
for (Entity ent : entityList) {
|
||||||
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && !createdEntities.contains(ent.getUniqueID()))) {
|
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && createdEntities.contains(ent.getUniqueID()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int x = ((int) Math.round(ent.posX) & 15);
|
int x = ((int) Math.round(ent.posX) & 15);
|
||||||
@ -515,7 +544,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk getChunk(int x, int z) {
|
public FaweChunk getFaweChunk(int x, int z) {
|
||||||
return new ForgeChunk_All(this, x, z);
|
return new ForgeChunk_All(this, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,7 +640,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.object.FaweCommand;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
@ -38,7 +39,7 @@ public class FaweForge implements IFawe {
|
|||||||
try {
|
try {
|
||||||
Fawe.set(this);
|
Fawe.set(this);
|
||||||
} catch (InstanceAlreadyExistsException e) {
|
} catch (InstanceAlreadyExistsException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
package com.boydti.fawe.forge;
|
package com.boydti.fawe.forge;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -361,7 +362,7 @@ public class ForgeMetrics {
|
|||||||
gzos = new GZIPOutputStream(baos);
|
gzos = new GZIPOutputStream(baos);
|
||||||
gzos.write(input.getBytes("UTF-8"));
|
gzos.write(input.getBytes("UTF-8"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (gzos != null) try {
|
if (gzos != null) try {
|
||||||
gzos.close();
|
gzos.close();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.forge;
|
package com.boydti.fawe.forge;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
@ -44,7 +45,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
later(this, interval);
|
later(this, interval);
|
||||||
}
|
}
|
||||||
@ -68,7 +69,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
item.run();
|
item.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
laterAsync(this, interval);
|
laterAsync(this, interval);
|
||||||
}
|
}
|
||||||
@ -127,7 +128,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -149,7 +150,7 @@ public class ForgeTaskMan extends TaskManager {
|
|||||||
try {
|
try {
|
||||||
async(r);
|
async(r);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.boydti.fawe.object.FaweChunk;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
import com.boydti.fawe.object.PseudoRandom;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -65,6 +66,36 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||||
|
Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
|
||||||
|
pos.set(x, y, z);
|
||||||
|
TileEntity tile = tiles.get(pos);
|
||||||
|
return tile != null ? getTag(tile) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getTag(TileEntity tile) {
|
||||||
|
try {
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
tile.readFromNBT(tag); // readTagIntoEntity
|
||||||
|
return (CompoundTag) methodToNative.invoke(null, tag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MainUtil.handleError(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getChunk(World world, int x, int z) {
|
||||||
|
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
|
||||||
|
if (chunk != null && !chunk.isLoaded()) {
|
||||||
|
chunk.onChunkLoad();
|
||||||
|
}
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChunkLoaded(int x, int z) {
|
public boolean isChunkLoaded(int x, int z) {
|
||||||
return getWorld().getChunkProvider().chunkExists(x, z);
|
return getWorld().getChunkProvider().chunkExists(x, z);
|
||||||
@ -101,7 +132,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
|
Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
|
||||||
droppedChunksSet.remove(pos);
|
droppedChunksSet.remove(pos);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
chunkServer.id2ChunkMap.remove(pos);
|
chunkServer.id2ChunkMap.remove(pos);
|
||||||
mcChunk = chunkProvider.provideChunk(x, z);
|
mcChunk = chunkProvider.provideChunk(x, z);
|
||||||
@ -116,11 +147,11 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
||||||
return getCachedChunk(world, x, z) != null;
|
return getCachedSections(world, x, z) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExtendedBlockStorage[] getCachedChunk(World world, int x, int z) {
|
public ExtendedBlockStorage[] getCachedSections(World world, int x, int z) {
|
||||||
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
|
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
|
||||||
if (chunk != null && !chunk.isLoaded()) {
|
if (chunk != null && !chunk.isLoaded()) {
|
||||||
chunk.onChunkLoad();
|
chunk.onChunkLoad();
|
||||||
@ -184,7 +215,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
int X = fc.getX() << 4;
|
int X = fc.getX() << 4;
|
||||||
int Z = fc.getZ() << 4;
|
int Z = fc.getZ() << 4;
|
||||||
|
|
||||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
ExtendedBlockStorage section = sections[j];
|
ExtendedBlockStorage section = sections[j];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
@ -249,7 +279,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -259,7 +289,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
public CharFaweChunk getPrevious(CharFaweChunk fs, ExtendedBlockStorage[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
public CharFaweChunk getPrevious(CharFaweChunk fs, ExtendedBlockStorage[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
||||||
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
||||||
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = new char[16][];
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
@ -291,7 +321,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
if (entities != null) {
|
if (entities != null) {
|
||||||
for (Collection<Entity> entityList : entities) {
|
for (Collection<Entity> entityList : entities) {
|
||||||
for (Entity ent : entityList) {
|
for (Entity ent : entityList) {
|
||||||
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && !createdEntities.contains(ent.getUniqueID()))) {
|
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && createdEntities.contains(ent.getUniqueID()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int x = ((int) Math.round(ent.posX) & 15);
|
int x = ((int) Math.round(ent.posX) & 15);
|
||||||
@ -503,7 +533,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
int[][] biomes = fs.biomes;
|
int[][] biomes = fs.biomes;
|
||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
@ -557,7 +587,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk<Chunk> getChunk(int x, int z) {
|
public FaweChunk<Chunk> getFaweChunk(int x, int z) {
|
||||||
return new ForgeChunk_All(this, x, z);
|
return new ForgeChunk_All(this, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import com.boydti.fawe.regions.FaweMaskManager;
|
|||||||
import com.boydti.fawe.sponge.v1_8.SpongeQueue_1_8;
|
import com.boydti.fawe.sponge.v1_8.SpongeQueue_1_8;
|
||||||
import com.boydti.fawe.sponge.v1_8.SpongeQueue_ALL;
|
import com.boydti.fawe.sponge.v1_8.SpongeQueue_ALL;
|
||||||
import com.boydti.fawe.util.FaweQueue;
|
import com.boydti.fawe.util.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.forge.ForgeWorldEdit;
|
import com.sk89q.worldedit.forge.ForgeWorldEdit;
|
||||||
@ -50,7 +51,7 @@ public class FaweSponge implements IFawe {
|
|||||||
try {
|
try {
|
||||||
Fawe.set(this);
|
Fawe.set(this);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
TaskManager.IMP.later(() -> SpongeUtil.initBiomeCache(), 0);
|
TaskManager.IMP.later(() -> SpongeUtil.initBiomeCache(), 0);
|
||||||
}
|
}
|
||||||
@ -114,7 +115,7 @@ public class FaweSponge implements IFawe {
|
|||||||
try {
|
try {
|
||||||
return new SpongeQueue_1_8(world);
|
return new SpongeQueue_1_8(world);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new SpongeQueue_ALL(world);
|
return new SpongeQueue_ALL(world);
|
||||||
|
@ -29,6 +29,7 @@ package com.boydti.fawe.sponge;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -137,7 +138,7 @@ public class SpongeMetrics {
|
|||||||
gzos = new GZIPOutputStream(baos);
|
gzos = new GZIPOutputStream(baos);
|
||||||
gzos.write(input.getBytes("UTF-8"));
|
gzos.write(input.getBytes("UTF-8"));
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (gzos != null) {
|
if (gzos != null) {
|
||||||
try {
|
try {
|
||||||
@ -265,7 +266,7 @@ public class SpongeMetrics {
|
|||||||
guid = config.getNode("mcstats.guid").getString();
|
guid = config.getNode("mcstats.guid").getString();
|
||||||
debug = config.getNode("mcstats.debug").getBoolean();
|
debug = config.getNode("mcstats.debug").getBoolean();
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.sponge;
|
package com.boydti.fawe.sponge;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -58,7 +59,7 @@ public class SpongeUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.boydti.fawe.object.BytePair;
|
|||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
import com.boydti.fawe.object.PseudoRandom;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -65,6 +66,36 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTileEntity(net.minecraft.world.chunk.Chunk chunk, int x, int y, int z) {
|
||||||
|
Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
|
||||||
|
pos.set(x, y, z);
|
||||||
|
TileEntity tile = tiles.get(pos);
|
||||||
|
return tile != null ? getTag(tile) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getTag(TileEntity tile) {
|
||||||
|
try {
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
tile.readFromNBT(tag); // readTagIntoEntity
|
||||||
|
return (CompoundTag) methodToNative.invoke(null, tag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MainUtil.handleError(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public net.minecraft.world.chunk.Chunk getChunk(World world, int x, int z) {
|
||||||
|
net.minecraft.world.chunk.Chunk chunk = ((net.minecraft.world.World) world).getChunkProvider().provideChunk(x, z);
|
||||||
|
if (chunk != null && !chunk.isLoaded()) {
|
||||||
|
chunk.onChunkLoad();
|
||||||
|
}
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshChunk(World world, net.minecraft.world.chunk.Chunk chunk) {
|
public void refreshChunk(World world, net.minecraft.world.chunk.Chunk chunk) {
|
||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
@ -145,7 +176,7 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -154,7 +185,7 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
public CharFaweChunk getPrevious(CharFaweChunk fs, ExtendedBlockStorage[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
public CharFaweChunk getPrevious(CharFaweChunk fs, ExtendedBlockStorage[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
|
||||||
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
||||||
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = new char[16][];
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
@ -186,7 +217,7 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
if (entities != null) {
|
if (entities != null) {
|
||||||
for (Collection<Entity> entityList : entities) {
|
for (Collection<Entity> entityList : entities) {
|
||||||
for (Entity ent : entityList) {
|
for (Entity ent : entityList) {
|
||||||
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && !createdEntities.contains(ent.getUniqueID()))) {
|
if (ent instanceof EntityPlayer || (!createdEntities.isEmpty() && createdEntities.contains(ent.getUniqueID()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int x = ((int) Math.round(ent.posX) & 15);
|
int x = ((int) Math.round(ent.posX) & 15);
|
||||||
@ -398,7 +429,7 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
int[][] biomes = fs.biomes;
|
int[][] biomes = fs.biomes;
|
||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
@ -431,7 +462,7 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk<net.minecraft.world.chunk.Chunk> getChunk(int x, int z) {
|
public FaweChunk<net.minecraft.world.chunk.Chunk> getFaweChunk(int x, int z) {
|
||||||
return new SpongeChunk_1_8(this, x, z);
|
return new SpongeChunk_1_8(this, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +497,6 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
int X = fc.getX() << 4;
|
int X = fc.getX() << 4;
|
||||||
int Z = fc.getZ() << 4;
|
int Z = fc.getZ() << 4;
|
||||||
|
|
||||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
ExtendedBlockStorage section = sections[j];
|
ExtendedBlockStorage section = sections[j];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
@ -531,7 +561,7 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -568,11 +598,11 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
||||||
return getCachedChunk(world, x, z) != null;
|
return getCachedSections(world, x, z) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExtendedBlockStorage[] getCachedChunk(World world, int cx, int cz) {
|
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
|
||||||
Chunk chunk = world.loadChunk(cx, 0, cz, true).orElse(null);
|
Chunk chunk = world.loadChunk(cx, 0, cz, true).orElse(null);
|
||||||
return ((net.minecraft.world.chunk.Chunk) chunk).getBlockStorageArray();
|
return ((net.minecraft.world.chunk.Chunk) chunk).getBlockStorageArray();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,10 @@ import com.boydti.fawe.example.NMSMappedFaweQueue;
|
|||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
import com.boydti.fawe.object.PseudoRandom;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -17,8 +20,11 @@ import java.util.UUID;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.nbt.NBTBase;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.NetHandlerPlayServer;
|
import net.minecraft.network.NetHandlerPlayServer;
|
||||||
import net.minecraft.network.play.server.S21PacketChunkData;
|
import net.minecraft.network.play.server.S21PacketChunkData;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.LongHashMap;
|
import net.minecraft.util.LongHashMap;
|
||||||
import net.minecraft.world.ChunkCoordIntPair;
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
@ -38,8 +44,17 @@ import org.spongepowered.api.world.extent.worker.MutableBlockVolumeWorker;
|
|||||||
import org.spongepowered.api.world.extent.worker.procedure.BlockVolumeMapper;
|
import org.spongepowered.api.world.extent.worker.procedure.BlockVolumeMapper;
|
||||||
|
|
||||||
public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.world.chunk.Chunk, ExtendedBlockStorage[], char[]> {
|
public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.world.chunk.Chunk, ExtendedBlockStorage[], char[]> {
|
||||||
|
private Method methodToNative;
|
||||||
|
|
||||||
public SpongeQueue_ALL(String world) {
|
public SpongeQueue_ALL(String world) {
|
||||||
super(world);
|
super(world);
|
||||||
|
try {
|
||||||
|
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
|
||||||
|
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
|
||||||
|
methodToNative.setAccessible(true);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,6 +86,33 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTileEntity(net.minecraft.world.chunk.Chunk chunk, int x, int y, int z) {
|
||||||
|
Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
|
||||||
|
TileEntity tile = tiles.get(new BlockPos(x, y, z));
|
||||||
|
return tile != null ? getTag(tile) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getTag(TileEntity tile) {
|
||||||
|
try {
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
tile.readFromNBT(tag); // readTagIntoEntity
|
||||||
|
return (CompoundTag) methodToNative.invoke(null, tag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MainUtil.handleError(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public net.minecraft.world.chunk.Chunk getChunk(World world, int x, int z) {
|
||||||
|
net.minecraft.world.chunk.Chunk chunk = ((net.minecraft.world.World) world).getChunkProvider().provideChunk(x, z);
|
||||||
|
if (chunk != null && !chunk.isLoaded()) {
|
||||||
|
chunk.onChunkLoad();
|
||||||
|
}
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getCachedSection(ExtendedBlockStorage[] chunk, int cy) {
|
public char[] getCachedSection(ExtendedBlockStorage[] chunk, int cy) {
|
||||||
ExtendedBlockStorage value = chunk[cy];
|
ExtendedBlockStorage value = chunk[cy];
|
||||||
@ -124,7 +166,7 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -188,7 +230,7 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk<net.minecraft.world.chunk.Chunk> getChunk(int x, int z) {
|
public FaweChunk<net.minecraft.world.chunk.Chunk> getFaweChunk(int x, int z) {
|
||||||
return new SpongeChunk_1_8(this, x, z);
|
return new SpongeChunk_1_8(this, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +335,7 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
if (Thread.currentThread() == Fawe.get().getMainThread()) {
|
||||||
e.printStackTrace();
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -330,11 +372,11 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
public boolean loadChunk(World world, int x, int z, boolean generate) {
|
||||||
return getCachedChunk(world, x, z) != null;
|
return getCachedSections(world, x, z) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExtendedBlockStorage[] getCachedChunk(World world, int cx, int cz) {
|
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
|
||||||
Chunk chunk = world.loadChunk(cx, 0, cz, true).orElse(null);
|
Chunk chunk = world.loadChunk(cx, 0, cz, true).orElse(null);
|
||||||
return ((net.minecraft.world.chunk.Chunk) chunk).getBlockStorageArray();
|
return ((net.minecraft.world.chunk.Chunk) chunk).getBlockStorageArray();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user