Fixes for thermos
This commit is contained in:
parent
6400505807
commit
91450e569b
@ -29,6 +29,7 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
@ -150,6 +151,14 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
Player player = (Player) obj;
|
Player player = (Player) obj;
|
||||||
FawePlayer existing = Fawe.get().getCachedPlayer(player.getName());
|
FawePlayer existing = Fawe.get().getCachedPlayer(player.getName());
|
||||||
return existing != null ? existing : new BukkitPlayer(player);
|
return existing != null ? existing : new BukkitPlayer(player);
|
||||||
|
} else if (obj != null && obj.getClass().getName().contains("EntityPlayer")) {
|
||||||
|
try {
|
||||||
|
Method method = obj.getClass().getDeclaredMethod("getBukkitEntity");
|
||||||
|
return wrap(method.invoke(obj));
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
import com.sk89q.worldedit.world.registry.WorldData;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -54,7 +55,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
* @param <V>
|
* @param <V>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static <V> FawePlayer<V> wrap(final Object obj) {
|
public static <V> FawePlayer<V> wrap(Object obj) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return FakePlayer.getConsole().toFawePlayer();
|
return FakePlayer.getConsole().toFawePlayer();
|
||||||
}
|
}
|
||||||
@ -93,6 +94,15 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
FakePlayer fake = new FakePlayer(actor.getName(), actor.getUniqueId(), actor);
|
FakePlayer fake = new FakePlayer(actor.getName(), actor.getUniqueId(), actor);
|
||||||
return fake.toFawePlayer();
|
return fake.toFawePlayer();
|
||||||
}
|
}
|
||||||
|
if (obj != null && obj.getClass().getName().contains("CraftPlayer") && !Fawe.imp().getPlatform().equals("bukkit")) {
|
||||||
|
try {
|
||||||
|
Method methodGetHandle = obj.getClass().getDeclaredMethod("getHandle");
|
||||||
|
obj = methodGetHandle.invoke(obj);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
return Fawe.imp().wrap(obj);
|
return Fawe.imp().wrap(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1334,9 +1334,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
|||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
return visitor.getAffected();
|
return visitor.getAffected();
|
||||||
}
|
}
|
||||||
final boolean[] ids = new boolean[256];
|
final boolean[] ids = new boolean[4096];
|
||||||
for (final int id : searchIDs) {
|
for (final int id : searchIDs) {
|
||||||
if ((id < 256) && (id >= 0)) {
|
if ((id < 4096) && (id >= 0)) {
|
||||||
ids[id] = true;
|
ids[id] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,29 +32,32 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||||||
public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||||
|
|
||||||
public final byte[][] byteIds;
|
public final byte[][] byteIds;
|
||||||
|
public final NibbleArray[] extended;
|
||||||
public final NibbleArray[] datas;
|
public final NibbleArray[] datas;
|
||||||
|
|
||||||
public ForgeChunk_All(FaweQueue parent, int x, int z) {
|
public ForgeChunk_All(FaweQueue parent, int x, int z) {
|
||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
this.byteIds = new byte[16][];
|
this.byteIds = new byte[16][];
|
||||||
|
this.extended = new NibbleArray[16];
|
||||||
this.datas = new NibbleArray[16];
|
this.datas = new NibbleArray[16];
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForgeChunk_All(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, byte[] heightMap, byte[][] byteIds, NibbleArray[] datas) {
|
public ForgeChunk_All(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, byte[] heightMap, byte[][] byteIds, NibbleArray[] datas, NibbleArray[] extended) {
|
||||||
super(parent, x, z, ids, count, air, heightMap);
|
super(parent, x, z, ids, count, air, heightMap);
|
||||||
this.byteIds = byteIds;
|
this.byteIds = byteIds;
|
||||||
this.datas = datas;
|
this.datas = datas;
|
||||||
|
this.extended = extended;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharFaweChunk copy(boolean shallow) {
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
ForgeChunk_All copy;
|
ForgeChunk_All copy;
|
||||||
if (shallow) {
|
if (shallow) {
|
||||||
copy = new ForgeChunk_All(getParent(), getX(), getZ(), ids, count, air, heightMap, byteIds, datas);
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), ids, count, air, heightMap, byteIds, datas, extended);
|
||||||
copy.biomes = biomes;
|
copy.biomes = biomes;
|
||||||
copy.chunk = chunk;
|
copy.chunk = chunk;
|
||||||
} else {
|
} else {
|
||||||
copy = new ForgeChunk_All(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), heightMap.clone(), (byte[][]) MainUtil.copyNd(byteIds), datas.clone());
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), heightMap.clone(), (byte[][]) MainUtil.copyNd(byteIds), datas.clone(), extended.clone());
|
||||||
copy.biomes = biomes;
|
copy.biomes = biomes;
|
||||||
copy.chunk = chunk;
|
copy.chunk = chunk;
|
||||||
copy.biomes = biomes.clone();
|
copy.biomes = biomes.clone();
|
||||||
@ -77,6 +80,10 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
return datas[i];
|
return datas[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NibbleArray getExtendedIdArray(int i) {
|
||||||
|
return extended[i];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(int x, int y, int z, int id, int data) {
|
public void setBlock(int x, int y, int z, int id, int data) {
|
||||||
int i = FaweCache.CACHE_I[y][z][x];
|
int i = FaweCache.CACHE_I[y][z][x];
|
||||||
@ -122,6 +129,13 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
}
|
}
|
||||||
dataArray.set(x, y & 15, z, data);
|
dataArray.set(x, y & 15, z, data);
|
||||||
}
|
}
|
||||||
|
if (id > 255) {
|
||||||
|
NibbleArray nibble = extended[i];
|
||||||
|
if (extended == null) {
|
||||||
|
extended[i] = nibble = new NibbleArray(4096, 4);
|
||||||
|
}
|
||||||
|
nibble.set(x, y & 15, z, id >> 8);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,6 +257,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
}
|
}
|
||||||
int countAir = this.getAir(j);
|
int countAir = this.getAir(j);
|
||||||
NibbleArray newDataArray = this.getDataArray(j);
|
NibbleArray newDataArray = this.getDataArray(j);
|
||||||
|
NibbleArray extendedArray = this.getExtendedIdArray(j);
|
||||||
ExtendedBlockStorage section = sections[j];
|
ExtendedBlockStorage section = sections[j];
|
||||||
if ((section == null)) {
|
if ((section == null)) {
|
||||||
if (count == countAir) {
|
if (count == countAir) {
|
||||||
@ -253,6 +268,9 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
if (newDataArray != null) {
|
if (newDataArray != null) {
|
||||||
section.setBlockMetadataArray(newDataArray);
|
section.setBlockMetadataArray(newDataArray);
|
||||||
}
|
}
|
||||||
|
if (extendedArray != null) {
|
||||||
|
section.setBlockMSBArray(extendedArray);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if (count >= 4096) {
|
} else if (count >= 4096) {
|
||||||
if (count == countAir) {
|
if (count == countAir) {
|
||||||
@ -262,6 +280,12 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
section.setBlockLSBArray(newIdArray);
|
section.setBlockLSBArray(newIdArray);
|
||||||
if (newDataArray != null) {
|
if (newDataArray != null) {
|
||||||
section.setBlockMetadataArray(newDataArray);
|
section.setBlockMetadataArray(newDataArray);
|
||||||
|
} else {
|
||||||
|
NibbleArray nibble = section.getMetadataArray();
|
||||||
|
Arrays.fill(nibble.data, (byte) 0);
|
||||||
|
}
|
||||||
|
if (extendedArray != null) {
|
||||||
|
section.setBlockMSBArray(extendedArray);
|
||||||
} else {
|
} else {
|
||||||
NibbleArray nibble = section.getBlockMSBArray();
|
NibbleArray nibble = section.getBlockMSBArray();
|
||||||
Arrays.fill(nibble.data, (byte) 0);
|
Arrays.fill(nibble.data, (byte) 0);
|
||||||
@ -270,10 +294,15 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
}
|
}
|
||||||
byte[] currentIdArray = section.getBlockLSBArray();
|
byte[] currentIdArray = section.getBlockLSBArray();
|
||||||
NibbleArray currentDataArray = section.getMetadataArray();
|
NibbleArray currentDataArray = section.getMetadataArray();
|
||||||
|
NibbleArray currentExtraArray = section.getBlockMSBArray();
|
||||||
boolean data = currentDataArray != null && newDataArray != null;
|
boolean data = currentDataArray != null && newDataArray != null;
|
||||||
if (currentDataArray == null && newDataArray != null) {
|
if (currentDataArray == null && newDataArray != null) {
|
||||||
section.setBlockMetadataArray(newDataArray);
|
section.setBlockMetadataArray(newDataArray);
|
||||||
}
|
}
|
||||||
|
boolean extra = currentExtraArray != null && extendedArray != null;
|
||||||
|
if (currentExtraArray == null && extendedArray != null) {
|
||||||
|
section.setBlockMSBArray(extendedArray);
|
||||||
|
}
|
||||||
int solid = 0;
|
int solid = 0;
|
||||||
char[] charArray = this.getIdArray(j);
|
char[] charArray = this.getIdArray(j);
|
||||||
for (int k = 0; k < newIdArray.length; k++) {
|
for (int k = 0; k < newIdArray.length; k++) {
|
||||||
@ -298,6 +327,16 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
int newData = newDataArray.get(x, y, z);
|
int newData = newDataArray.get(x, y, z);
|
||||||
currentDataArray.set(x, y, z, newData);
|
currentDataArray.set(x, y, z, newData);
|
||||||
}
|
}
|
||||||
|
if (extra) {
|
||||||
|
int extraId = FaweCache.getId(combined) >> 8;
|
||||||
|
if (extraId != 0) {
|
||||||
|
int x = FaweCache.CACHE_X[0][k];
|
||||||
|
int y = FaweCache.CACHE_Y[0][k];
|
||||||
|
int z = FaweCache.CACHE_Z[0][k];
|
||||||
|
int newExtra = extendedArray.get(x, y, z);
|
||||||
|
currentExtraArray.set(x, y, z, newExtra);
|
||||||
|
}
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user