Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 16:40:12 +01:00
Commit
f05bbbc2a1
@ -17,7 +17,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|||||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
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_11to1_10.Protocol1_11To1_10;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
|
|
||||||
public class PlayerPackets1_11 {
|
public class PlayerPackets1_11 {
|
||||||
private static final ValueTransformer<Short, Float> toNewFloat = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
private static final ValueTransformer<Short, Float> toNewFloat = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||||
@ -45,10 +45,13 @@ public class PlayerPackets1_11 {
|
|||||||
if (action == 2) {
|
if (action == 2) {
|
||||||
// Convert to the old actionbar way
|
// Convert to the old actionbar way
|
||||||
PacketWrapper actionbar = new PacketWrapper(0x0F, null, wrapper.user()); // Chat Message packet
|
PacketWrapper actionbar = new PacketWrapper(0x0F, null, wrapper.user()); // Chat Message packet
|
||||||
actionbar.write(Type.STRING, wrapper.read(Type.STRING));
|
String msg = wrapper.read(Type.STRING);
|
||||||
|
msg = ChatRewriter.jsonTextToLegacy(msg);
|
||||||
|
msg = "{\"text\":\"" + msg + "\"}";
|
||||||
|
actionbar.write(Type.STRING, msg);
|
||||||
actionbar.write(Type.BYTE, (byte) 2); // Above hotbar
|
actionbar.write(Type.BYTE, (byte) 2); // Above hotbar
|
||||||
|
|
||||||
actionbar.send(Protocol1_11To1_10.class);
|
actionbar.send(Protocol1_10To1_11.class);
|
||||||
|
|
||||||
wrapper.cancel(); // Cancel the title packet
|
wrapper.cancel(); // Cancel the title packet
|
||||||
return;
|
return;
|
||||||
|
@ -60,6 +60,46 @@ public class BlockItemPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
|||||||
@Override
|
@Override
|
||||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||||
|
|
||||||
|
// Block Action
|
||||||
|
protocol.out(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION); // Location
|
||||||
|
map(Type.UNSIGNED_BYTE); // Action Id
|
||||||
|
map(Type.UNSIGNED_BYTE); // Action param
|
||||||
|
map(Type.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int blockId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
|
||||||
|
if (blockId == 73)
|
||||||
|
blockId = 25;
|
||||||
|
else if (blockId == 99)
|
||||||
|
blockId = 33;
|
||||||
|
else if (blockId == 92)
|
||||||
|
blockId = 29;
|
||||||
|
else if (blockId == 142)
|
||||||
|
blockId = 54;
|
||||||
|
else if (blockId == 305)
|
||||||
|
blockId = 146;
|
||||||
|
else if (blockId == 249)
|
||||||
|
blockId = 130;
|
||||||
|
else if (blockId == 257)
|
||||||
|
blockId = 138;
|
||||||
|
else if (blockId == 140)
|
||||||
|
blockId = 52;
|
||||||
|
else if (blockId == 472)
|
||||||
|
blockId = 209;
|
||||||
|
else if (blockId >= 483 && blockId <= 498)
|
||||||
|
blockId = blockId - 483 + 219;
|
||||||
|
|
||||||
|
wrapper.set(Type.VAR_INT, 0, blockId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Update Block Entity
|
// Update Block Entity
|
||||||
protocol.out(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
protocol.out(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,7 +157,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
|||||||
String match = wrapper.read(Type.STRING);
|
String match = wrapper.read(Type.STRING);
|
||||||
wrapper.write(Type.STRING, (start == 0 ? "/" : "") + match);
|
wrapper.write(Type.STRING, (start == 0 ? "/" : "") + match);
|
||||||
// Ignore tooltip
|
// Ignore tooltip
|
||||||
wrapper.read(Type.OPTIONAL_CHAT);
|
if (wrapper.read(Type.BOOLEAN)) wrapper.read(Type.STRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -203,13 +203,9 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
|||||||
if (channel.equals("MC|BSign") || channel.equals("MC|BEdit")) {
|
if (channel.equals("MC|BSign") || channel.equals("MC|BEdit")) {
|
||||||
wrapper.setId(0x0B);
|
wrapper.setId(0x0B);
|
||||||
Item book = wrapper.read(Type.ITEM);
|
Item book = wrapper.read(Type.ITEM);
|
||||||
System.out.println(book);
|
|
||||||
BlockItemPackets1_13.toServer(book);
|
BlockItemPackets1_13.toServer(book);
|
||||||
System.out.println(book);
|
|
||||||
wrapper.write(Type.FLAT_ITEM, book);
|
wrapper.write(Type.FLAT_ITEM, book);
|
||||||
boolean signing = channel.equals("MC|BSign");
|
boolean signing = channel.equals("MC|BSign");
|
||||||
System.out.println(channel);
|
|
||||||
System.out.println(signing);
|
|
||||||
wrapper.write(Type.BOOLEAN, signing);
|
wrapper.write(Type.BOOLEAN, signing);
|
||||||
} else if (channel.equals("MC|ItemName")) {
|
} else if (channel.equals("MC|ItemName")) {
|
||||||
wrapper.setId(0x1C);
|
wrapper.setId(0x1C);
|
||||||
|
@ -182,8 +182,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
|||||||
public static int getNewBlockStateId(int blockId) {
|
public static int getNewBlockStateId(int blockId) {
|
||||||
if (blockId > 8590) {
|
if (blockId > 8590) {
|
||||||
blockId -= 17;
|
blockId -= 17;
|
||||||
} else if (blockId > 8573) {
|
} else if (blockId > 8588) {
|
||||||
blockId = 0; //TODO replace new blocks
|
blockId = 8573;
|
||||||
} else if (blockId > 8479) {
|
} else if (blockId > 8479) {
|
||||||
blockId -= 16;
|
blockId -= 16;
|
||||||
} else if (blockId > 8469 && blockId % 2 == 0) {
|
} else if (blockId > 8469 && blockId % 2 == 0) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren