Fix sendBlocks + lever rotation

This commit is contained in:
Jesse Boyd 2016-12-03 12:57:17 +11:00
parent aa27d01fc4
commit 6b0c2b9ef9
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
11 changed files with 50 additions and 33 deletions

View File

@ -237,21 +237,21 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
for (FawePlayer player : players) { for (FawePlayer player : players) {
Player bukkitPlayer = ((BukkitPlayer) player).parent; Player bukkitPlayer = ((BukkitPlayer) player).parent;
World world = bukkitPlayer.getWorld(); World world = bukkitPlayer.getWorld();
for (Map.Entry<Long, Map<Short, Short>> entry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> entry : blockMap.entrySet()) {
long chunkHash = entry.getKey(); long chunkHash = entry.getKey();
int cx = MathMan.unpairIntX(chunkHash); int cx = MathMan.unpairIntX(chunkHash);
int cz = MathMan.unpairIntY(chunkHash); int cz = MathMan.unpairIntY(chunkHash);
Map<Short, Short> blocks = entry.getValue(); Map<Short, Character> blocks = entry.getValue();
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) { for (Map.Entry<Short, Character> blockEntry : blocks.entrySet()) {
short blockHash = blockEntry.getKey(); short blockHash = blockEntry.getKey();
int x = (blockHash >> 12 & 0xF) + (cx << 4); int x = (blockHash >> 12 & 0xF) + (cx << 4);
int y = (blockHash & 0xFF); int y = (blockHash & 0xFF);
int z = (blockHash >> 8 & 0xF) + (cz << 4); int z = (blockHash >> 8 & 0xF) + (cz << 4);
short combined = blockEntry.getValue(); char combined = blockEntry.getValue();
int id = FaweCache.getId(combined); int id = FaweCache.getId(combined);
byte data = (byte) FaweCache.getData(combined); byte data = (byte) FaweCache.getData(combined);
Location loc = new Location(world, x, y, z); Location loc = new Location(world, x, y, z);

View File

@ -331,7 +331,7 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
if (parent != null) { if (parent != null) {
parentNMS.sendBlockUpdate(blockMap, players); parentNMS.sendBlockUpdate(blockMap, players);
} }

View File

@ -245,7 +245,7 @@ public abstract class FaweQueue {
return count; return count;
} }
public abstract void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players); public abstract void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players);
@Deprecated @Deprecated
public boolean next() { public boolean next() {

View File

@ -169,7 +169,7 @@ public class DelegateFaweQueue extends FaweQueue {
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
parent.sendBlockUpdate(blockMap, players); parent.sendBlockUpdate(blockMap, players);
} }

View File

@ -140,6 +140,23 @@ public class BundledBlockData {
valuesEntry.getValue().setDirection(dirs[index]); valuesEntry.getValue().setDirection(dirs[index]);
index += increment; index += increment;
} }
} else if (entry.legacyId == 69) {
dir = entry.states.get("facing");
Vector[] dirs = new Vector[]{
new Vector(0, -1, 0),
new Vector(1, 0, 0),
new Vector(-1, 0, 0),
new Vector(0, 0, 1),
new Vector(0, 0, -1),
new Vector(0, 1, 0),
new Vector(0, 1, 0),
new Vector(0, -1, 0)};
int len = dir.values.size();
int index = 0;
for (Map.Entry<String, FaweStateValue> valuesEntry : dir.values.entrySet()) {
valuesEntry.getValue().setDirection(dirs[index]);
index ++;
}
} }
} }
} }

View File

@ -104,11 +104,11 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) {
try { try {
long chunkHash = chunkEntry.getKey(); long chunkHash = chunkEntry.getKey();
Map<Short, Short> blocks = chunkEntry.getValue(); Map<Short, Character> blocks = chunkEntry.getValue();
SPacketMultiBlockChange packet = new SPacketMultiBlockChange(); SPacketMultiBlockChange packet = new SPacketMultiBlockChange();
int cx = MathMan.unpairIntX(chunkHash); int cx = MathMan.unpairIntX(chunkHash);
int cz = MathMan.unpairIntY(chunkHash); int cz = MathMan.unpairIntY(chunkHash);
@ -117,7 +117,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
buffer.writeInt(cx); buffer.writeInt(cx);
buffer.writeInt(cz); buffer.writeInt(cz);
buffer.writeVarIntToBuffer(blocks.size()); buffer.writeVarIntToBuffer(blocks.size());
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) { for (Map.Entry<Short, Character> blockEntry : blocks.entrySet()) {
buffer.writeShort(blockEntry.getKey()); buffer.writeShort(blockEntry.getKey());
buffer.writeVarIntToBuffer(blockEntry.getValue()); buffer.writeVarIntToBuffer(blockEntry.getValue());
} }

View File

@ -89,11 +89,11 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) {
try { try {
long chunkHash = chunkEntry.getKey(); long chunkHash = chunkEntry.getKey();
Map<Short, Short> blocks = chunkEntry.getValue(); Map<Short, Character> blocks = chunkEntry.getValue();
SPacketMultiBlockChange packet = new SPacketMultiBlockChange(); SPacketMultiBlockChange packet = new SPacketMultiBlockChange();
int cx = MathMan.unpairIntX(chunkHash); int cx = MathMan.unpairIntX(chunkHash);
int cz = MathMan.unpairIntY(chunkHash); int cz = MathMan.unpairIntY(chunkHash);
@ -102,7 +102,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
buffer.writeInt(cx); buffer.writeInt(cx);
buffer.writeInt(cz); buffer.writeInt(cz);
buffer.writeVarInt(blocks.size()); buffer.writeVarInt(blocks.size());
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) { for (Map.Entry<Short, Character> blockEntry : blocks.entrySet()) {
buffer.writeShort(blockEntry.getKey()); buffer.writeShort(blockEntry.getKey());
buffer.writeVarInt(blockEntry.getValue()); buffer.writeVarInt(blockEntry.getValue());
} }

View File

@ -290,11 +290,11 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) {
try { try {
long chunkHash = chunkEntry.getKey(); long chunkHash = chunkEntry.getKey();
Map<Short, Short> blocks = chunkEntry.getValue(); Map<Short, Character> blocks = chunkEntry.getValue();
S22PacketMultiBlockChange packet = new S22PacketMultiBlockChange(); S22PacketMultiBlockChange packet = new S22PacketMultiBlockChange();
int cx = MathMan.unpairIntX(chunkHash); int cx = MathMan.unpairIntX(chunkHash);
int cz = MathMan.unpairIntY(chunkHash); int cz = MathMan.unpairIntY(chunkHash);
@ -303,7 +303,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
buffer.writeInt(cx); buffer.writeInt(cx);
buffer.writeInt(cz); buffer.writeInt(cz);
buffer.writeVarIntToBuffer(blocks.size()); buffer.writeVarIntToBuffer(blocks.size());
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) { for (Map.Entry<Short, Character> blockEntry : blocks.entrySet()) {
buffer.writeShort(blockEntry.getKey()); buffer.writeShort(blockEntry.getKey());
buffer.writeVarIntToBuffer(blockEntry.getValue()); buffer.writeVarIntToBuffer(blockEntry.getValue());
} }

View File

@ -204,11 +204,11 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) {
try { try {
long chunkHash = chunkEntry.getKey(); long chunkHash = chunkEntry.getKey();
Map<Short, Short> blocks = chunkEntry.getValue(); Map<Short, Character> blocks = chunkEntry.getValue();
S22PacketMultiBlockChange packet = new S22PacketMultiBlockChange(); S22PacketMultiBlockChange packet = new S22PacketMultiBlockChange();
int cx = MathMan.unpairIntX(chunkHash); int cx = MathMan.unpairIntX(chunkHash);
int cz = MathMan.unpairIntY(chunkHash); int cz = MathMan.unpairIntY(chunkHash);
@ -217,7 +217,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
buffer.writeInt(cx); buffer.writeInt(cx);
buffer.writeInt(cz); buffer.writeInt(cz);
buffer.writeVarIntToBuffer(blocks.size()); buffer.writeVarIntToBuffer(blocks.size());
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) { for (Map.Entry<Short, Character> blockEntry : blocks.entrySet()) {
buffer.writeShort(blockEntry.getKey()); buffer.writeShort(blockEntry.getKey());
buffer.writeVarIntToBuffer(blockEntry.getValue()); buffer.writeVarIntToBuffer(blockEntry.getValue());
} }

View File

@ -242,11 +242,11 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
for (Map.Entry<Long, Map<Short, Short>> chunkEntry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) {
try { try {
long chunkHash = chunkEntry.getKey(); long chunkHash = chunkEntry.getKey();
Map<Short, Short> blocks = chunkEntry.getValue(); Map<Short, Character> blocks = chunkEntry.getValue();
SPacketMultiBlockChange packet = new SPacketMultiBlockChange(); SPacketMultiBlockChange packet = new SPacketMultiBlockChange();
int cx = MathMan.unpairIntX(chunkHash); int cx = MathMan.unpairIntX(chunkHash);
int cz = MathMan.unpairIntY(chunkHash); int cz = MathMan.unpairIntY(chunkHash);
@ -255,7 +255,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
buffer.writeInt(cx); buffer.writeInt(cx);
buffer.writeInt(cz); buffer.writeInt(cz);
buffer.writeVarIntToBuffer(blocks.size()); buffer.writeVarIntToBuffer(blocks.size());
for (Map.Entry<Short, Short> blockEntry : blocks.entrySet()) { for (Map.Entry<Short, Character> blockEntry : blocks.entrySet()) {
buffer.writeShort(blockEntry.getKey()); buffer.writeShort(blockEntry.getKey());
buffer.writeVarIntToBuffer(blockEntry.getValue()); buffer.writeVarIntToBuffer(blockEntry.getValue());
} }

View File

@ -124,15 +124,15 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
} }
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Short>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
ArrayList<Block> blocks = new ArrayList<Block>(); ArrayList<Block> blocks = new ArrayList<Block>();
for (Map.Entry<Long, Map<Short, Short>> entry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> entry : blockMap.entrySet()) {
long chunkHash = entry.getKey(); long chunkHash = entry.getKey();
int cx = MathMan.unpairIntX(chunkHash); int cx = MathMan.unpairIntX(chunkHash);
int cz = MathMan.unpairIntY(chunkHash); int cz = MathMan.unpairIntY(chunkHash);
Map<Short, Short> ids = entry.getValue(); Map<Short, Character> ids = entry.getValue();
for (Map.Entry<Short, Short> blockEntry : ids.entrySet()) { for (Map.Entry<Short, Character> blockEntry : ids.entrySet()) {
short combined = blockEntry.getValue(); char combined = blockEntry.getValue();
int id = FaweCache.getId(combined); int id = FaweCache.getId(combined);
int data = FaweCache.getData(combined); int data = FaweCache.getData(combined);
Block block = Block.get(id, data); Block block = Block.get(id, data);