Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 16:12:43 +01:00
Merge branch 'dev' of https://github.com/Matsv/ViaBackwards into 1.13_items
# Conflicts: # core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java
Dieser Commit ist enthalten in:
Commit
e35f264e89
@ -81,5 +81,11 @@
|
||||
<artifactId>viabackwards-sponge</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-velocity</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -22,8 +22,8 @@ import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.update.Version;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -54,21 +54,22 @@ public interface ViaBackwardsPlatform {
|
||||
*/
|
||||
Logger getLogger();
|
||||
|
||||
// TODO remove or better implement later
|
||||
default boolean isOutdated() {
|
||||
String minimumVVVersion = "2.0.0";
|
||||
boolean upToDate = false;
|
||||
try {
|
||||
Class<?> clazz = Class.forName("us.myles.ViaVersion.api.protocol.ProtocolVersion");
|
||||
Field v1_13 = clazz.getField("v1_13");
|
||||
Class<?> vvVersionInfo = Class.forName("us.myles.ViaVersion.sponge.VersionInfo");
|
||||
String vvVersion = (String) vvVersionInfo.getField("VERSION").get(null);
|
||||
|
||||
upToDate = (v1_13 != null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException ignored) {
|
||||
upToDate = (vvVersion != null
|
||||
&& new Version(vvVersion).compareTo(new Version(minimumVVVersion + "--")) >= 0);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) {
|
||||
}
|
||||
|
||||
if (!upToDate) {
|
||||
getLogger().severe("================================");
|
||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||
getLogger().severe("PLEASE USE THE LATEST VERSION");
|
||||
getLogger().severe("PLEASE USE VIAVERSION " + minimumVVVersion + " OR NEWER");
|
||||
getLogger().severe("LINK: https://viaversion.com");
|
||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||
getLogger().severe("================================");
|
||||
|
@ -8,20 +8,20 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityTypeMapping {
|
||||
private static Map<Integer, Integer> entityTypes = new HashMap<>();
|
||||
private static Map<Integer, Integer> entityTypes = new HashMap<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Field field = EntityTypeRewriter.class.getDeclaredField("entityTypes");
|
||||
field.setAccessible(true);
|
||||
Map<Integer, Integer> entityTypes = (Map<Integer, Integer>) field.get(null);
|
||||
entityTypes.forEach((type1_12, type1_13) -> EntityTypeMapping.entityTypes.put(type1_13, type1_12));
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
static {
|
||||
try {
|
||||
Field field = EntityTypeRewriter.class.getDeclaredField("entityTypes");
|
||||
field.setAccessible(true);
|
||||
Map<Integer, Integer> entityTypes = (Map<Integer, Integer>) field.get(null);
|
||||
entityTypes.forEach((type1_12, type1_13) -> EntityTypeMapping.entityTypes.put(type1_13, type1_12));
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<Integer> getOldId(int type1_13) {
|
||||
return Optional.ofNullable(entityTypes.get(type1_13));
|
||||
}
|
||||
public static Optional<Integer> getOldId(int type1_13) {
|
||||
return Optional.ofNullable(entityTypes.get(type1_13));
|
||||
}
|
||||
}
|
||||
|
@ -7,20 +7,20 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class NamedSoundMapping {
|
||||
private static Map<String, String> sounds = new HashMap<>();
|
||||
private static Map<String, String> sounds = new HashMap<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Field field = NamedSoundRewriter.class.getDeclaredField("oldToNew");
|
||||
field.setAccessible(true);
|
||||
Map<String, String> sounds = (Map<String, String>) field.get(null);
|
||||
sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.sounds.put(sound1_13, sound1_12));
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
static {
|
||||
try {
|
||||
Field field = NamedSoundRewriter.class.getDeclaredField("oldToNew");
|
||||
field.setAccessible(true);
|
||||
Map<String, String> sounds = (Map<String, String>) field.get(null);
|
||||
sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.sounds.put(sound1_13, sound1_12));
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getOldId(String sound1_13) {
|
||||
return sounds.get(sound1_13);
|
||||
}
|
||||
public static String getOldId(String sound1_13) {
|
||||
return sounds.get(sound1_13);
|
||||
}
|
||||
}
|
||||
|
@ -4,42 +4,42 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PaintingMapping {
|
||||
private static Map<Integer, String> paintings = new HashMap<>();
|
||||
private static Map<Integer, String> paintings = new HashMap<>();
|
||||
|
||||
public static void init() {
|
||||
add("kebab");
|
||||
add("aztec");
|
||||
add("alban");
|
||||
add("aztec2");
|
||||
add("bomb");
|
||||
add("plant");
|
||||
add("wasteland");
|
||||
add("pool");
|
||||
add("courbet");
|
||||
add("sea");
|
||||
add("sunset");
|
||||
add("creebet");
|
||||
add("wanderer");
|
||||
add("graham");
|
||||
add("match");
|
||||
add("bust");
|
||||
add("stage");
|
||||
add("void");
|
||||
add("skullandroses");
|
||||
add("wither");
|
||||
add("fighters");
|
||||
add("pointer");
|
||||
add("pigscene");
|
||||
add("burningskull");
|
||||
add("skeleton");
|
||||
add("donkeykong");
|
||||
}
|
||||
public static void init() {
|
||||
add("kebab");
|
||||
add("aztec");
|
||||
add("alban");
|
||||
add("aztec2");
|
||||
add("bomb");
|
||||
add("plant");
|
||||
add("wasteland");
|
||||
add("pool");
|
||||
add("courbet");
|
||||
add("sea");
|
||||
add("sunset");
|
||||
add("creebet");
|
||||
add("wanderer");
|
||||
add("graham");
|
||||
add("match");
|
||||
add("bust");
|
||||
add("stage");
|
||||
add("void");
|
||||
add("skullandroses");
|
||||
add("wither");
|
||||
add("fighters");
|
||||
add("pointer");
|
||||
add("pigscene");
|
||||
add("burningskull");
|
||||
add("skeleton");
|
||||
add("donkeykong");
|
||||
}
|
||||
|
||||
private static void add(String motive) {
|
||||
paintings.put(paintings.size(), motive);
|
||||
}
|
||||
private static void add(String motive) {
|
||||
paintings.put(paintings.size(), motive);
|
||||
}
|
||||
|
||||
public static String getStringId(int id) {
|
||||
return paintings.getOrDefault(id, "kebab");
|
||||
}
|
||||
public static String getStringId(int id) {
|
||||
return paintings.getOrDefault(id, "kebab");
|
||||
}
|
||||
}
|
||||
|
@ -9,36 +9,36 @@ import java.util.Arrays;
|
||||
import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData;
|
||||
|
||||
public class SoundMapping {
|
||||
private static short[] sounds = new short[662];
|
||||
private static short[] sounds = new short[662];
|
||||
|
||||
public static void init() {
|
||||
JsonObject mapping1_12 = loadData("mapping-1.12.json");
|
||||
JsonObject mapping1_13 = loadData("mapping-1.13.json");
|
||||
public static void init() {
|
||||
JsonObject mapping1_12 = loadData("mapping-1.12.json");
|
||||
JsonObject mapping1_13 = loadData("mapping-1.13.json");
|
||||
|
||||
Arrays.fill(sounds, (short) -1);
|
||||
mapIdentifiers(sounds, mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"));
|
||||
}
|
||||
Arrays.fill(sounds, (short) -1);
|
||||
mapIdentifiers(sounds, mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"));
|
||||
}
|
||||
|
||||
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
|
||||
for (int i = 0; i < oldIdentifiers.size(); i++) {
|
||||
JsonElement v = oldIdentifiers.get(i);
|
||||
Integer index = findIndex(newIdentifiers, v.getAsString());
|
||||
if (index == null) continue; //There will be missing sounds, since we are goind backwards
|
||||
output[i] = index.shortValue();
|
||||
}
|
||||
}
|
||||
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
|
||||
for (int i = 0; i < oldIdentifiers.size(); i++) {
|
||||
JsonElement v = oldIdentifiers.get(i);
|
||||
Integer index = findIndex(newIdentifiers, v.getAsString());
|
||||
if (index == null) continue; //There will be missing sounds, since we are goind backwards
|
||||
output[i] = index.shortValue();
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer findIndex(JsonArray array, String value) {
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JsonElement v = array.get(i);
|
||||
if (v.getAsString().equals(value)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static Integer findIndex(JsonArray array, String value) {
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JsonElement v = array.get(i);
|
||||
if (v.getAsString().equals(value)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getOldSound(int newSound) {
|
||||
return newSound >= sounds.length ? -1 : sounds[newSound];
|
||||
}
|
||||
public static int getOldSound(int newSound) {
|
||||
return newSound >= sounds.length ? -1 : sounds[newSound];
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
Item[] items = wrapper.get(Type.ITEM_ARRAY, 0);
|
||||
for (int i = 0; i < items.length; i++)
|
||||
items[i] = handleItemToClient(items[i]);
|
||||
wrapper.set(Type.ITEM_ARRAY,0, items);
|
||||
wrapper.set(Type.ITEM_ARRAY, 0, items);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -635,14 +635,14 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
ListTag ench = new ListTag("ench", CompoundTag.class);
|
||||
List<Tag> lore = new ArrayList<>();
|
||||
boolean dummyEnchatment = true;
|
||||
for (Tag enchantmentEntry : enchantments) {
|
||||
for (Tag enchantmentEntry : enchantments.clone()) {
|
||||
if (enchantmentEntry instanceof CompoundTag) {
|
||||
CompoundTag enchEntry = new CompoundTag("");
|
||||
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
||||
if(enchantmentMappings.containsKey(newId)){
|
||||
if (enchantmentMappings.containsKey(newId)) {
|
||||
lore.add(new StringTag("", enchantmentMappings.get(newId)));
|
||||
noMapped.add(enchantmentEntry);
|
||||
}else{
|
||||
} else {
|
||||
dummyEnchatment = false;
|
||||
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId);
|
||||
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
||||
@ -681,20 +681,20 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
tag.put(noMapped);
|
||||
tag.put(ench);
|
||||
|
||||
if(!lore.isEmpty()){
|
||||
if (!lore.isEmpty()) {
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display==null) {
|
||||
if (display == null) {
|
||||
tag.put(display = new CompoundTag("display"));
|
||||
tag.put(new ByteTag(NBT_TAG_NAME + "|noDisplay"));
|
||||
}
|
||||
ListTag loreTag = display.get("Lore");
|
||||
if (loreTag==null){
|
||||
if (loreTag == null) {
|
||||
display.put(loreTag = new ListTag("Lore", StringTag.class));
|
||||
}
|
||||
|
||||
ListTag oldLore = new ListTag(NBT_TAG_NAME + "|OldLore", StringTag.class);
|
||||
Iterator<Tag> iterator = lore.iterator();
|
||||
while(iterator.hasNext()){
|
||||
while (iterator.hasNext()) {
|
||||
oldLore.add(iterator.next().clone());
|
||||
}
|
||||
display.put(oldLore);
|
||||
@ -712,10 +712,10 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
if (enchantmentEntry instanceof CompoundTag) {
|
||||
CompoundTag enchEntry = new CompoundTag("");
|
||||
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
||||
if(enchantmentMappings.containsKey(newId)){
|
||||
if (enchantmentMappings.containsKey(newId)) {
|
||||
lore.add(new StringTag("", enchantmentMappings.get(newId)));
|
||||
noMapped.add(enchantmentEntry);
|
||||
}else{
|
||||
} else {
|
||||
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId);
|
||||
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
||||
oldId = Short.valueOf(newId.substring(18));
|
||||
@ -735,20 +735,20 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
tag.put(noMapped);
|
||||
tag.put(newStoredEnch);
|
||||
|
||||
if(!lore.isEmpty()){
|
||||
if (!lore.isEmpty()) {
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display==null) {
|
||||
if (display == null) {
|
||||
tag.put(display = new CompoundTag("display"));
|
||||
tag.put(new ByteTag(NBT_TAG_NAME + "|noDisplay"));
|
||||
}
|
||||
ListTag loreTag = display.get("Lore");
|
||||
if (loreTag==null){
|
||||
if (loreTag == null) {
|
||||
display.put(loreTag = new ListTag("Lore", StringTag.class));
|
||||
}
|
||||
|
||||
ListTag oldLore = new ListTag(NBT_TAG_NAME + "|OldLore", StringTag.class);
|
||||
Iterator<Tag> iterator = lore.iterator();
|
||||
while(iterator.hasNext()){
|
||||
while (iterator.hasNext()) {
|
||||
oldLore.add(iterator.next().clone());
|
||||
}
|
||||
display.put(oldLore);
|
||||
@ -853,10 +853,10 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
// Display Name now uses JSON
|
||||
if (tag.get("display") instanceof CompoundTag) {
|
||||
CompoundTag display = tag.get("display");
|
||||
if(tag.get(NBT_TAG_NAME + "|noDisplay") instanceof ByteTag){
|
||||
if (tag.get(NBT_TAG_NAME + "|noDisplay") instanceof ByteTag) {
|
||||
tag.remove("display");
|
||||
tag.remove(NBT_TAG_NAME + "|noDisplay");
|
||||
}else{
|
||||
} else {
|
||||
if (display.get("Name") instanceof StringTag) {
|
||||
StringTag name = display.get("Name");
|
||||
display.put(new StringTag(NBT_TAG_NAME + "|Name", name.getValue()));
|
||||
@ -866,12 +866,12 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
)
|
||||
);
|
||||
}
|
||||
if(display.get(NBT_TAG_NAME + "|OldLore") instanceof ListTag){
|
||||
if (display.get(NBT_TAG_NAME + "|OldLore") instanceof ListTag) {
|
||||
ListTag loreTag = new ListTag("Lore", StringTag.class);
|
||||
ListTag oldLore = display.get(NBT_TAG_NAME + "|OldLore");
|
||||
Iterator<Tag> iterator = oldLore.iterator();
|
||||
|
||||
while (iterator.hasNext()){
|
||||
while (iterator.hasNext()) {
|
||||
loreTag.add(iterator.next());
|
||||
}
|
||||
display.remove("Lore");
|
||||
@ -915,10 +915,10 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
enchantments.add(enchantmentEntry);
|
||||
}
|
||||
}
|
||||
if(tag.get(NBT_TAG_NAME + "|Enchantments") instanceof ListTag){
|
||||
if (tag.get(NBT_TAG_NAME + "|Enchantments") instanceof ListTag) {
|
||||
ListTag noMapped = tag.get(NBT_TAG_NAME + "|Enchantments");
|
||||
Iterator<Tag> iterator = noMapped.iterator();
|
||||
while (iterator.hasNext()){
|
||||
while (iterator.hasNext()) {
|
||||
enchantments.add(iterator.next());
|
||||
}
|
||||
tag.remove(NBT_TAG_NAME + "|Enchantments");
|
||||
@ -944,10 +944,10 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
newStoredEnch.add(enchantmentEntry);
|
||||
}
|
||||
}
|
||||
if(tag.get(NBT_TAG_NAME + "|Enchantments") instanceof ListTag){
|
||||
if (tag.get(NBT_TAG_NAME + "|Enchantments") instanceof ListTag) {
|
||||
ListTag noMapped = tag.get(NBT_TAG_NAME + "|StoredEnchantments");
|
||||
Iterator<Tag> iterator = noMapped.iterator();
|
||||
while (iterator.hasNext()){
|
||||
while (iterator.hasNext()) {
|
||||
newStoredEnch.add(iterator.next());
|
||||
}
|
||||
}
|
||||
@ -1057,7 +1057,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
|
||||
|
||||
private void handleEnchantmentClient(Item item){
|
||||
private void handleEnchantmentClient(Item item) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -465,13 +465,8 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||
// Remove boat splash timer
|
||||
registerMetaHandler().filter(EntityType.BOAT, 12).removed();
|
||||
|
||||
//Remove shooter UUID
|
||||
registerMetaHandler().filter(EntityType.ABSTRACT_ARROW, true, 7).removed();
|
||||
|
||||
registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8).handleIndexChange(7);
|
||||
|
||||
// Remove Trident special loyalty level
|
||||
registerMetaHandler().filter(EntityType.TRIDENT, 8).removed();
|
||||
registerMetaHandler().filter(EntityType.TRIDENT, 7).removed();
|
||||
|
||||
// Handle new wolf colors
|
||||
registerMetaHandler().filter(EntityType.WOLF, 17).handle(e -> {
|
||||
|
@ -9,6 +9,7 @@ import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
@ -17,6 +18,25 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPacke
|
||||
public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
// Login Plugin Request
|
||||
protocol.out(State.LOGIN, 0x04, -1, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
packetWrapper.cancel();
|
||||
packetWrapper.create(0x02, new ValueCreator() { // Plugin response
|
||||
@Override
|
||||
public void write(PacketWrapper newWrapper) throws Exception {
|
||||
newWrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
|
||||
newWrapper.write(Type.BOOLEAN, false); // Success
|
||||
}
|
||||
}).sendToServer(Protocol1_12_2To1_13.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Plugin Message
|
||||
protocol.out(State.PLAY, 0x19, 0x18, new PacketRemapper() {
|
||||
@ -30,21 +50,21 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
wrapper.write(Type.STRING, "MC|TrList");
|
||||
wrapper.passthrough(Type.INT); //Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
//Input Item
|
||||
Item input = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(input));
|
||||
//Output Item
|
||||
Item output = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(output));
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
//Input Item
|
||||
Item input = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(input));
|
||||
//Output Item
|
||||
Item output = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(output));
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
|
||||
if (secondItem) {
|
||||
//Second Item
|
||||
Item second = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(second));
|
||||
}
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
|
||||
if (secondItem) {
|
||||
//Second Item
|
||||
Item second = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(second));
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); //Trade disabled
|
||||
wrapper.passthrough(Type.INT); //Number of tools uses
|
||||
@ -158,7 +178,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
String match = wrapper.read(Type.STRING);
|
||||
wrapper.write(Type.STRING, (start == 0 ? "/" : "") + match);
|
||||
// Ignore tooltip
|
||||
if (wrapper.read(Type.BOOLEAN)) wrapper.read(Type.STRING);
|
||||
if (wrapper.read(Type.BOOLEAN)) wrapper.read(Type.STRING);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -11,76 +11,76 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
private static final String[] SOUND_SOURCES = {"master", "music", "record", "weather", "block", "hostile", "neutral", "player", "ambient", "voice"};
|
||||
private static final String[] SOUND_SOURCES = {"master", "music", "record", "weather", "block", "hostile", "neutral", "player", "ambient", "voice"};
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
|
||||
//Named Sound Event
|
||||
protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
String newSound = wrapper.get(Type.STRING, 0);
|
||||
String oldSound = NamedSoundMapping.getOldId(newSound);
|
||||
if (oldSound != null) {
|
||||
wrapper.set(Type.STRING, 0, oldSound);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
//Named Sound Event
|
||||
protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
String newSound = wrapper.get(Type.STRING, 0);
|
||||
String oldSound = NamedSoundMapping.getOldId(newSound);
|
||||
if (oldSound != null) {
|
||||
wrapper.set(Type.STRING, 0, oldSound);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Stop Sound
|
||||
protocol.out(State.PLAY, 0x4C, 0x18, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.STRING, "MC|StopSound");
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
String source;
|
||||
if ((flags & 0x01) != 0) {
|
||||
source = SOUND_SOURCES[wrapper.read(Type.VAR_INT)];
|
||||
} else {
|
||||
source = "";
|
||||
}
|
||||
String sound = (flags & 0x02) != 0 ? wrapper.read(Type.STRING) : "";
|
||||
//Stop Sound
|
||||
protocol.out(State.PLAY, 0x4C, 0x18, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.STRING, "MC|StopSound");
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
String source;
|
||||
if ((flags & 0x01) != 0) {
|
||||
source = SOUND_SOURCES[wrapper.read(Type.VAR_INT)];
|
||||
} else {
|
||||
source = "";
|
||||
}
|
||||
String sound = (flags & 0x02) != 0 ? wrapper.read(Type.STRING) : "";
|
||||
|
||||
wrapper.write(Type.STRING, source);
|
||||
wrapper.write(Type.STRING, sound);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
wrapper.write(Type.STRING, source);
|
||||
wrapper.write(Type.STRING, sound);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Sound Effect
|
||||
protocol.out(State.PLAY, 0x4D, 0x49, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int newSound = wrapper.get(Type.VAR_INT, 0);
|
||||
int oldSound = SoundMapping.getOldSound(newSound);
|
||||
if (oldSound == -1) {
|
||||
wrapper.cancel();
|
||||
} else {
|
||||
wrapper.set(Type.VAR_INT, 0, oldSound);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
//Sound Effect
|
||||
protocol.out(State.PLAY, 0x4D, 0x49, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int newSound = wrapper.get(Type.VAR_INT, 0);
|
||||
int oldSound = SoundMapping.getOldSound(newSound);
|
||||
if (oldSound == -1) {
|
||||
wrapper.cancel();
|
||||
} else {
|
||||
wrapper.set(Type.VAR_INT, 0, oldSound);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.EntityPackets1_13_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.InventoryPackets1_13_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.WorldPackets1_13_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -8,17 +11,14 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.EntityPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.InventoryPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.WorldPackets;
|
||||
|
||||
public class Protocol1_13_1To1_13_2 extends BackwardsProtocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
InventoryPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
EntityPackets.register(this);
|
||||
InventoryPackets1_13_2.register(this);
|
||||
WorldPackets1_13_2.register(this);
|
||||
EntityPackets1_13_2.register(this);
|
||||
|
||||
//Edit Book
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
|
@ -12,7 +12,7 @@ import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class EntityPackets {
|
||||
public class EntityPackets1_13_2 {
|
||||
|
||||
|
||||
public static void register(Protocol protocol) {
|
@ -7,7 +7,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class InventoryPackets {
|
||||
public class InventoryPackets1_13_2 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
|
@ -7,7 +7,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class WorldPackets {
|
||||
public class WorldPackets1_13_2 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
//spawn particle
|
||||
@ -24,6 +24,7 @@ public class WorldPackets {
|
||||
map(Type.FLOAT); // 7 - Offset Z
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
@ -1,48 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter {
|
||||
|
||||
public static void handleMetadata(int entityId, Entity1_13Types.EntityType type, List<Metadata> metadatas, UserConnection connection) {
|
||||
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
||||
try {
|
||||
// 1.13 changed item to flat item (no data)
|
||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
||||
InventoryPackets.toClient((Item) metadata.getValue());
|
||||
} else if (metadata.getMetaType() == MetaType1_13.BlockID) {
|
||||
// Convert to new block id
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
if (type == null) continue;
|
||||
if (type.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT) && metadata.getId() == 9) {
|
||||
// New block format
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
if(type.is(EntityType.ITEM)){
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
metadatas.remove(metadata);
|
||||
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler");
|
||||
Via.getPlatform().getLogger().warning("Metadata: " + metadata);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -12,16 +13,15 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
EntityPackets.register(this);
|
||||
InventoryPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
new EntityPackets1_13_1().register(this);
|
||||
InventoryPackets1_13_1.register(this);
|
||||
WorldPackets1_13_1.register(this);
|
||||
|
||||
//Tab complete
|
||||
registerIncoming(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
@ -47,7 +47,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
InventoryPackets.toServer(wrapper.get(Type.FLAT_ITEM, 0));
|
||||
InventoryPackets1_13_1.toServer(wrapper.get(Type.FLAT_ITEM, 0));
|
||||
wrapper.write(Type.VAR_INT, 0);
|
||||
}
|
||||
});
|
||||
@ -128,7 +128,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
Item icon = wrapper.passthrough(Type.FLAT_ITEM);
|
||||
InventoryPackets.toClient(icon);
|
||||
InventoryPackets1_13_1.toClient(icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
@ -169,7 +169,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Integer[] items = wrapper.passthrough(Type.VAR_INT_ARRAY);
|
||||
for (int j = 0; j < items.length; j++) {
|
||||
items[j] = InventoryPackets.getOldItemId(items[j]);
|
||||
items[j] = InventoryPackets1_13_1.getOldItemId(items[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,9 +214,15 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.put(new EntityTracker(userConnection));
|
||||
if (!userConnection.has(ClientWorld.class))
|
||||
userConnection.put(new ClientWorld(userConnection));
|
||||
public void init(UserConnection user) {
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
user.put(new EntityTracker(user));
|
||||
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
||||
if (!user.has(ClientWorld.class))
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
}
|
||||
|
@ -1,152 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.MetadataRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types.EntityType;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
|
||||
|
||||
public class EntityPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
|
||||
//spawn entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - Data
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
byte type = wrapper.get(Type.BYTE, 0);
|
||||
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true);
|
||||
|
||||
if (entType != null) {
|
||||
if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
}
|
||||
// Register Type ID
|
||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// Spawn mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_13.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
|
||||
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, false);
|
||||
|
||||
// Register Type ID
|
||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
||||
|
||||
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
map(Type.DOUBLE); // 3 - Y
|
||||
map(Type.DOUBLE); // 4 - Z
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_13.METADATA_LIST); // 7 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
Entity1_13Types.EntityType entType = Entity1_13Types.EntityType.PLAYER;
|
||||
// Register Type ID
|
||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
||||
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// Destroy entities
|
||||
protocol.registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||
wrapper.user().get(EntityTracker.class).removeEntity(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Metadata packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_13.METADATA_LIST); // 1 - Metadata list
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
Optional<EntityType> type = wrapper.user().get(EntityTracker.class).get(entityId);
|
||||
MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,360 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13.EntityType;
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_13To1_13_1 protocol) {
|
||||
|
||||
// Spawn Object
|
||||
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - Data
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
byte type = wrapper.get(Type.BYTE, 0);
|
||||
EntityType entType = EntityType1_13.getTypeFromId(type, true);
|
||||
if (entType == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
||||
return;
|
||||
}
|
||||
|
||||
// Rewrite falling block
|
||||
if (entType.is(EntityType.FALLING_BLOCK)) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
|
||||
// Track Entity
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
entityId,
|
||||
entType
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
protocol.out(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
EntityType.XP_ORB
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Global Entity
|
||||
protocol.out(State.PLAY, 0x02, 0x02, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
EntityType.LIGHTNING_BOLT
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Mob
|
||||
protocol.out(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_13.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
|
||||
EntityType entityType = EntityType1_13.getTypeFromId(type, false);
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
entityType
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Rewrite Metadata
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
MetaStorage storage = new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0));
|
||||
handleMeta(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
storage
|
||||
);
|
||||
|
||||
// Don't handle new ids / base meta since it's not used for this version
|
||||
|
||||
// Rewrite Metadata
|
||||
wrapper.set(
|
||||
Types1_13.METADATA_LIST,
|
||||
0,
|
||||
storage.getMetaDataList()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.out(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
map(Type.DOUBLE); // 3 - Y
|
||||
map(Type.DOUBLE); // 4 - Z
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_13.METADATA_LIST); // 7 - Metadata
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
EntityType.PLAYER
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Rewrite Metadata
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(
|
||||
Types1_13.METADATA_LIST,
|
||||
0,
|
||||
handleMeta(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0))
|
||||
).getMetaDataList()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Spawn Painting
|
||||
protocol.out(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
EntityType.PAINTING
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Join Game
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.INT, 0),
|
||||
EntityType1_12.EntityType.PLAYER
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Save dimension
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Respawn
|
||||
protocol.out(State.PLAY, 0x38, 0x38, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID\
|
||||
|
||||
// Save dimension
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 0);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
protocol.out(State.PLAY, 0x35, 0x35, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||
getEntityTracker(wrapper.user()).removeEntity(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Metadata packet
|
||||
protocol.out(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_13.METADATA_LIST); // 1 - Metadata list
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(
|
||||
Types1_13.METADATA_LIST,
|
||||
0,
|
||||
handleMeta(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0))
|
||||
).getMetaDataList()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
||||
// Rewrite items & blocks
|
||||
registerMetaHandler().handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
|
||||
if (meta.getMetaType() == MetaType1_13.Slot) {
|
||||
InventoryPackets1_13_1.toClient((Item) meta.getValue());
|
||||
} else if (meta.getMetaType() == MetaType1_13.BlockID) {
|
||||
// Convert to new block id
|
||||
int data = (int) meta.getValue();
|
||||
meta.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
|
||||
return meta;
|
||||
});
|
||||
|
||||
// Remove shooter UUID
|
||||
registerMetaHandler().
|
||||
filter(EntityType.ABSTRACT_ARROW, true, 7)
|
||||
.removed();
|
||||
|
||||
// Move colors to old position
|
||||
registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8)
|
||||
.handleIndexChange(7);
|
||||
|
||||
// Move loyalty level to old position
|
||||
registerMetaHandler().filter(EntityType.TRIDENT, 8)
|
||||
.handleIndexChange(7);
|
||||
|
||||
// Rewrite Minecart blocks
|
||||
registerMetaHandler()
|
||||
.filter(EntityType.MINECART_ABSTRACT, true, 9)
|
||||
.handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
|
||||
int data = (int) meta.getValue();
|
||||
meta.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
|
||||
return meta;
|
||||
});
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class InventoryPackets {
|
||||
public class InventoryPackets1_13_1 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
|
@ -13,7 +13,7 @@ import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class WorldPackets {
|
||||
public class WorldPackets1_13_1 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
//Chunk
|
||||
@ -109,7 +109,7 @@ public class WorldPackets {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
wrapper.set(Type.INT, 1, data = InventoryPackets.getNewItemId(data));
|
||||
wrapper.set(Type.INT, 1, data = InventoryPackets1_13_1.getNewItemId(data));
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
wrapper.set(Type.INT, 1, data = Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
@ -118,42 +118,6 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
//join game
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Store the player
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//respawn
|
||||
protocol.registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 0);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//spawn particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
@ -176,7 +140,7 @@ public class WorldPackets {
|
||||
int data = wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.set(Type.VAR_INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
} else if (id == 27) {
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM));
|
||||
InventoryPackets1_13_1.toClient(wrapper.passthrough(Type.FLAT_ITEM));
|
||||
}
|
||||
}
|
||||
});
|
1
pom.xml
1
pom.xml
@ -28,6 +28,7 @@
|
||||
<module>bukkit</module>
|
||||
<module>bungee</module>
|
||||
<module>sponge</module>
|
||||
<module>velocity</module>
|
||||
<module>all</module>
|
||||
</modules>
|
||||
|
||||
|
@ -11,14 +11,14 @@
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import nl.matsv.viabackwards.sponge.VersionInfo;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.Order;
|
||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||
import org.spongepowered.api.plugin.Dependency;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
@ -31,26 +31,21 @@ import java.util.logging.Logger;
|
||||
dependencies = {@Dependency(id = "viaversion")}
|
||||
)
|
||||
public class SpongePlugin implements ViaBackwardsPlatform {
|
||||
@Getter
|
||||
private Logger logger;
|
||||
@Inject
|
||||
private PluginContainer container;
|
||||
private org.slf4j.Logger loggerSlf4j;
|
||||
|
||||
@Listener(order = Order.LATE)
|
||||
public void onServerStart(GameAboutToStartServerEvent e) {
|
||||
public void onGameStart(GameInitializationEvent e) {
|
||||
// Setup Logger
|
||||
this.logger = new LoggerWrapper(container.getLogger());
|
||||
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||
// Init!
|
||||
this.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
// TODO check how to for sponge, site was offline
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
// Not possible
|
||||
}
|
||||
}
|
||||
|
83
velocity/pom.xml
Normale Datei
83
velocity/pom.xml
Normale Datei
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016 Matsv
|
||||
~
|
||||
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
~
|
||||
~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
~
|
||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>2.4.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>viabackwards-velocity</artifactId>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<!-- Stolen from ViaVersion ;) -->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>templating-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>filter-src</id>
|
||||
<goals>
|
||||
<goal>filter-sources</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>velocity-maven-repo</id>
|
||||
<name>Velocity maven repo</name>
|
||||
<url>https://repo.velocitypowered.com/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- Common Module -->
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Velocity API -->
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.velocity;
|
||||
|
||||
public class VersionInfo {
|
||||
public static final String VERSION = "${project.version}";
|
||||
}
|
51
velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java
Normale Datei
51
velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java
Normale Datei
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import lombok.Getter;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import nl.matsv.viabackwards.velocity.VersionInfo;
|
||||
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Plugin(id = "viabackwards",
|
||||
name = "ViaBackwards",
|
||||
version = VersionInfo.VERSION,
|
||||
authors = {"Matsv"},
|
||||
description = "Allow older Minecraft versions to connect to an newer server version.",
|
||||
dependencies = {@Dependency(id = "viaversion")}
|
||||
)
|
||||
public class VelocityPlugin implements ViaBackwardsPlatform {
|
||||
@Getter
|
||||
private Logger logger;
|
||||
@Inject
|
||||
private org.slf4j.Logger loggerSlf4j;
|
||||
|
||||
@Subscribe(order = PostOrder.LATE)
|
||||
public void onProxyStart(ProxyInitializeEvent e) {
|
||||
// Setup Logger
|
||||
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||
// Init!
|
||||
this.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
// Not possible
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren