Merge pull request #1 from MylesIsCool/master

Update From Original
This commit is contained in:
HugoDaBosss 2016-03-01 15:47:15 +01:00
commit 442d4de74b
5 changed files with 37 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# ViaVersion 0.3.2
# ViaVersion 0.3.3
**Allows the connection of 1.8 clients to 1.9**
This plugin modifies netty to allow connection of 1.9 clients to 1.8,
@ -20,18 +20,21 @@ Some items with JSON data cause crashing due to the change in how strict minecra
This took hours of work, so if you enjoy this consider looking into contacting me and supporting my projects.
Credits:
Sources:
--------
**wiki.vg** (Protocol info, though I did have to find a lot myself)
**MCProtocolLib** (used for chunk reading & some of writing.)
Contributors:
--------
**Myself** (harhar)
**Matsv** (Movement Fix / Correcting my stupidity)
**Matsv/StatBoom**
**HugoDaBosss** (Sounds fix)
**HugoDaBosss**
License:
--------

View File

@ -184,6 +184,13 @@ public class PacketUtil {
}
}
public static void writeVarIntArray(List<Integer> integers, ByteBuf output) {
writeVarInt(integers.size(),output);
for (Integer i : integers){
writeVarInt(i,output);
}
}
public static int readVarShort(ByteBuf buf) {
int low = buf.readUnsignedShort();
int high = 0;

View File

@ -36,7 +36,7 @@ public class IncomingTransformer {
// if (packet != PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST && packet != PacketType.PLAY_KEEP_ALIVE_REQUEST && packet != PacketType.PLAY_PLAYER_POSITION_REQUEST && packet != PacketType.PLAY_PLAYER_LOOK_REQUEST) {
// System.out.println("Packet Type: " + packet + " New ID: " + packetID + " Original: " + original);
// }
if (packet == PacketType.PLAY_TP_CONFIRM) {
if (packet == PacketType.PLAY_TP_CONFIRM || packet == PacketType.PLAY_VEHICLE_MOVE_REQUEST) { //TODO handle client-sided horse riding
throw new CancelException();
}
PacketUtil.writeVarInt(packetID, output);

View File

@ -25,6 +25,8 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import static us.myles.ViaVersion.PacketUtil.*;
public class OutgoingTransformer {
private static Gson gson = new Gson();
private final Channel channel;
@ -72,10 +74,25 @@ public class OutgoingTransformer {
output.writeBytes(input);
}
if (packet == PacketType.PLAY_ATTACH_ENTITY) {
int id = input.readInt();
output.writeInt(id);
int target = input.readInt();
output.writeInt(target);
int passenger = input.readInt();
int vehicle = input.readInt();
boolean lead = input.readBoolean();
if (!lead){
output.clear();
writeVarInt(PacketType.PLAY_SET_PASSENGERS.getNewPacketID(),output);
writeVarInt(vehicle,output);
writeVarIntArray(Collections.singletonList(passenger),output);
return;
}
output.writeInt(passenger);
output.writeInt(vehicle);
return;
}
if (packet == PacketType.PLAY_DISCONNECT){
String reason = readString(input);
if (reason.startsWith("\""))
reason = "{\"text\":" + reason + "}";
writeString(reason,output);
return;
}
if (packet == PacketType.PLAY_ENTITY_TELEPORT) {

View File

@ -1,4 +1,4 @@
name: ViaVersion
main: us.myles.ViaVersion.Core
author: _MylesC
version: 0.3.2
version: 0.3.3