3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 00:22:51 +01:00

maybe cleaner code?

Dieser Commit ist enthalten in:
creeper123123321 2018-06-28 07:34:56 -03:00
Ursprung 383cbe15a6
Commit 7fda025c0d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1

Datei anzeigen

@ -658,22 +658,19 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
} }
}); });
handler(POS_TO_3_INT); handler(POS_TO_3_INT);
map(Type.VAR_INT, Type.BYTE); // Action map(Type.VAR_INT, new ValueTransformer<Integer, Byte>(Type.BYTE) { // Action
handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public Byte transform(PacketWrapper wrapper, Integer action) throws Exception {
wrapper.set(Type.BYTE, 0, (byte) (wrapper.get(Type.BYTE, 0) + 1)); // Action return (byte) (action + 1);
} }
}); }); // Action
handler(new PacketHandler() { map(Type.VAR_INT, new ValueTransformer<Integer, String>(Type.STRING) {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public String transform(PacketWrapper wrapper, Integer mode) throws Exception {
int mode = wrapper.read(Type.VAR_INT); return mode == 0 ? "SAVE"
String stringMode = mode == 0 ? "SAVE"
: mode == 1 ? "LOAD" : mode == 1 ? "LOAD"
: mode == 2 ? "CORNER" : mode == 2 ? "CORNER"
: "DATA"; : "DATA";
wrapper.write(Type.STRING, stringMode);
} }
}); });
map(Type.STRING); // Name map(Type.STRING); // Name
@ -683,27 +680,31 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
map(Type.BYTE, Type.INT); // Size X map(Type.BYTE, Type.INT); // Size X
map(Type.BYTE, Type.INT); // Size Y map(Type.BYTE, Type.INT); // Size Y
map(Type.BYTE, Type.INT); // Size Z map(Type.BYTE, Type.INT); // Size Z
map(Type.VAR_INT, new ValueTransformer<Integer, String>(Type.STRING) { // Mirror
@Override
public String transform(PacketWrapper wrapper, Integer mirror) throws Exception {
return mirror == 0 ? "NONE"
: mirror == 1 ? "LEFT_RIGHT"
: "FRONT_BACK";
}
});
map(Type.VAR_INT, new ValueTransformer<Integer, String>(Type.STRING) { // Rotation
@Override
public String transform(PacketWrapper wrapper, Integer rotation) throws Exception {
return rotation == 0 ? "NONE"
: rotation == 1 ? "CLOCKWISE_90"
: rotation == 2 ? "CLOCKWISE_180"
: "COUNTERCLOCKWISE_90";
}
});
map(Type.STRING);
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
int mirror = wrapper.read(Type.VAR_INT);
int rotation = wrapper.read(Type.VAR_INT);
String metadata = wrapper.read(Type.STRING);
float integrity = wrapper.read(Type.FLOAT); float integrity = wrapper.read(Type.FLOAT);
long seed = wrapper.read(Type.VAR_LONG); long seed = wrapper.read(Type.VAR_LONG);
byte flags = wrapper.read(Type.BYTE); byte flags = wrapper.read(Type.BYTE);
String stringMirror = mirror == 0 ? "NONE"
: mirror == 1 ? "LEFT_RIGHT"
: "FRONT_BACK";
String stringRotation = rotation == 0 ? "NONE"
: rotation == 1 ? "CLOCKWISE_90"
: rotation == 2 ? "CLOCKWISE_180"
: "COUNTERCLOCKWISE_90";
wrapper.write(Type.STRING, stringMirror);
wrapper.write(Type.STRING, stringRotation);
wrapper.write(Type.STRING, metadata);
wrapper.write(Type.BOOLEAN, (flags & 0x1) != 0); // Ignore Entities wrapper.write(Type.BOOLEAN, (flags & 0x1) != 0); // Ignore Entities
wrapper.write(Type.BOOLEAN, (flags & 0x2) != 0); // Show air wrapper.write(Type.BOOLEAN, (flags & 0x2) != 0); // Show air
wrapper.write(Type.BOOLEAN, (flags & 0x4) != 0); // Show bounding box wrapper.write(Type.BOOLEAN, (flags & 0x4) != 0); // Show bounding box