Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Let the transformer handle the signs (#456)
Dieser Commit ist enthalten in:
Ursprung
b55c0d0783
Commit
85e416171c
@ -277,9 +277,10 @@ public class PacketWrapper {
|
|||||||
* (Sends it after current)
|
* (Sends it after current)
|
||||||
*
|
*
|
||||||
* @param packetProtocol - The protocol version of the packet.
|
* @param packetProtocol - The protocol version of the packet.
|
||||||
|
* @param skipCurrentPipeline - Skip the current pipeline
|
||||||
* @throws Exception if it fails to write
|
* @throws Exception if it fails to write
|
||||||
*/
|
*/
|
||||||
public void send(Class<? extends Protocol> packetProtocol) throws Exception {
|
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception {
|
||||||
if (!isCancelled()) {
|
if (!isCancelled()) {
|
||||||
// Apply current pipeline
|
// Apply current pipeline
|
||||||
List<Protocol> protocols = new ArrayList<>(user().get(ProtocolInfo.class).getPipeline().pipes());
|
List<Protocol> protocols = new ArrayList<>(user().get(ProtocolInfo.class).getPipeline().pipes());
|
||||||
@ -288,10 +289,14 @@ public class PacketWrapper {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < protocols.size(); i++) {
|
for (int i = 0; i < protocols.size(); i++) {
|
||||||
if (protocols.get(i).getClass().equals(packetProtocol)) {
|
if (protocols.get(i).getClass().equals(packetProtocol)) {
|
||||||
index = i + 1;
|
index = skipCurrentPipeline ? (i + 1) : (i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset reader before we start
|
||||||
|
resetReader();
|
||||||
|
|
||||||
// Apply other protocols
|
// Apply other protocols
|
||||||
apply(Direction.OUTGOING, user().get(ProtocolInfo.class).getState(), index, protocols);
|
apply(Direction.OUTGOING, user().get(ProtocolInfo.class).getState(), index, protocols);
|
||||||
// Send
|
// Send
|
||||||
@ -301,6 +306,18 @@ public class PacketWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send this packet to the associated user.
|
||||||
|
* Be careful not to send packets twice.
|
||||||
|
* (Sends it after current)
|
||||||
|
*
|
||||||
|
* @param packetProtocol - The protocol version of the packet.
|
||||||
|
* @throws Exception if it fails to write
|
||||||
|
*/
|
||||||
|
public void send(Class<? extends Protocol> packetProtocol) throws Exception {
|
||||||
|
send(packetProtocol, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send this packet to the associated user.
|
* Send this packet to the associated user.
|
||||||
* Be careful not to send packets twice.
|
* Be careful not to send packets twice.
|
||||||
|
@ -10,7 +10,6 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
|
|||||||
import us.myles.ViaVersion.api.type.types.*;
|
import us.myles.ViaVersion.api.type.types.*;
|
||||||
import us.myles.ViaVersion.api.type.types.minecraft.*;
|
import us.myles.ViaVersion.api.type.types.minecraft.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -26,9 +26,6 @@ public class BlockEntity {
|
|||||||
types.put("UNKNOWN", 7);
|
types.put("UNKNOWN", 7);
|
||||||
types.put("EndGateway", 8);
|
types.put("EndGateway", 8);
|
||||||
types.put("Sign", 9);
|
types.put("Sign", 9);
|
||||||
|
|
||||||
//I didn't see anything that didn't work about chests
|
|
||||||
// types.put("Chest", -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(List<CompoundTag> tags, UserConnection connection) {
|
public static void handle(List<CompoundTag> tags, UserConnection connection) {
|
||||||
@ -51,14 +48,7 @@ public class BlockEntity {
|
|||||||
|
|
||||||
Position pos = new Position((long) x, (long) y, (long) z);
|
Position pos = new Position((long) x, (long) y, (long) z);
|
||||||
|
|
||||||
if (newId != 9) {
|
|
||||||
updateBlockEntity(pos, (short) newId, tag, connection);
|
updateBlockEntity(pos, (short) newId, tag, connection);
|
||||||
} else {
|
|
||||||
String[] lines = new String[4];
|
|
||||||
for (int i = 1; i < 5; i++)
|
|
||||||
lines[i - 1] = (String) tag.get("Text" + i).getValue();
|
|
||||||
updateSign(pos, lines, connection);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (ViaVersion.getInstance().isDebug()) {
|
if (ViaVersion.getInstance().isDebug()) {
|
||||||
System.out.println("Block Entity: " + e.getMessage() + ": " + tag);
|
System.out.println("Block Entity: " + e.getMessage() + ": " + tag);
|
||||||
@ -72,14 +62,6 @@ public class BlockEntity {
|
|||||||
wrapper.write(Type.POSITION, pos);
|
wrapper.write(Type.POSITION, pos);
|
||||||
wrapper.write(Type.UNSIGNED_BYTE, id);
|
wrapper.write(Type.UNSIGNED_BYTE, id);
|
||||||
wrapper.write(Type.NBT, tag);
|
wrapper.write(Type.NBT, tag);
|
||||||
wrapper.send(Protocol1_9_1_2TO1_9_3_4.class);
|
wrapper.send(Protocol1_9_1_2TO1_9_3_4.class, false);
|
||||||
}
|
|
||||||
|
|
||||||
private static void updateSign(Position pos, String[] lines, UserConnection connection) throws Exception {
|
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x46, null, connection);
|
|
||||||
wrapper.write(Type.POSITION, pos);
|
|
||||||
for (String s : lines)
|
|
||||||
wrapper.write(Type.STRING, s);
|
|
||||||
wrapper.send(Protocol1_9_1_2TO1_9_3_4.class);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren