Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-09 17:50:23 +01:00
Commit
2eb9fe7e62
@ -28,16 +28,18 @@ public class ConnectionData {
|
|||||||
static Set<Integer> occludingStates = new HashSet<>();
|
static Set<Integer> occludingStates = new HashSet<>();
|
||||||
|
|
||||||
public static void update(UserConnection user, Position position) {
|
public static void update(UserConnection user, Position position) {
|
||||||
|
BlockConnectionProvider connectionProvider = Via.getManager().getProviders().get(BlockConnectionProvider.class);
|
||||||
for (BlockFace face : BlockFace.values()) {
|
for (BlockFace face : BlockFace.values()) {
|
||||||
Position pos = new Position(
|
Position pos = new Position(
|
||||||
position.getX() + face.getModX(),
|
position.getX() + face.getModX(),
|
||||||
position.getY() + face.getModY(),
|
position.getY() + face.getModY(),
|
||||||
position.getZ() + face.getModZ()
|
position.getZ() + face.getModZ()
|
||||||
);
|
);
|
||||||
int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos);
|
int blockState = connectionProvider.getBlockdata(user, pos);
|
||||||
if (!connects(blockState)) continue;
|
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
||||||
int newBlockState = connect(user, pos, blockState);
|
if (handler == null) continue;
|
||||||
|
|
||||||
|
int newBlockState = handler.connect(user, position, blockState);
|
||||||
PacketWrapper blockUpdatePacket = new PacketWrapper(0x0B, null, user);
|
PacketWrapper blockUpdatePacket = new PacketWrapper(0x0B, null, user);
|
||||||
blockUpdatePacket.write(Type.POSITION, pos);
|
blockUpdatePacket.write(Type.POSITION, pos);
|
||||||
blockUpdatePacket.write(Type.VAR_INT, newBlockState);
|
blockUpdatePacket.write(Type.VAR_INT, newBlockState);
|
||||||
@ -54,7 +56,7 @@ public class ConnectionData {
|
|||||||
for (int chunkDeltaZ = -1; chunkDeltaZ <= 1; chunkDeltaZ++) {
|
for (int chunkDeltaZ = -1; chunkDeltaZ <= 1; chunkDeltaZ++) {
|
||||||
if (Math.abs(chunkDeltaX) + Math.abs(chunkDeltaZ) == 0) continue;
|
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
|
if (Math.abs(chunkDeltaX) + Math.abs(chunkDeltaZ) == 2) { // Corner
|
||||||
for (int blockY = chunkSectionY * 16; blockY < chunkSectionY * 16 + 16; blockY++) {
|
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) {
|
public static void updateBlock(UserConnection user, Position pos, List<BlockChangeRecord> records) {
|
||||||
int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos);
|
int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos);
|
||||||
if (!connects(blockState)) return;
|
ConnectionHandler handler = getConnectionHandler(blockState);
|
||||||
int newBlockState = connect(user, pos, 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));
|
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++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
int block = section.getFlatBlock(x, y, z);
|
int block = section.getFlatBlock(x, y, z);
|
||||||
|
|
||||||
if (ConnectionData.connects(block)) {
|
ConnectionHandler handler = ConnectionData.getConnectionHandler(block);
|
||||||
block = ConnectionData.connect(user, new Position(xOff + x, yOff + y, zOff + z), block);
|
if (handler != null) {
|
||||||
|
block = handler.connect(user, new Position(xOff + x, yOff + y, zOff + z), block);
|
||||||
section.setFlatBlock(x, y, 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) {
|
public static int connect(UserConnection user, Position position, int blockState) {
|
||||||
if (connectionHandlerMap.containsKey(blockState)) {
|
|
||||||
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
ConnectionHandler handler = connectionHandlerMap.get(blockState);
|
||||||
return handler.connect(user, position, blockState);
|
return handler != null ? handler.connect(user, position, blockState) : blockState;
|
||||||
} else {
|
|
||||||
return blockState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ConnectionHandler getConnectionHandler(int blockstate) {
|
||||||
|
return connectionHandlerMap.get(blockstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getId(String key) {
|
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.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
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.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.MappingData;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
|
||||||
@ -177,11 +178,8 @@ public class WorldPackets {
|
|||||||
if (Via.getConfig().isServersideBlockConnections()) {
|
if (Via.getConfig().isServersideBlockConnections()) {
|
||||||
|
|
||||||
ConnectionData.updateBlockStorage(userConnection, position, newId);
|
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));
|
wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId));
|
||||||
if (Via.getConfig().isServersideBlockConnections()) {
|
if (Via.getConfig().isServersideBlockConnections()) {
|
||||||
// Workaround for packet order issue
|
// Workaround for packet order issue
|
||||||
@ -232,8 +230,9 @@ public class WorldPackets {
|
|||||||
(long) record.getY(),
|
(long) record.getY(),
|
||||||
(long) (record.getHorizontal() & 15) + (chunkZ * 16));
|
(long) (record.getHorizontal() & 15) + (chunkZ * 16));
|
||||||
|
|
||||||
if (ConnectionData.connects(blockState)) {
|
ConnectionHandler handler = ConnectionData.getConnectionHandler(blockState);
|
||||||
blockState = ConnectionData.connect(userConnection, position, blockState);
|
if (handler != null) {
|
||||||
|
blockState = handler.connect(userConnection, position, blockState);
|
||||||
record.setBlockId(blockState);
|
record.setBlockId(blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,10 +331,12 @@ public class InventoryPackets {
|
|||||||
CompoundTag tag;
|
CompoundTag tag;
|
||||||
if ((tag = item.getTag()) != null) {
|
if ((tag = item.getTag()) != null) {
|
||||||
// Display Lore now uses JSON
|
// Display Lore now uses JSON
|
||||||
if (tag.get("display") instanceof CompoundTag) {
|
Tag displayTag = tag.get("display");
|
||||||
CompoundTag display = tag.get("display");
|
if (displayTag instanceof CompoundTag) {
|
||||||
if (display.get("Lore") instanceof ListTag) {
|
CompoundTag display = (CompoundTag) displayTag;
|
||||||
ListTag lore = display.get("Lore");
|
Tag loreTag = display.get("Lore");
|
||||||
|
if (loreTag instanceof ListTag) {
|
||||||
|
ListTag lore = (ListTag) loreTag;
|
||||||
display.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|Lore", ConverterRegistry.convertToValue(lore)));
|
display.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|Lore", ConverterRegistry.convertToValue(lore)));
|
||||||
for (Tag loreEntry : lore) {
|
for (Tag loreEntry : lore) {
|
||||||
if (loreEntry instanceof StringTag) {
|
if (loreEntry instanceof StringTag) {
|
||||||
@ -366,10 +368,12 @@ public class InventoryPackets {
|
|||||||
CompoundTag tag;
|
CompoundTag tag;
|
||||||
if ((tag = item.getTag()) != null) {
|
if ((tag = item.getTag()) != null) {
|
||||||
// Display Name now uses JSON
|
// Display Name now uses JSON
|
||||||
if (tag.get("display") instanceof CompoundTag) {
|
Tag displayTag = tag.get("display");
|
||||||
CompoundTag display = tag.get("display");
|
if (displayTag instanceof CompoundTag) {
|
||||||
if (((CompoundTag) tag.get("display")).get("Lore") instanceof ListTag) {
|
CompoundTag display = (CompoundTag) displayTag;
|
||||||
ListTag lore = display.get("Lore");
|
Tag loreTag = display.get("Lore");
|
||||||
|
if (loreTag instanceof ListTag) {
|
||||||
|
ListTag lore = (ListTag) loreTag;
|
||||||
ListTag via = display.get(NBT_TAG_NAME + "|Lore");
|
ListTag via = display.get(NBT_TAG_NAME + "|Lore");
|
||||||
if (via != null) {
|
if (via != null) {
|
||||||
display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via)));
|
display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via)));
|
||||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren