Merge pull request #17 from StamBoom/master

Fixed riding on entities. (To some extent)
This commit is contained in:
Myles 2016-03-01 14:35:59 +00:00
commit 46ec24a686
3 changed files with 21 additions and 7 deletions

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,8 +25,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import static us.myles.ViaVersion.PacketUtil.readString;
import static us.myles.ViaVersion.PacketUtil.writeString;
import static us.myles.ViaVersion.PacketUtil.*;
public class OutgoingTransformer {
private static Gson gson = new Gson();
@ -75,10 +74,18 @@ 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){