3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 16:40:10 +01:00
Dieser Commit ist enthalten in:
Matsv 2016-07-11 15:52:06 +02:00
Ursprung db935b454f
Commit b2680d76a6
9 geänderte Dateien mit 74 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,20 @@
package us.myles.ViaVersion.api.type.types.minecraft;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.types.Metadata1_8Type;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.types.MetadataList1_8Type;
import java.util.List;
public class Types1_8 {
/**
* Metadata list type for 1.8
*/
public static Type<List<Metadata>> METADATA_LIST = new MetadataList1_8Type();
/**
* Metadata type for 1.8
*/
public static Type<Metadata> METADATA = new Metadata1_8Type();
}

Datei anzeigen

@ -0,0 +1,20 @@
package us.myles.ViaVersion.api.type.types.minecraft;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types.Meta1_9_1_10Type;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types.MetaList1_9_1_10Type;
import java.util.List;
public class Types1_9 {
/**
* Metadata list type for 1.9
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetaList1_9_1_10Type();
/**
* Metadata type for 1.9
*/
public static final Type<Metadata> METADATA = new Meta1_9_1_10Type();
}

Datei anzeigen

@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; 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.api.type.types.minecraft.Types1_9;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.storage.ResourcePackTracker; import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.storage.ResourcePackTracker;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types.Meta1_9_1_10Type; import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types.Meta1_9_1_10Type;
@ -17,15 +18,18 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
public class Protocol1_10To1_9_3_4 extends Protocol { public class Protocol1_10To1_9_3_4 extends Protocol {
@Deprecated
public static final Type<List<Metadata>> METADATA_LIST = new MetaList1_9_1_10Type(); public static final Type<List<Metadata>> METADATA_LIST = new MetaList1_9_1_10Type();
@Deprecated
public static final Type<Metadata> METADATA = new Meta1_9_1_10Type(); public static final Type<Metadata> METADATA = new Meta1_9_1_10Type();
public static ValueTransformer<Short, Float> toNewPitch = new ValueTransformer<Short, Float>(Type.FLOAT) { public static ValueTransformer<Short, Float> toNewPitch = new ValueTransformer<Short, Float>(Type.FLOAT) {
@Override @Override
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception { public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
return inputValue / 63.5F; return inputValue / 63.5F;
} }
}; };
public static ValueTransformer<List<Metadata>, List<Metadata>> transformMetadata = new ValueTransformer<List<Metadata>, List<Metadata>>(METADATA_LIST) { public static ValueTransformer<List<Metadata>, List<Metadata>> transformMetadata = new ValueTransformer<List<Metadata>, List<Metadata>>(Types1_9.METADATA_LIST) {
@Override @Override
public List<Metadata> transform(PacketWrapper wrapper, List<Metadata> inputValue) throws Exception { public List<Metadata> transform(PacketWrapper wrapper, List<Metadata> inputValue) throws Exception {
List<Metadata> metaList = new CopyOnWriteArrayList<>(inputValue); List<Metadata> metaList = new CopyOnWriteArrayList<>(inputValue);
@ -80,7 +84,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
map(METADATA_LIST, transformMetadata); // 1 - Metadata list map(Types1_9.METADATA_LIST, transformMetadata); // 1 - Metadata list
} }
}); });
@ -100,7 +104,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
map(Type.SHORT); // 9 - Velocity X map(Type.SHORT); // 9 - Velocity X
map(Type.SHORT); // 10 - Velocity Y map(Type.SHORT); // 10 - Velocity Y
map(Type.SHORT); // 11 - Velocity Z map(Type.SHORT); // 11 - Velocity Z
map(METADATA_LIST, transformMetadata); // 12 - Metadata map(Types1_9.METADATA_LIST, transformMetadata); // 12 - Metadata
} }
}); });
@ -115,7 +119,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
map(Type.DOUBLE); // 4 - Z map(Type.DOUBLE); // 4 - Z
map(Type.BYTE); // 5 - Yaw map(Type.BYTE); // 5 - Yaw
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
map(METADATA_LIST, transformMetadata); // 7 - Metadata list map(Types1_9.METADATA_LIST, transformMetadata); // 7 - Metadata list
} }
}); });

Datei anzeigen

@ -3,7 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.type.types.minecraft.MetaListTypeTemplate; import us.myles.ViaVersion.api.type.types.minecraft.MetaListTypeTemplate;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4; import us.myles.ViaVersion.api.type.types.minecraft.Types1_9;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -15,7 +15,7 @@ public class MetaList1_9_1_10Type extends MetaListTypeTemplate {
List<Metadata> list = new ArrayList<>(); List<Metadata> list = new ArrayList<>();
Metadata meta; Metadata meta;
do { do {
meta = Protocol1_10To1_9_3_4.METADATA.read(buffer); meta = Types1_9.METADATA.read(buffer);
if (meta != null) if (meta != null)
list.add(meta); list.add(meta);
} while (meta != null); } while (meta != null);
@ -26,9 +26,9 @@ public class MetaList1_9_1_10Type extends MetaListTypeTemplate {
@Override @Override
public void write(ByteBuf buffer, List<Metadata> object) throws Exception { public void write(ByteBuf buffer, List<Metadata> object) throws Exception {
for (Metadata m : object) for (Metadata m : object)
Protocol1_10To1_9_3_4.METADATA.write(buffer, m); Types1_9.METADATA.write(buffer, m);
// Write end of list // Write end of list
Protocol1_10To1_9_3_4.METADATA.write(buffer, null); Types1_9.METADATA.write(buffer, null);
} }
} }

Datei anzeigen

@ -26,8 +26,11 @@ import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class Protocol1_9TO1_8 extends Protocol { public class Protocol1_9TO1_8 extends Protocol {
@Deprecated
public static Type<List<Metadata>> METADATA_LIST = new MetadataList1_8Type(); public static Type<List<Metadata>> METADATA_LIST = new MetadataList1_8Type();
@Deprecated
public static Type<Metadata> METADATA = new Metadata1_8Type(); public static Type<Metadata> METADATA = new Metadata1_8Type();
private static Gson gson = new GsonBuilder().create(); private static Gson gson = new GsonBuilder().create();
public static ValueTransformer<String, String> FIX_JSON = new ValueTransformer<String, String>(Type.STRING) { public static ValueTransformer<String, String> FIX_JSON = new ValueTransformer<String, String>(Type.STRING) {
@Override @Override

Datei anzeigen

@ -10,8 +10,9 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; 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.api.type.types.minecraft.Types1_8;
import us.myles.ViaVersion.api.type.types.minecraft.Types1_9;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
@ -176,11 +177,11 @@ public class EntityPackets {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
map(Protocol1_9TO1_8.METADATA_LIST, Protocol1_10To1_9_3_4.METADATA_LIST); // 1 - Metadata List map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST); // 1 - Metadata List
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
List<Metadata> metadataList = wrapper.get(Protocol1_10To1_9_3_4.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if (tracker.getClientEntityTypes().containsKey(entityID)) { if (tracker.getClientEntityTypes().containsKey(entityID)) {
@ -197,7 +198,7 @@ public class EntityPackets {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
List<Metadata> metadataList = wrapper.get(Protocol1_10To1_9_3_4.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
tracker.handleMetadata(entityID, metadataList); tracker.handleMetadata(entityID, metadataList);
@ -208,7 +209,7 @@ public class EntityPackets {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
List<Metadata> metadataList = wrapper.get(Protocol1_10To1_9_3_4.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
if (metadataList.size() == 0) { if (metadataList.size() == 0) {
wrapper.cancel(); wrapper.cancel();
} }

Datei anzeigen

@ -11,8 +11,9 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueCreator;
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.api.type.types.minecraft.Types1_8;
import us.myles.ViaVersion.api.type.types.minecraft.Types1_9;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
@ -108,7 +109,7 @@ public class SpawnPackets {
// TEMP FIX FOR POTIONS UNTIL WE FIGURE OUT HOW TO TRANSFORM SENT PACKETS // TEMP FIX FOR POTIONS UNTIL WE FIGURE OUT HOW TO TRANSFORM SENT PACKETS
Metadata potion = new Metadata(5, NewType.Slot.getTypeID(), Type.ITEM, item); Metadata potion = new Metadata(5, NewType.Slot.getTypeID(), Type.ITEM, item);
meta.add(potion); meta.add(potion);
wrapper.write(Protocol1_10To1_9_3_4.METADATA_LIST, meta); wrapper.write(Types1_9.METADATA_LIST, meta);
} }
}); });
metaPacket.send(Protocol1_9TO1_8.class); metaPacket.send(Protocol1_9TO1_8.class);
@ -207,11 +208,11 @@ public class SpawnPackets {
map(Type.SHORT); // 10 - Velocity Y map(Type.SHORT); // 10 - Velocity Y
map(Type.SHORT); // 11 - Velocity Z map(Type.SHORT); // 11 - Velocity Z
map(Protocol1_9TO1_8.METADATA_LIST, Protocol1_10To1_9_3_4.METADATA_LIST); map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST);
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
List<Metadata> metadataList = wrapper.get(Protocol1_10To1_9_3_4.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if (tracker.getClientEntityTypes().containsKey(entityID)) { if (tracker.getClientEntityTypes().containsKey(entityID)) {
@ -226,7 +227,7 @@ public class SpawnPackets {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
List<Metadata> metadataList = wrapper.get(Protocol1_10To1_9_3_4.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
tracker.handleMetadata(entityID, metadataList); tracker.handleMetadata(entityID, metadataList);
@ -312,12 +313,12 @@ public class SpawnPackets {
} }
}); });
map(Protocol1_9TO1_8.METADATA_LIST, Protocol1_10To1_9_3_4.METADATA_LIST); map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST);
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
List<Metadata> metadataList = wrapper.get(Protocol1_10To1_9_3_4.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if (tracker.getClientEntityTypes().containsKey(entityID)) { if (tracker.getClientEntityTypes().containsKey(entityID)) {
@ -333,7 +334,7 @@ public class SpawnPackets {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
List<Metadata> metadataList = wrapper.get(Protocol1_10To1_9_3_4.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
tracker.handleMetadata(entityID, metadataList); tracker.handleMetadata(entityID, metadataList);

Datei anzeigen

@ -19,8 +19,8 @@ import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.minecraft.Types1_9;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chat.GameMode; import us.myles.ViaVersion.protocols.protocol1_9to1_8.chat.GameMode;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
@ -275,7 +275,7 @@ public class EntityTracker extends StoredObject {
if (metadataBuffer.containsKey(entityID)) { if (metadataBuffer.containsKey(entityID)) {
PacketWrapper wrapper = new PacketWrapper(0x39, null, getUser()); PacketWrapper wrapper = new PacketWrapper(0x39, null, getUser());
wrapper.write(Type.VAR_INT, entityID); wrapper.write(Type.VAR_INT, entityID);
wrapper.write(Protocol1_10To1_9_3_4.METADATA_LIST, metadataBuffer.get(entityID)); wrapper.write(Types1_9.METADATA_LIST, metadataBuffer.get(entityID));
MetadataRewriter.transform(getClientEntityTypes().get(entityID), metadataBuffer.get(entityID)); MetadataRewriter.transform(getClientEntityTypes().get(entityID), metadataBuffer.get(entityID));
handleMetadata(entityID, metadataBuffer.get(entityID)); handleMetadata(entityID, metadataBuffer.get(entityID));
if (metadataBuffer.get(entityID).size() > 0) { if (metadataBuffer.get(entityID).size() > 0) {

Datei anzeigen

@ -3,7 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.type.types.minecraft.MetaListTypeTemplate; import us.myles.ViaVersion.api.type.types.minecraft.MetaListTypeTemplate;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.api.type.types.minecraft.Types1_8;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -15,7 +15,7 @@ public class MetadataList1_8Type extends MetaListTypeTemplate {
List<Metadata> list = new ArrayList<>(); List<Metadata> list = new ArrayList<>();
Metadata m; Metadata m;
do { do {
m = Protocol1_9TO1_8.METADATA.read(buffer); m = Types1_8.METADATA.read(buffer);
if (m != null) { if (m != null) {
list.add(m); list.add(m);
} }