mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-09-06 03:37:59 +02:00
commit
2eb9fe7e62
@ -28,16 +28,18 @@ public class ConnectionData {
|
||||
static Set<Integer> occludingStates = new HashSet<>();
|
||||
|
||||
public static void update(UserConnection user, Position position) {
|
||||
BlockConnectionProvider connectionProvider = Via.getManager().getProviders().get(BlockConnectionProvider.class);
|
||||
for (BlockFace face : BlockFace.values()) {
|
||||
Position pos = new Position(
|
||||
position.getX() + face.getModX(),
|
||||
position.getY() + face.getModY(),
|
||||
position.getZ() + face.getModZ()
|
||||
);
|
||||
int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos);
|
||||
if (!connects(blockState)) continue;
|
||||
int newBlockState = connect(user, pos, blockState);
|
||||
int blockState = connectionProvider.getBlockdata(user, pos);
|
||||
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
||||
if (handler == null) continue;
|
||||
|
||||
int newBlockState = handler.connect(user, position, blockState);
|
||||
PacketWrapper blockUpdatePacket = new PacketWrapper(0x0B, null, user);
|
||||
blockUpdatePacket.write(Type.POSITION, pos);
|
||||
blockUpdatePacket.write(Type.VAR_INT, newBlockState);
|
||||
@ -54,7 +56,7 @@ public class ConnectionData {
|
||||
for (int chunkDeltaZ = -1; chunkDeltaZ <= 1; chunkDeltaZ++) {
|
||||
if (Math.abs(chunkDeltaX) + Math.abs(chunkDeltaZ) == 0) continue;
|
||||
|
||||
ArrayList<BlockChangeRecord> updates = new ArrayList<>();
|
||||
List<BlockChangeRecord> updates = new ArrayList<>();
|
||||
|
||||
if (Math.abs(chunkDeltaX) + Math.abs(chunkDeltaZ) == 2) { // Corner
|
||||
for (int blockY = chunkSectionY * 16; blockY < chunkSectionY * 16 + 16; blockY++) {
|
||||
@ -127,9 +129,10 @@ public class ConnectionData {
|
||||
|
||||
public static void updateBlock(UserConnection user, Position pos, List<BlockChangeRecord> records) {
|
||||
int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos);
|
||||
if (!connects(blockState)) return;
|
||||
int newBlockState = connect(user, pos, blockState);
|
||||
ConnectionHandler handler = getConnectionHandler(blockState);
|
||||
if (handler == null) return;
|
||||
|
||||
int newBlockState = handler.connect(user, pos, blockState);
|
||||
records.add(new BlockChangeRecord((short) (((pos.getX() & 0xF) << 4) | (pos.getZ() & 0xF)), pos.getY().shortValue(), newBlockState));
|
||||
}
|
||||
|
||||
@ -181,8 +184,9 @@ public class ConnectionData {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
int block = section.getFlatBlock(x, y, z);
|
||||
|
||||
if (ConnectionData.connects(block)) {
|
||||
block = ConnectionData.connect(user, new Position(xOff + x, yOff + y, zOff + z), block);
|
||||
ConnectionHandler handler = ConnectionData.getConnectionHandler(block);
|
||||
if (handler != null) {
|
||||
block = handler.connect(user, new Position(xOff + x, yOff + y, zOff + z), block);
|
||||
section.setFlatBlock(x, y, z, block);
|
||||
}
|
||||
}
|
||||
@ -270,12 +274,12 @@ public class ConnectionData {
|
||||
}
|
||||
|
||||
public static int connect(UserConnection user, Position position, int blockState) {
|
||||
if (connectionHandlerMap.containsKey(blockState)) {
|
||||
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
||||
return handler.connect(user, position, blockState);
|
||||
} else {
|
||||
return blockState;
|
||||
}
|
||||
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
||||
return handler != null ? handler.connect(user, position, blockState) : blockState;
|
||||
}
|
||||
|
||||
public static ConnectionHandler getConnectionHandler(int blockstate) {
|
||||
return connectionHandlerMap.get(blockstate);
|
||||
}
|
||||
|
||||
public static int getId(String key) {
|
||||
|
@ -16,6 +16,7 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionHandler;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
|
||||
@ -177,10 +178,7 @@ public class WorldPackets {
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
|
||||
ConnectionData.updateBlockStorage(userConnection, position, newId);
|
||||
|
||||
if (ConnectionData.connects(newId)) {
|
||||
newId = ConnectionData.connect(userConnection, position, newId);
|
||||
}
|
||||
newId = ConnectionData.connect(userConnection, position, newId);
|
||||
}
|
||||
wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId));
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
@ -232,8 +230,9 @@ public class WorldPackets {
|
||||
(long) record.getY(),
|
||||
(long) (record.getHorizontal() & 15) + (chunkZ * 16));
|
||||
|
||||
if (ConnectionData.connects(blockState)) {
|
||||
blockState = ConnectionData.connect(userConnection, position, blockState);
|
||||
ConnectionHandler handler = ConnectionData.getConnectionHandler(blockState);
|
||||
if (handler != null) {
|
||||
blockState = handler.connect(userConnection, position, blockState);
|
||||
record.setBlockId(blockState);
|
||||
}
|
||||
}
|
||||
|
@ -331,10 +331,12 @@ public class InventoryPackets {
|
||||
CompoundTag tag;
|
||||
if ((tag = item.getTag()) != null) {
|
||||
// Display Lore now uses JSON
|
||||
if (tag.get("display") instanceof CompoundTag) {
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display.get("Lore") instanceof ListTag) {
|
||||
ListTag lore = display.get("Lore");
|
||||
Tag displayTag = tag.get("display");
|
||||
if (displayTag instanceof CompoundTag) {
|
||||
CompoundTag display = (CompoundTag) displayTag;
|
||||
Tag loreTag = display.get("Lore");
|
||||
if (loreTag instanceof ListTag) {
|
||||
ListTag lore = (ListTag) loreTag;
|
||||
display.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|Lore", ConverterRegistry.convertToValue(lore)));
|
||||
for (Tag loreEntry : lore) {
|
||||
if (loreEntry instanceof StringTag) {
|
||||
@ -366,10 +368,12 @@ public class InventoryPackets {
|
||||
CompoundTag tag;
|
||||
if ((tag = item.getTag()) != null) {
|
||||
// Display Name now uses JSON
|
||||
if (tag.get("display") instanceof CompoundTag) {
|
||||
CompoundTag display = tag.get("display");
|
||||
if (((CompoundTag) tag.get("display")).get("Lore") instanceof ListTag) {
|
||||
ListTag lore = display.get("Lore");
|
||||
Tag displayTag = tag.get("display");
|
||||
if (displayTag instanceof CompoundTag) {
|
||||
CompoundTag display = (CompoundTag) displayTag;
|
||||
Tag loreTag = display.get("Lore");
|
||||
if (loreTag instanceof ListTag) {
|
||||
ListTag lore = (ListTag) loreTag;
|
||||
ListTag via = display.get(NBT_TAG_NAME + "|Lore");
|
||||
if (via != null) {
|
||||
display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via)));
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user