Tile entity fixes + send block update
This commit is contained in:
parent
5a914513b9
commit
aa27d01fc4
@ -1,10 +1,13 @@
|
||||
package com.boydti.fawe.bukkit.v0;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.BukkitPlayer;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
@ -20,8 +23,10 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
@ -231,6 +236,31 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
for (FawePlayer player : players) {
|
||||
Player bukkitPlayer = ((BukkitPlayer) player).parent;
|
||||
World world = bukkitPlayer.getWorld();
|
||||
for (Map.Entry<Long, Map<Short, Short>> entry : blockMap.entrySet()) {
|
||||
long chunkHash = entry.getKey();
|
||||
int cx = MathMan.unpairIntX(chunkHash);
|
||||
int cz = MathMan.unpairIntY(chunkHash);
|
||||
Map<Short, Short> blocks = entry.getValue();
|
||||
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) {
|
||||
short blockHash = blockEntry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + (cx << 4);
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + (cz << 4);
|
||||
short combined = blockEntry.getValue();
|
||||
int id = FaweCache.getId(combined);
|
||||
byte data = (byte) FaweCache.getData(combined);
|
||||
Location loc = new Location(world, x, y, z);
|
||||
bukkitPlayer.sendBlockChange(loc, id, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endSet(boolean parallel) {
|
||||
ChunkListener.physicsFreeze = false;
|
||||
|
@ -4,11 +4,9 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
@ -408,12 +406,15 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
BlockPosition pos = new BlockPosition(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
BlockPosition pos = new BlockPosition(x, y, z); // Set pos
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_10.methodFromNative.invoke(BukkitQueue_1_10.adapter, nativeTag);
|
||||
|
@ -23,7 +23,6 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -210,146 +209,110 @@ public final class FaweAdapter_1_10 implements BukkitImplAdapter
|
||||
return null;
|
||||
}
|
||||
|
||||
private Tag toNative(NBTBase foreign)
|
||||
{
|
||||
public Tag toNative(NBTBase foreign) {
|
||||
if (foreign == null) {
|
||||
return null;
|
||||
}
|
||||
if ((foreign instanceof NBTTagCompound))
|
||||
{
|
||||
Map<String, Tag> values = new HashMap();
|
||||
Set<String> foreignKeys = ((NBTTagCompound)foreign).c();
|
||||
for (String str : foreignKeys)
|
||||
{
|
||||
if (foreign instanceof NBTTagCompound) {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
Set<String> foreignKeys = ((NBTTagCompound) foreign).c(); // map.keySet
|
||||
|
||||
for (String str : foreignKeys) {
|
||||
NBTBase base = ((NBTTagCompound) foreign).get(str);
|
||||
values.put(str, toNative(base));
|
||||
}
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
if ((foreign instanceof NBTTagByte)) {
|
||||
return new ByteTag(((NBTTagByte)foreign).g());
|
||||
}
|
||||
if ((foreign instanceof NBTTagByteArray)) {
|
||||
return new ByteArrayTag(((NBTTagByteArray)foreign).c());
|
||||
}
|
||||
if ((foreign instanceof NBTTagDouble)) {
|
||||
return new DoubleTag(((NBTTagDouble)foreign).h());
|
||||
}
|
||||
if ((foreign instanceof NBTTagFloat)) {
|
||||
return new FloatTag(((NBTTagFloat)foreign).i());
|
||||
}
|
||||
if ((foreign instanceof NBTTagInt)) {
|
||||
return new IntTag(((NBTTagInt)foreign).e());
|
||||
}
|
||||
if ((foreign instanceof NBTTagIntArray)) {
|
||||
return new IntArrayTag(((NBTTagIntArray)foreign).d());
|
||||
}
|
||||
if ((foreign instanceof NBTTagList)) {
|
||||
try
|
||||
{
|
||||
} else if (foreign instanceof NBTTagByte) {
|
||||
return new ByteTag(((NBTTagByte) foreign).g()); // getByte
|
||||
} else if (foreign instanceof NBTTagByteArray) {
|
||||
return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data
|
||||
} else if (foreign instanceof NBTTagDouble) {
|
||||
return new DoubleTag(((NBTTagDouble) foreign).h()); // getDouble
|
||||
} else if (foreign instanceof NBTTagFloat) {
|
||||
return new FloatTag(((NBTTagFloat) foreign).i()); // getFloat
|
||||
} else if (foreign instanceof NBTTagInt) {
|
||||
return new IntTag(((NBTTagInt) foreign).e()); // getInt
|
||||
} else if (foreign instanceof NBTTagIntArray) {
|
||||
return new IntArrayTag(((NBTTagIntArray) foreign).d()); // data
|
||||
} else if (foreign instanceof NBTTagList) {
|
||||
try {
|
||||
return toNativeList((NBTTagList) foreign);
|
||||
} catch (Throwable e) {
|
||||
logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
|
||||
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
this.logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
|
||||
return new ListTag(ByteTag.class, new ArrayList());
|
||||
}
|
||||
}
|
||||
if ((foreign instanceof NBTTagLong)) {
|
||||
return new LongTag(((NBTTagLong)foreign).d());
|
||||
}
|
||||
if ((foreign instanceof NBTTagShort)) {
|
||||
return new ShortTag(((NBTTagShort)foreign).f());
|
||||
}
|
||||
if ((foreign instanceof NBTTagString)) {
|
||||
return new StringTag(((NBTTagString)foreign).c_());
|
||||
}
|
||||
if ((foreign instanceof NBTTagEnd)) {
|
||||
} else if (foreign instanceof NBTTagLong) {
|
||||
return new LongTag(((NBTTagLong) foreign).d()); // getLong
|
||||
} else if (foreign instanceof NBTTagShort) {
|
||||
return new ShortTag(((NBTTagShort) foreign).f()); // getShort
|
||||
} else if (foreign instanceof NBTTagString) {
|
||||
return new StringTag(((NBTTagString) foreign).c_()); // data
|
||||
} else if (foreign instanceof NBTTagEnd) {
|
||||
return new EndTag();
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
private ListTag toNativeList(NBTTagList foreign)
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
List<Tag> values = new ArrayList();
|
||||
int type = foreign.getTypeId();
|
||||
|
||||
List foreignList = (List)this.nbtListTagListField.get(foreign);
|
||||
for (int i = 0; i < foreign.size(); i++)
|
||||
{
|
||||
NBTBase element = (NBTBase)foreignList.get(i);
|
||||
values.add(toNative(element));
|
||||
}
|
||||
|
||||
public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
List<Tag> values = new ArrayList<Tag>();
|
||||
int type = foreign.g();
|
||||
|
||||
List foreignList;
|
||||
foreignList = (List) nbtListTagListField.get(foreign);
|
||||
for (int i = 0; i < foreign.size(); i++) {
|
||||
NBTBase element = (NBTBase) foreignList.get(i);
|
||||
values.add(toNative(element)); // List elements shouldn't have names
|
||||
}
|
||||
|
||||
Class<? extends Tag> cls = NBTConstants.getClassFromType(type);
|
||||
return new ListTag(cls, values);
|
||||
}
|
||||
|
||||
private NBTBase fromNative(Tag foreign)
|
||||
{
|
||||
public NBTBase fromNative(Tag foreign) {
|
||||
if (foreign == null) {
|
||||
return null;
|
||||
}
|
||||
Map.Entry<String, Tag> entry;
|
||||
if ((foreign instanceof CompoundTag))
|
||||
{
|
||||
if (foreign instanceof CompoundTag) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
for (Iterator localIterator = ((CompoundTag)foreign)
|
||||
.getValue().entrySet().iterator(); localIterator.hasNext();)
|
||||
{
|
||||
entry = (Map.Entry)localIterator.next();
|
||||
|
||||
tag.set((String)entry.getKey(), fromNative((Tag)entry.getValue()));
|
||||
for (Map.Entry<String, Tag> entry : ((CompoundTag) foreign)
|
||||
.getValue().entrySet()) {
|
||||
tag.set(entry.getKey(), fromNative(entry.getValue()));
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
if ((foreign instanceof ByteTag)) {
|
||||
return new NBTTagByte(((ByteTag)foreign).getValue().byteValue());
|
||||
}
|
||||
if ((foreign instanceof ByteArrayTag)) {
|
||||
} else if (foreign instanceof ByteTag) {
|
||||
return new NBTTagByte(((ByteTag) foreign).getValue());
|
||||
} else if (foreign instanceof ByteArrayTag) {
|
||||
return new NBTTagByteArray(((ByteArrayTag) foreign).getValue());
|
||||
}
|
||||
if ((foreign instanceof DoubleTag)) {
|
||||
return new NBTTagDouble(((DoubleTag)foreign).getValue().doubleValue());
|
||||
}
|
||||
if ((foreign instanceof FloatTag)) {
|
||||
return new NBTTagFloat(((FloatTag)foreign).getValue().floatValue());
|
||||
}
|
||||
if ((foreign instanceof IntTag)) {
|
||||
return new NBTTagInt(((IntTag)foreign).getValue().intValue());
|
||||
}
|
||||
if ((foreign instanceof IntArrayTag)) {
|
||||
} else if (foreign instanceof DoubleTag) {
|
||||
return new NBTTagDouble(((DoubleTag) foreign).getValue());
|
||||
} else if (foreign instanceof FloatTag) {
|
||||
return new NBTTagFloat(((FloatTag) foreign).getValue());
|
||||
} else if (foreign instanceof IntTag) {
|
||||
return new NBTTagInt(((IntTag) foreign).getValue());
|
||||
} else if (foreign instanceof IntArrayTag) {
|
||||
return new NBTTagIntArray(((IntArrayTag) foreign).getValue());
|
||||
}
|
||||
if ((foreign instanceof ListTag))
|
||||
{
|
||||
} else if (foreign instanceof ListTag) {
|
||||
NBTTagList tag = new NBTTagList();
|
||||
ListTag foreignList = (ListTag) foreign;
|
||||
for (Tag t : foreignList.getValue()) {
|
||||
tag.add(fromNative(t));
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
if ((foreign instanceof LongTag)) {
|
||||
return new NBTTagLong(((LongTag)foreign).getValue().longValue());
|
||||
}
|
||||
if ((foreign instanceof ShortTag)) {
|
||||
return new NBTTagShort(((ShortTag)foreign).getValue().shortValue());
|
||||
}
|
||||
if ((foreign instanceof StringTag)) {
|
||||
} else if (foreign instanceof LongTag) {
|
||||
return new NBTTagLong(((LongTag) foreign).getValue());
|
||||
} else if (foreign instanceof ShortTag) {
|
||||
return new NBTTagShort(((ShortTag) foreign).getValue());
|
||||
} else if (foreign instanceof StringTag) {
|
||||
return new NBTTagString(((StringTag) foreign).getValue());
|
||||
}
|
||||
if ((foreign instanceof EndTag)) {
|
||||
try
|
||||
{
|
||||
return (NBTBase)this.nbtCreateTagMethod.invoke(null, new Object[] { Byte.valueOf((byte) 0) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} else if (foreign instanceof EndTag) {
|
||||
try {
|
||||
return (NBTBase) nbtCreateTagMethod.invoke(null, (byte) 0);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
}
|
@ -4,11 +4,9 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
@ -422,11 +420,14 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
BlockPosition pos = new BlockPosition(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
BlockPosition pos = new BlockPosition(x, y, z); // Set pos
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11.methodFromNative.invoke(com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11.adapter, nativeTag);
|
||||
|
@ -23,7 +23,6 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -210,146 +209,111 @@ public final class FaweAdapter_1_11 implements BukkitImplAdapter
|
||||
return null;
|
||||
}
|
||||
|
||||
private Tag toNative(NBTBase foreign)
|
||||
{
|
||||
public Tag toNative(NBTBase foreign) {
|
||||
if (foreign == null) {
|
||||
return null;
|
||||
}
|
||||
if ((foreign instanceof NBTTagCompound))
|
||||
{
|
||||
Map<String, Tag> values = new HashMap();
|
||||
Set<String> foreignKeys = ((NBTTagCompound)foreign).c();
|
||||
for (String str : foreignKeys)
|
||||
{
|
||||
if (foreign instanceof NBTTagCompound) {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
Set<String> foreignKeys = ((NBTTagCompound) foreign).c(); // map.keySet
|
||||
|
||||
for (String str : foreignKeys) {
|
||||
NBTBase base = ((NBTTagCompound) foreign).get(str);
|
||||
values.put(str, toNative(base));
|
||||
}
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
if ((foreign instanceof NBTTagByte)) {
|
||||
return new ByteTag(((NBTTagByte)foreign).g());
|
||||
}
|
||||
if ((foreign instanceof NBTTagByteArray)) {
|
||||
return new ByteArrayTag(((NBTTagByteArray)foreign).c());
|
||||
}
|
||||
if ((foreign instanceof NBTTagDouble)) {
|
||||
return new DoubleTag(((NBTTagDouble)foreign).asDouble());
|
||||
}
|
||||
if ((foreign instanceof NBTTagFloat)) {
|
||||
return new FloatTag(((NBTTagFloat)foreign).i());
|
||||
}
|
||||
if ((foreign instanceof NBTTagInt)) {
|
||||
return new IntTag(((NBTTagInt)foreign).e());
|
||||
}
|
||||
if ((foreign instanceof NBTTagIntArray)) {
|
||||
return new IntArrayTag(((NBTTagIntArray)foreign).d());
|
||||
}
|
||||
if ((foreign instanceof NBTTagList)) {
|
||||
try
|
||||
{
|
||||
} else if (foreign instanceof NBTTagByte) {
|
||||
return new ByteTag(((NBTTagByte) foreign).g()); // getByte
|
||||
} else if (foreign instanceof NBTTagByteArray) {
|
||||
return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data
|
||||
} else if (foreign instanceof NBTTagDouble) {
|
||||
return new DoubleTag(((NBTTagDouble) foreign).asDouble()); // getDouble
|
||||
} else if (foreign instanceof NBTTagFloat) {
|
||||
return new FloatTag(((NBTTagFloat) foreign).i()); // getFloat
|
||||
} else if (foreign instanceof NBTTagInt) {
|
||||
return new IntTag(((NBTTagInt) foreign).e()); // getInt
|
||||
} else if (foreign instanceof NBTTagIntArray) {
|
||||
return new IntArrayTag(((NBTTagIntArray) foreign).d()); // data
|
||||
} else if (foreign instanceof NBTTagList) {
|
||||
try {
|
||||
return toNativeList((NBTTagList) foreign);
|
||||
} catch (Throwable e) {
|
||||
logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
|
||||
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
this.logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
|
||||
return new ListTag(ByteTag.class, new ArrayList());
|
||||
}
|
||||
}
|
||||
if ((foreign instanceof NBTTagLong)) {
|
||||
return new LongTag(((NBTTagLong)foreign).d());
|
||||
}
|
||||
if ((foreign instanceof NBTTagShort)) {
|
||||
return new ShortTag(((NBTTagShort)foreign).f());
|
||||
}
|
||||
if ((foreign instanceof NBTTagString)) {
|
||||
return new StringTag(((NBTTagString)foreign).c_());
|
||||
}
|
||||
if ((foreign instanceof NBTTagEnd)) {
|
||||
} else if (foreign instanceof NBTTagLong) {
|
||||
return new LongTag(((NBTTagLong) foreign).d()); // getLong
|
||||
} else if (foreign instanceof NBTTagShort) {
|
||||
return new ShortTag(((NBTTagShort) foreign).f()); // getShort
|
||||
} else if (foreign instanceof NBTTagString) {
|
||||
return new StringTag(((NBTTagString) foreign).c_()); // data
|
||||
} else if (foreign instanceof NBTTagEnd) {
|
||||
return new EndTag();
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
private ListTag toNativeList(NBTTagList foreign)
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
List<Tag> values = new ArrayList();
|
||||
int type = foreign.getTypeId();
|
||||
|
||||
List foreignList = (List)this.nbtListTagListField.get(foreign);
|
||||
for (int i = 0; i < foreign.size(); i++)
|
||||
{
|
||||
NBTBase element = (NBTBase)foreignList.get(i);
|
||||
values.add(toNative(element));
|
||||
}
|
||||
|
||||
public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
List<Tag> values = new ArrayList<Tag>();
|
||||
int type = foreign.g();
|
||||
|
||||
List foreignList;
|
||||
foreignList = (List) nbtListTagListField.get(foreign);
|
||||
for (int i = 0; i < foreign.size(); i++) {
|
||||
NBTBase element = (NBTBase) foreignList.get(i);
|
||||
values.add(toNative(element)); // List elements shouldn't have names
|
||||
}
|
||||
|
||||
Class<? extends Tag> cls = NBTConstants.getClassFromType(type);
|
||||
return new ListTag(cls, values);
|
||||
}
|
||||
|
||||
private NBTBase fromNative(Tag foreign)
|
||||
{
|
||||
public NBTBase fromNative(Tag foreign) {
|
||||
if (foreign == null) {
|
||||
return null;
|
||||
}
|
||||
Map.Entry<String, Tag> entry;
|
||||
if ((foreign instanceof CompoundTag))
|
||||
{
|
||||
if (foreign instanceof CompoundTag) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
for (Iterator localIterator = ((CompoundTag)foreign)
|
||||
.getValue().entrySet().iterator(); localIterator.hasNext();)
|
||||
{
|
||||
entry = (Map.Entry)localIterator.next();
|
||||
|
||||
tag.set((String)entry.getKey(), fromNative((Tag)entry.getValue()));
|
||||
for (Map.Entry<String, Tag> entry : ((CompoundTag) foreign)
|
||||
.getValue().entrySet()) {
|
||||
tag.set(entry.getKey(), fromNative(entry.getValue()));
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
if ((foreign instanceof ByteTag)) {
|
||||
return new NBTTagByte(((ByteTag)foreign).getValue().byteValue());
|
||||
}
|
||||
if ((foreign instanceof ByteArrayTag)) {
|
||||
} else if (foreign instanceof ByteTag) {
|
||||
return new NBTTagByte(((ByteTag) foreign).getValue());
|
||||
} else if (foreign instanceof ByteArrayTag) {
|
||||
return new NBTTagByteArray(((ByteArrayTag) foreign).getValue());
|
||||
}
|
||||
if ((foreign instanceof DoubleTag)) {
|
||||
return new NBTTagDouble(((DoubleTag)foreign).getValue().doubleValue());
|
||||
}
|
||||
if ((foreign instanceof FloatTag)) {
|
||||
return new NBTTagFloat(((FloatTag)foreign).getValue().floatValue());
|
||||
}
|
||||
if ((foreign instanceof IntTag)) {
|
||||
return new NBTTagInt(((IntTag)foreign).getValue().intValue());
|
||||
}
|
||||
if ((foreign instanceof IntArrayTag)) {
|
||||
} else if (foreign instanceof DoubleTag) {
|
||||
return new NBTTagDouble(((DoubleTag) foreign).getValue());
|
||||
} else if (foreign instanceof FloatTag) {
|
||||
return new NBTTagFloat(((FloatTag) foreign).getValue());
|
||||
} else if (foreign instanceof IntTag) {
|
||||
return new NBTTagInt(((IntTag) foreign).getValue());
|
||||
} else if (foreign instanceof IntArrayTag) {
|
||||
return new NBTTagIntArray(((IntArrayTag) foreign).getValue());
|
||||
}
|
||||
if ((foreign instanceof ListTag))
|
||||
{
|
||||
} else if (foreign instanceof ListTag) {
|
||||
NBTTagList tag = new NBTTagList();
|
||||
ListTag foreignList = (ListTag) foreign;
|
||||
for (Tag t : foreignList.getValue()) {
|
||||
tag.add(fromNative(t));
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
if ((foreign instanceof LongTag)) {
|
||||
return new NBTTagLong(((LongTag)foreign).getValue().longValue());
|
||||
}
|
||||
if ((foreign instanceof ShortTag)) {
|
||||
return new NBTTagShort(((ShortTag)foreign).getValue().shortValue());
|
||||
}
|
||||
if ((foreign instanceof StringTag)) {
|
||||
} else if (foreign instanceof LongTag) {
|
||||
return new NBTTagLong(((LongTag) foreign).getValue());
|
||||
} else if (foreign instanceof ShortTag) {
|
||||
return new NBTTagShort(((ShortTag) foreign).getValue());
|
||||
} else if (foreign instanceof StringTag) {
|
||||
return new NBTTagString(((StringTag) foreign).getValue());
|
||||
}
|
||||
if ((foreign instanceof EndTag)) {
|
||||
try
|
||||
{
|
||||
return (NBTBase)this.nbtCreateTagMethod.invoke(null, new Object[] { Byte.valueOf((byte) 0) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} else if (foreign instanceof EndTag) {
|
||||
try {
|
||||
return (NBTBase) nbtCreateTagMethod.invoke(null, (byte) 0);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,11 +4,9 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
@ -356,14 +354,17 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
int bx = this.getX() << 4;
|
||||
int bz = this.getZ() << 4;
|
||||
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz);
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(x, y, z);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue17.methodFromNative.invoke(BukkitQueue17.adapter, nativeTag);
|
||||
tileEntity.a(tag); // ReadTagIntoTile
|
||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
@ -292,11 +291,14 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
BlockPosition pos = new BlockPosition(pair.get0x() + bx, pair.get1() & 0xFF, pair.get0y() + bz); // Set pos
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
BlockPosition pos = new BlockPosition(x, y, z); // Set pos
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue18R3.methodFromNative.invoke(BukkitQueue18R3.adapter, nativeTag);
|
||||
|
@ -4,11 +4,9 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
@ -415,11 +413,14 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
BlockPosition pos = new BlockPosition(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
BlockPosition pos = new BlockPosition(x, y, z); // Set pos
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_9_R1.methodFromNative.invoke(BukkitQueue_1_9_R1.adapter, nativeTag);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.example;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
@ -21,7 +20,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
public final byte[] heightMap;
|
||||
|
||||
public int[][] biomes;
|
||||
public HashMap<BytePair, CompoundTag> tiles;
|
||||
public HashMap<Short, CompoundTag> tiles;
|
||||
public HashSet<CompoundTag> entities;
|
||||
public HashSet<UUID> entityRemoves;
|
||||
|
||||
@ -139,9 +138,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
if (tiles == null) {
|
||||
tiles = new HashMap<>();
|
||||
}
|
||||
byte i = MathMan.pair16((byte) x, (byte) z);
|
||||
byte j = (byte) y;
|
||||
BytePair pair = new BytePair(i, j);
|
||||
short pair = MathMan.tripleBlockCoord(x, y, z);
|
||||
tiles.put(pair, tile);
|
||||
}
|
||||
|
||||
@ -150,15 +147,13 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
if (tiles == null) {
|
||||
return null;
|
||||
}
|
||||
byte i = MathMan.pair16((byte) x, (byte) z);
|
||||
byte j = (byte) y;
|
||||
BytePair pair = new BytePair(i, j);
|
||||
short pair = MathMan.tripleBlockCoord(x, y, z);
|
||||
return tiles.get(pair);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<BytePair, CompoundTag> getTiles() {
|
||||
return tiles == null ? new HashMap<BytePair, CompoundTag>() : tiles;
|
||||
public Map<Short, CompoundTag> getTiles() {
|
||||
return tiles == null ? new HashMap<Short, CompoundTag>() : tiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,11 +95,9 @@ public class NMSRelighter implements Relighter{
|
||||
int bx = chunkX << 4;
|
||||
int bz = chunkZ << 4;
|
||||
for (short blockHash : blocks.keySet()) {
|
||||
int hi = (byte) (blockHash >>> 8);
|
||||
int lo = (byte) blockHash;
|
||||
int y = lo & 0xFF;
|
||||
int x = (hi & 0xF) + bx;
|
||||
int z = ((hi >> 4) & 0xF) + bz;
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
int lcx = x & 0xF;
|
||||
int lcz = z & 0xF;
|
||||
int oldLevel = queue.getEmmittedLight(x, y, z);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.example;
|
||||
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -74,7 +73,7 @@ public class NullFaweChunk extends FaweChunk<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<BytePair, CompoundTag> getTiles() {
|
||||
public Map<Short, CompoundTag> getTiles() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.jnbt.anvil;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.RunnableVal2;
|
||||
@ -27,7 +26,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
// data: byte[16][2048]
|
||||
// skylight: byte[16][2048]
|
||||
// blocklight: byte[16][2048]
|
||||
// entities: Map<BytePair, CompoundTag>
|
||||
// entities: Map<Short, CompoundTag>
|
||||
// tiles: List<CompoundTag>
|
||||
// biomes: byte[256]
|
||||
// compressedSize: int
|
||||
@ -39,7 +38,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
public byte[][] skyLight;
|
||||
public byte[][] blockLight;
|
||||
public byte[] biomes;
|
||||
public Map<BytePair, CompoundTag> tiles = new HashMap<>();
|
||||
public Map<Short, CompoundTag> tiles = new HashMap<>();
|
||||
public Map<UUID, CompoundTag> entities = new HashMap<>();
|
||||
private long inhabitedTime;
|
||||
private long lastUpdate;
|
||||
@ -159,9 +158,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
int x = tile.getInt("x") & 15;
|
||||
int y = tile.getInt("y");
|
||||
int z = tile.getInt("z") & 15;
|
||||
byte i = MathMan.pair16((byte) x, (byte) z);
|
||||
byte j = (byte) y;
|
||||
BytePair pair = new BytePair(i, j);
|
||||
short pair = MathMan.tripleBlockCoord(x, y, z);
|
||||
tiles.put(pair, tile);
|
||||
}
|
||||
});
|
||||
@ -227,9 +224,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
@Override
|
||||
public void setTile(int x, int y, int z, CompoundTag tile) {
|
||||
modified = true;
|
||||
byte i = MathMan.pair16((byte) x, (byte) z);
|
||||
byte j = (byte) y;
|
||||
BytePair pair = new BytePair(i, j);
|
||||
short pair = MathMan.tripleBlockCoord(x, y, z);
|
||||
if (tile != null) {
|
||||
tiles.put(pair, tile);
|
||||
} else {
|
||||
@ -257,8 +252,8 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<BytePair, CompoundTag> getTiles() {
|
||||
return tiles == null ? new HashMap<BytePair, CompoundTag>() : tiles;
|
||||
public Map<Short, CompoundTag> getTiles() {
|
||||
return tiles == null ? new HashMap<Short, CompoundTag>() : tiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -266,9 +261,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
if (tiles == null || tiles.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
byte i = MathMan.pair16((byte) x, (byte) z);
|
||||
byte j = (byte) y;
|
||||
BytePair pair = new BytePair(i, j);
|
||||
short pair = MathMan.tripleBlockCoord(x, y, z);
|
||||
return tiles.get(pair);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.jnbt.anvil;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.RunnableVal4;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -328,4 +329,11 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
parent.endSet(parallel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
if (parent != null) {
|
||||
parentNMS.sendBlockUpdate(blockMap, players);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
|
||||
* get1 => y
|
||||
* @return
|
||||
*/
|
||||
public abstract Map<BytePair, CompoundTag> getTiles();
|
||||
public abstract Map<Short, CompoundTag> getTiles();
|
||||
|
||||
/**
|
||||
* Get the tile at a location
|
||||
|
@ -23,6 +23,7 @@ import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
@ -244,6 +245,8 @@ public abstract class FaweQueue {
|
||||
return count;
|
||||
}
|
||||
|
||||
public abstract void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players);
|
||||
|
||||
@Deprecated
|
||||
public boolean next() {
|
||||
int amount = Settings.QUEUE.PARALLEL_THREADS;
|
||||
|
@ -3,7 +3,6 @@ package com.boydti.fawe.object.changeset;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
@ -256,15 +255,15 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
// Tile changes
|
||||
{
|
||||
// Tiles created
|
||||
Map<BytePair, CompoundTag> tiles = next.getTiles();
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tiles.entrySet()) {
|
||||
Map<Short, CompoundTag> tiles = next.getTiles();
|
||||
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
|
||||
synchronized (lock) {
|
||||
addTileCreate(entry.getValue());
|
||||
}
|
||||
}
|
||||
// Tiles removed
|
||||
tiles = previous.getTiles();
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tiles.entrySet()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
|
||||
synchronized (lock) {
|
||||
addTileRemove(entry.getValue());
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
}
|
||||
try {
|
||||
NBTOutputStream nbtos = getTileCreateOS();
|
||||
nbtos.writeNamedTag(tileCreateSize++ + "", tag);
|
||||
nbtos.writeTag(tag);
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
@ -310,7 +310,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
}
|
||||
try {
|
||||
NBTOutputStream nbtos = getTileRemoveOS();
|
||||
nbtos.writeNamedTag(tileRemoveSize++ + "", tag);
|
||||
nbtos.writeTag(tag);
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
@ -322,7 +322,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
}
|
||||
try {
|
||||
NBTOutputStream nbtos = getEntityRemoveOS();
|
||||
nbtos.writeNamedTag(entityRemoveSize++ + "", tag);
|
||||
nbtos.writeTag(tag);
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
@ -334,7 +334,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
}
|
||||
try {
|
||||
NBTOutputStream nbtos = getEntityCreateOS();
|
||||
nbtos.writeNamedTag(entityCreateSize++ + "", tag);
|
||||
nbtos.writeTag(tag);
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
@ -468,7 +468,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
|
||||
public CompoundTag read() {
|
||||
try {
|
||||
return (CompoundTag) is.readNamedTag().getTag();
|
||||
return (CompoundTag) is.readTag();
|
||||
} catch (Exception ignoreEOS) {}
|
||||
return null;
|
||||
}
|
||||
@ -518,7 +518,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
|
||||
public CompoundTag read() {
|
||||
try {
|
||||
return (CompoundTag) is.readNamedTag().getTag();
|
||||
return (CompoundTag) is.readTag();
|
||||
} catch (Exception ignoreEOS) {}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
@ -9,6 +10,7 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
@ -166,6 +168,11 @@ public class DelegateFaweQueue extends FaweQueue {
|
||||
return parent.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
parent.sendBlockUpdate(blockMap, players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean next() {
|
||||
return parent.next();
|
||||
|
@ -65,9 +65,7 @@ public class MathMan {
|
||||
}
|
||||
|
||||
public static final short tripleBlockCoord(int x, int y, int z) {
|
||||
byte hi = (byte) ((x & 15) + ((z & 15) << 4));
|
||||
byte lo = (byte) y;
|
||||
return (short) (((hi & 0xFF) << 8) | (lo & 0xFF));
|
||||
return (short) ((x & 15) << 12 | (z & 15) << 8 | y);
|
||||
}
|
||||
|
||||
public static final long chunkXZ2Int(int x, int z) {
|
||||
|
@ -197,6 +197,9 @@ public final class NBTInputStream implements Closeable {
|
||||
return;
|
||||
case NBTConstants.TYPE_LIST:
|
||||
int childType = is.readByte();
|
||||
if (childType == NBTConstants.TYPE_LIST) {
|
||||
childType = NBTConstants.TYPE_COMPOUND;
|
||||
}
|
||||
length = is.readInt();
|
||||
reader = getReader.runAndGet(node + ".?", null).value2;
|
||||
if (reader != null) {
|
||||
@ -307,6 +310,9 @@ public final class NBTInputStream implements Closeable {
|
||||
return (new String(bytes, NBTConstants.CHARSET));
|
||||
case NBTConstants.TYPE_LIST:
|
||||
int childType = is.readByte();
|
||||
if (childType == NBTConstants.TYPE_LIST) {
|
||||
childType = NBTConstants.TYPE_COMPOUND;
|
||||
}
|
||||
length = is.readInt();
|
||||
List<Tag> tagList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
@ -382,6 +388,9 @@ public final class NBTInputStream implements Closeable {
|
||||
return new StringTag(new String(bytes, NBTConstants.CHARSET));
|
||||
case NBTConstants.TYPE_LIST:
|
||||
int childType = is.readByte();
|
||||
if (childType == NBTConstants.TYPE_LIST) {
|
||||
childType = NBTConstants.TYPE_COMPOUND;
|
||||
}
|
||||
length = is.readInt();
|
||||
List<Tag> tagList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
|
@ -89,6 +89,10 @@ public final class NBTOutputStream implements Closeable {
|
||||
writeTagPayload(tag);
|
||||
}
|
||||
|
||||
public void writeEndTag() throws IOException {
|
||||
os.writeByte(NBTConstants.TYPE_END);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes tag payload.
|
||||
*
|
||||
@ -194,8 +198,12 @@ public final class NBTOutputStream implements Closeable {
|
||||
Class<? extends Tag> clazz = tag.getType();
|
||||
List<Tag> tags = tag.getValue();
|
||||
int size = tags.size();
|
||||
|
||||
if (!tags.isEmpty()) {
|
||||
Tag tag0 = tags.get(0);
|
||||
os.writeByte(NBTUtils.getTypeCode(tag0.getClass()));
|
||||
} else {
|
||||
os.writeByte(NBTUtils.getTypeCode(clazz));
|
||||
}
|
||||
os.writeInt(size);
|
||||
for (Tag tag1 : tags) {
|
||||
writeTagPayload(tag1);
|
||||
|
@ -3,10 +3,8 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
@ -343,12 +341,15 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
BlockPos pos = new BlockPos(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
BlockPos pos = new BlockPos(x, y, z); // Set pos
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
|
||||
|
@ -3,13 +3,17 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.forge.ForgePlayer;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@ -29,7 +33,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.network.play.server.SPacketMultiBlockChange;
|
||||
import net.minecraft.server.management.PlayerChunkMap;
|
||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -97,6 +103,34 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) {
|
||||
try {
|
||||
long chunkHash = chunkEntry.getKey();
|
||||
Map<Short, Short> blocks = chunkEntry.getValue();
|
||||
SPacketMultiBlockChange packet = new SPacketMultiBlockChange();
|
||||
int cx = MathMan.unpairIntX(chunkHash);
|
||||
int cz = MathMan.unpairIntY(chunkHash);
|
||||
ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer();
|
||||
PacketBuffer buffer = new PacketBuffer(byteBuf);
|
||||
buffer.writeInt(cx);
|
||||
buffer.writeInt(cz);
|
||||
buffer.writeVarIntToBuffer(blocks.size());
|
||||
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) {
|
||||
buffer.writeShort(blockEntry.getKey());
|
||||
buffer.writeVarIntToBuffer(blockEntry.getValue());
|
||||
}
|
||||
packet.readPacketData(buffer);
|
||||
for (FawePlayer player : players) {
|
||||
((ForgePlayer) player).parent.connection.sendPacket(packet);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||
|
||||
@Override
|
||||
|
@ -3,10 +3,8 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
@ -357,12 +355,15 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
BlockPos pos = new BlockPos(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
BlockPos pos = new BlockPos(x, y, z); // Set pos
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
|
||||
|
@ -3,13 +3,17 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.forge.ForgePlayer;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@ -29,7 +33,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.network.play.server.SPacketMultiBlockChange;
|
||||
import net.minecraft.server.management.PlayerChunkMap;
|
||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -82,6 +88,34 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
getImpWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) {
|
||||
try {
|
||||
long chunkHash = chunkEntry.getKey();
|
||||
Map<Short, Short> blocks = chunkEntry.getValue();
|
||||
SPacketMultiBlockChange packet = new SPacketMultiBlockChange();
|
||||
int cx = MathMan.unpairIntX(chunkHash);
|
||||
int cz = MathMan.unpairIntY(chunkHash);
|
||||
ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer();
|
||||
PacketBuffer buffer = new PacketBuffer(byteBuf);
|
||||
buffer.writeInt(cx);
|
||||
buffer.writeInt(cz);
|
||||
buffer.writeVarInt(blocks.size());
|
||||
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) {
|
||||
buffer.writeShort(blockEntry.getKey());
|
||||
buffer.writeVarInt(blockEntry.getValue());
|
||||
}
|
||||
packet.readPacketData(buffer);
|
||||
for (FawePlayer player : players) {
|
||||
((ForgePlayer) player).parent.connection.sendPacket(packet);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||
|
@ -3,10 +3,8 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
@ -304,16 +302,16 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
int bx = this.getX() << 4;
|
||||
int bz = this.getZ() << 4;
|
||||
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
int x = MathMan.unpair16x((byte) pair.get0()) + bx;
|
||||
int y = pair.get1() & 0xFF;
|
||||
int z = MathMan.unpair16y((byte) pair.get0()) + bz;
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(x, y, z);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
|
||||
|
@ -3,7 +3,9 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.forge.ForgePlayer;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.IntegerPair;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
@ -12,6 +14,8 @@ import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@ -29,7 +33,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S21PacketChunkData;
|
||||
import net.minecraft.network.play.server.S22PacketMultiBlockChange;
|
||||
import net.minecraft.server.management.PlayerManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.LongHashMap;
|
||||
@ -283,6 +289,34 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) {
|
||||
try {
|
||||
long chunkHash = chunkEntry.getKey();
|
||||
Map<Short, Short> blocks = chunkEntry.getValue();
|
||||
S22PacketMultiBlockChange packet = new S22PacketMultiBlockChange();
|
||||
int cx = MathMan.unpairIntX(chunkHash);
|
||||
int cz = MathMan.unpairIntY(chunkHash);
|
||||
ByteBuf byteBuf = new UnpooledByteBufAllocator(true).buffer();
|
||||
PacketBuffer buffer = new PacketBuffer(byteBuf);
|
||||
buffer.writeInt(cx);
|
||||
buffer.writeInt(cz);
|
||||
buffer.writeVarIntToBuffer(blocks.size());
|
||||
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) {
|
||||
buffer.writeShort(blockEntry.getKey());
|
||||
buffer.writeVarIntToBuffer(blockEntry.getValue());
|
||||
}
|
||||
packet.readPacketData(buffer);
|
||||
for (FawePlayer player : players) {
|
||||
((ForgePlayer) player).parent.playerNetServerHandler.sendPacket(packet);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCount(int tickingBlockCount, int nonEmptyBlockCount, ExtendedBlockStorage section) throws NoSuchFieldException, IllegalAccessException {
|
||||
Class<? extends ExtendedBlockStorage> clazz = section.getClass();
|
||||
Field fieldTickingBlockCount = clazz.getDeclaredField("field_76683_c"); // tickRefCount
|
||||
|
@ -3,10 +3,8 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
@ -258,11 +256,14 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
BlockPos pos = new BlockPos(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
BlockPos pos = new BlockPos(x, y, z); // Set pos
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
|
||||
|
@ -3,13 +3,17 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.forge.ForgePlayer;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@ -26,7 +30,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S21PacketChunkData;
|
||||
import net.minecraft.network.play.server.S22PacketMultiBlockChange;
|
||||
import net.minecraft.server.management.PlayerManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
@ -197,6 +203,34 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
return (int) fieldNonEmptyBlockCount.get(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) {
|
||||
try {
|
||||
long chunkHash = chunkEntry.getKey();
|
||||
Map<Short, Short> blocks = chunkEntry.getValue();
|
||||
S22PacketMultiBlockChange packet = new S22PacketMultiBlockChange();
|
||||
int cx = MathMan.unpairIntX(chunkHash);
|
||||
int cz = MathMan.unpairIntY(chunkHash);
|
||||
ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer();
|
||||
PacketBuffer buffer = new PacketBuffer(byteBuf);
|
||||
buffer.writeInt(cx);
|
||||
buffer.writeInt(cz);
|
||||
buffer.writeVarIntToBuffer(blocks.size());
|
||||
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) {
|
||||
buffer.writeShort(blockEntry.getKey());
|
||||
buffer.writeVarIntToBuffer(blockEntry.getValue());
|
||||
}
|
||||
packet.readPacketData(buffer);
|
||||
for (FawePlayer player : players) {
|
||||
((ForgePlayer) player).parent.playerNetServerHandler.sendPacket(packet);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
@ -3,10 +3,8 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
@ -341,12 +339,15 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
}
|
||||
}
|
||||
// Set tiles
|
||||
Map<BytePair, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
Map<Short, CompoundTag> tilesToSpawn = this.getTiles();
|
||||
|
||||
for (Map.Entry<BytePair, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
for (Map.Entry<Short, CompoundTag> entry : tilesToSpawn.entrySet()) {
|
||||
CompoundTag nativeTag = entry.getValue();
|
||||
BytePair pair = entry.getKey();
|
||||
BlockPos pos = new BlockPos(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos
|
||||
short blockHash = entry.getKey();
|
||||
int x = (blockHash >> 12 & 0xF) + bx;
|
||||
int y = (blockHash & 0xFF);
|
||||
int z = (blockHash >> 8 & 0xF) + bz;
|
||||
BlockPos pos = new BlockPos(x, y, z); // Set pos
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
|
||||
|
@ -3,13 +3,17 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.forge.ForgePlayer;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@ -29,7 +33,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.network.play.server.SPacketMultiBlockChange;
|
||||
import net.minecraft.server.management.PlayerChunkMap;
|
||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -235,6 +241,34 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) {
|
||||
try {
|
||||
long chunkHash = chunkEntry.getKey();
|
||||
Map<Short, Short> blocks = chunkEntry.getValue();
|
||||
SPacketMultiBlockChange packet = new SPacketMultiBlockChange();
|
||||
int cx = MathMan.unpairIntX(chunkHash);
|
||||
int cz = MathMan.unpairIntY(chunkHash);
|
||||
ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer();
|
||||
PacketBuffer buffer = new PacketBuffer(byteBuf);
|
||||
buffer.writeInt(cx);
|
||||
buffer.writeInt(cz);
|
||||
buffer.writeVarIntToBuffer(blocks.size());
|
||||
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) {
|
||||
buffer.writeShort(blockEntry.getKey());
|
||||
buffer.writeVarIntToBuffer(blockEntry.getValue());
|
||||
}
|
||||
packet.readPacketData(buffer);
|
||||
for (FawePlayer player : players) {
|
||||
((ForgePlayer) player).parent.connection.sendPacket(packet);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
@ -7,18 +7,24 @@ import cn.nukkit.level.Level;
|
||||
import cn.nukkit.level.Position;
|
||||
import cn.nukkit.level.format.generic.BaseFullChunk;
|
||||
import cn.nukkit.math.Vector3;
|
||||
import cn.nukkit.network.protocol.UpdateBlockPacket;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.nukkit.core.NBTConverter;
|
||||
import com.boydti.fawe.nukkit.optimization.FaweNukkit;
|
||||
import com.boydti.fawe.nukkit.optimization.FaweNukkitPlayer;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -117,6 +123,43 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
|
||||
return new File("worlds" + File.separator + world.getFolderName() + File.separator + "region");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) {
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
for (Map.Entry<Long, Map<Short, Short>> entry : blockMap.entrySet()) {
|
||||
long chunkHash = entry.getKey();
|
||||
int cx = MathMan.unpairIntX(chunkHash);
|
||||
int cz = MathMan.unpairIntY(chunkHash);
|
||||
Map<Short, Short> ids = entry.getValue();
|
||||
for (Map.Entry<Short, Short> blockEntry : ids.entrySet()) {
|
||||
short combined = blockEntry.getValue();
|
||||
int id = FaweCache.getId(combined);
|
||||
int data = FaweCache.getData(combined);
|
||||
Block block = Block.get(id, data);
|
||||
short blockHash = blockEntry.getKey();
|
||||
block.x = (blockHash >> 12 & 0xF) + (cx << 4);
|
||||
block.y = (blockHash & 0xFF);
|
||||
block.z = (blockHash >> 8 & 0xF) + (cz << 4);
|
||||
blocks.add(block);
|
||||
}
|
||||
}
|
||||
Map<Level, List<Player>> playerMap = new HashMap<>();
|
||||
for (FawePlayer player : players) {
|
||||
Player nukkitPlayer = ((FaweNukkitPlayer) player).parent;
|
||||
List<Player> list = playerMap.get(nukkitPlayer.getLevel());
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
playerMap.put(nukkitPlayer.getLevel(), list);
|
||||
}
|
||||
list.add(nukkitPlayer);
|
||||
}
|
||||
Block[] blocksArray = blocks.toArray(new Block[blocks.size()]);
|
||||
for (Map.Entry<Level, List<Player>> levelListEntry : playerMap.entrySet()) {
|
||||
List<Player> playerList = levelListEntry.getValue();
|
||||
levelListEntry.getKey().sendBlocks(playerList.toArray(new Player[playerList.size()]), blocksArray, UpdateBlockPacket.FLAG_ALL_PRIORITY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSky() {
|
||||
return world.getDimension() == 0;
|
||||
|
Loading…
Reference in New Issue
Block a user