mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-21 12:07:38 +01:00
Start working on 5.0.0
This commit is contained in:
parent
abb1803aaf
commit
5e7371d39b
@ -21,7 +21,7 @@ tasks {
|
||||
}
|
||||
|
||||
java {
|
||||
javaTarget(8)
|
||||
javaTarget(17)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "4.10.2";
|
||||
String MINIMUM_VV_VERSION = "5.0.0";
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
|
@ -41,12 +41,12 @@ public class EntityPositionHandler {
|
||||
this.storageSupplier = storageSupplier;
|
||||
}
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, boolean create, boolean relative) throws Exception {
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, boolean create, boolean relative) {
|
||||
cacheEntityPosition(wrapper,
|
||||
wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), create, relative);
|
||||
}
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) throws Exception {
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
StoredEntityData storedEntity = entityRewriter.tracker(wrapper.user()).entityData(entityId);
|
||||
if (storedEntity == null) {
|
||||
|
@ -22,15 +22,15 @@ public abstract class EntityPositionStorage {
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
public double getX() {
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
@ -29,15 +29,15 @@ public abstract class PlayerPositionStorage implements StorableObject {
|
||||
protected PlayerPositionStorage() {
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public abstract class PlayerPositionStorage implements StorableObject {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setCoordinates(PacketWrapper wrapper, boolean relative) throws Exception {
|
||||
public void setCoordinates(PacketWrapper wrapper, boolean relative) {
|
||||
setCoordinates(wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), relative);
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class WrappedMetadata {
|
||||
private final List<Metadata> metadataList;
|
||||
|
||||
public WrappedMetadata(List<Metadata> metadataList) {
|
||||
this.metadataList = metadataList;
|
||||
}
|
||||
public record WrappedMetadata(List<Metadata> metadataList) {
|
||||
|
||||
public boolean has(Metadata data) {
|
||||
return this.metadataList.contains(data);
|
||||
@ -53,13 +48,4 @@ public final class WrappedMetadata {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Metadata> metadataList() {
|
||||
return metadataList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MetaStorage{" + "metaDataList=" + metadataList + '}';
|
||||
}
|
||||
}
|
||||
|
@ -146,29 +146,18 @@ public class EnchantmentRewriter {
|
||||
}
|
||||
|
||||
public static String getRomanNumber(int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return "I";
|
||||
case 2:
|
||||
return "II";
|
||||
case 3:
|
||||
return "III";
|
||||
case 4:
|
||||
return "IV";
|
||||
case 5:
|
||||
return "V";
|
||||
case 6:
|
||||
return "VI";
|
||||
case 7:
|
||||
return "VII";
|
||||
case 8:
|
||||
return "VIII";
|
||||
case 9:
|
||||
return "IX";
|
||||
case 10:
|
||||
return "X";
|
||||
default:
|
||||
return Integer.toString(number);
|
||||
}
|
||||
return switch (number) {
|
||||
case 1 -> "I";
|
||||
case 2 -> "II";
|
||||
case 3 -> "III";
|
||||
case 4 -> "IV";
|
||||
case 5 -> "V";
|
||||
case 6 -> "VI";
|
||||
case 7 -> "VII";
|
||||
case 8 -> "VIII";
|
||||
case 9 -> "IX";
|
||||
case 10 -> "X";
|
||||
default -> Integer.toString(number);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
* @param wrapper packet wrapper
|
||||
* @return unmapped (!) entity type
|
||||
*/
|
||||
protected EntityType trackAndMapEntity(PacketWrapper wrapper) throws Exception {
|
||||
protected EntityType trackAndMapEntity(PacketWrapper wrapper) {
|
||||
int typeId = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = typeFromId(typeId);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
|
@ -279,12 +279,12 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
tags.put(pos, tag);
|
||||
|
||||
// Handle given Block Entities
|
||||
if (pos.getY() < 0 || pos.getY() > 255) continue; // 1.17
|
||||
if (pos.y() < 0 || pos.y() > 255) continue; // 1.17
|
||||
|
||||
ChunkSection section = chunk.getSections()[pos.getY() >> 4];
|
||||
ChunkSection section = chunk.getSections()[pos.y() >> 4];
|
||||
if (section == null) continue;
|
||||
|
||||
int block = section.palette(PaletteType.BLOCKS).idAt(pos.getX(), pos.getY() & 0xF, pos.getZ());
|
||||
int block = section.palette(PaletteType.BLOCKS).idAt(pos.x(), pos.y() & 0xF, pos.z());
|
||||
|
||||
MappedLegacyBlockItem settings = getMappedBlock(block);
|
||||
if (settings != null && settings.hasBlockEntityHandler()) {
|
||||
@ -379,51 +379,10 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
return BackwardsMappingDataLoader.INSTANCE.loadFromDataDir(name);
|
||||
}
|
||||
|
||||
private static final class Pos {
|
||||
private record Pos(int x, short y, int z) {
|
||||
|
||||
private final int x;
|
||||
private final short y;
|
||||
private final int z;
|
||||
|
||||
private Pos(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = (short) y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Pos pos = (Pos) o;
|
||||
if (x != pos.x) return false;
|
||||
if (y != pos.y) return false;
|
||||
return z == pos.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + y;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pos{" + "x=" + x + ", y=" + y + ", z=" + z + '}';
|
||||
public Pos( int x, int y, int z){
|
||||
this(x, (short) y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,8 +155,8 @@ public class LegacyEnchantmentRewriter {
|
||||
}
|
||||
|
||||
Tag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
|
||||
if (hideFlags instanceof IntTag) {
|
||||
tag.putInt("HideFlags", ((IntTag) hideFlags).asByte());
|
||||
if (hideFlags instanceof IntTag intTag) {
|
||||
tag.putInt("HideFlags", intTag.asByte());
|
||||
} else {
|
||||
tag.remove("HideFlags");
|
||||
}
|
||||
|
@ -170,13 +170,13 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception {
|
||||
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) {
|
||||
tracker(wrapper.user()).addEntity(entityId, type);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
protected interface IdSetter {
|
||||
|
||||
void setId(PacketWrapper wrapper, int id) throws Exception;
|
||||
void setId(PacketWrapper wrapper, int id);
|
||||
}
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ public abstract class LegacySoundRewriter<T extends BackwardsProtocol<?, ?, ?, ?
|
||||
public int handleSounds(int soundId) {
|
||||
int newSoundId = soundId;
|
||||
SoundData data = soundRewrites.get(soundId);
|
||||
if (data != null) return data.getReplacementSound();
|
||||
if (data != null) return data.replacementSound();
|
||||
|
||||
for (Int2ObjectMap.Entry<SoundData> entry : soundRewrites.int2ObjectEntrySet()) {
|
||||
if (soundId > entry.getIntKey()) {
|
||||
if (entry.getValue().isAdded()) {
|
||||
if (entry.getValue().added()) {
|
||||
newSoundId--;
|
||||
} else {
|
||||
newSoundId++;
|
||||
@ -66,41 +66,14 @@ public abstract class LegacySoundRewriter<T extends BackwardsProtocol<?, ?, ?, ?
|
||||
|
||||
public boolean hasPitch(int soundId) {
|
||||
SoundData data = soundRewrites.get(soundId);
|
||||
return data != null && data.isChangePitch();
|
||||
return data != null && data.changePitch();
|
||||
}
|
||||
|
||||
public float handlePitch(int soundId) {
|
||||
SoundData data = soundRewrites.get(soundId);
|
||||
return data != null ? data.getNewPitch() : 1F;
|
||||
return data != null ? data.newPitch() : 1F;
|
||||
}
|
||||
|
||||
public static final class SoundData {
|
||||
private final int replacementSound;
|
||||
private final boolean changePitch;
|
||||
private final float newPitch;
|
||||
private final boolean added;
|
||||
|
||||
public SoundData(int replacementSound, boolean changePitch, float newPitch, boolean added) {
|
||||
this.replacementSound = replacementSound;
|
||||
this.changePitch = changePitch;
|
||||
this.newPitch = newPitch;
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
public int getReplacementSound() {
|
||||
return replacementSound;
|
||||
}
|
||||
|
||||
public boolean isChangePitch() {
|
||||
return changePitch;
|
||||
}
|
||||
|
||||
public float getNewPitch() {
|
||||
return newPitch;
|
||||
}
|
||||
|
||||
public boolean isAdded() {
|
||||
return added;
|
||||
}
|
||||
public record SoundData(int replacementSound, boolean changePitch, float newPitch, boolean added) {
|
||||
}
|
||||
}
|
||||
|
@ -70,8 +70,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
handler(wrapper -> {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
if (horse.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
int currentSlot = wrapper.get(Type.SHORT, 0);
|
||||
wrapper.set(Type.SHORT, 0, ((Integer) (currentSlot = getNewSlotId(storage, currentSlot))).shortValue());
|
||||
@ -94,8 +96,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
if (horse.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
stacks = Arrays.copyOf(stacks, !storage.isChested() ? 38 : 53);
|
||||
|
||||
@ -156,8 +159,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
handler(wrapper -> {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
if (horse.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
int clickSlot = wrapper.get(Type.SHORT, 0);
|
||||
int correctSlot = getOldSlotId(storage, clickSlot);
|
||||
|
@ -221,20 +221,14 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
*/
|
||||
filter().type(EntityTypes1_11.EntityType.ZOMBIE).handler((event, meta) -> {
|
||||
switch (meta.id()) {
|
||||
case 13:
|
||||
event.cancel();
|
||||
return;
|
||||
case 14:
|
||||
event.setIndex(15);
|
||||
break;
|
||||
case 15:
|
||||
event.setIndex(14);
|
||||
break;
|
||||
// Profession
|
||||
case 16:
|
||||
case 13 -> event.cancel();
|
||||
case 14 -> event.setIndex(15);
|
||||
case 15 -> event.setIndex(14);
|
||||
case 16 -> {
|
||||
// Profession
|
||||
event.setIndex(13);
|
||||
meta.setValue(1 + (int) meta.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -297,18 +291,18 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
int index = event.index();
|
||||
// Store them for later (:
|
||||
switch (index) {
|
||||
case 16:
|
||||
case 16 -> {
|
||||
storage.setLiamaStrength((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
case 17:
|
||||
}
|
||||
case 17 -> {
|
||||
storage.setLiamaCarpetColor((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
case 18:
|
||||
}
|
||||
case 18 -> {
|
||||
storage.setLiamaVariant((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -30,9 +30,9 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPac
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
|
||||
public class PlayerPackets1_11 {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<>(Type.FLOAT) {
|
||||
@Override
|
||||
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
|
||||
public Float transform(PacketWrapper wrapper, Short inputValue) {
|
||||
return inputValue / 16f;
|
||||
}
|
||||
};
|
||||
|
@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ShoulderTracker extends StoredObject {
|
||||
private int entityId;
|
||||
@ -85,7 +86,7 @@ public class ShoulderTracker extends StoredObject {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (String s : array) {
|
||||
builder.append(s.substring(0, 1).toUpperCase())
|
||||
builder.append(s.substring(0, 1).toUpperCase(Locale.ROOT))
|
||||
.append(s.substring(1))
|
||||
.append(" ");
|
||||
}
|
||||
|
@ -220,12 +220,12 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
boolean hasLongArrayTag = false;
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Tag> entry = iterator.next();
|
||||
if (entry.getValue() instanceof CompoundTag) {
|
||||
if (entry.getValue() instanceof CompoundTag tag) {
|
||||
CompoundTag nestedBackupTag = new CompoundTag();
|
||||
backupTag.put(entry.getKey(), nestedBackupTag);
|
||||
hasLongArrayTag |= handleNbtToClient((CompoundTag) entry.getValue(), nestedBackupTag);
|
||||
} else if (entry.getValue() instanceof LongArrayTag) {
|
||||
backupTag.put(entry.getKey(), fromLongArrayTag((LongArrayTag) entry.getValue()));
|
||||
hasLongArrayTag |= handleNbtToClient(tag, nestedBackupTag);
|
||||
} else if (entry.getValue() instanceof LongArrayTag tag) {
|
||||
backupTag.put(entry.getKey(), fromLongArrayTag(tag));
|
||||
iterator.remove();
|
||||
hasLongArrayTag = true;
|
||||
}
|
||||
@ -239,9 +239,8 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
super.handleItemToServer(connection, item);
|
||||
|
||||
if (item.tag() != null) {
|
||||
Tag tag = item.tag().remove("Via|LongArrayTags");
|
||||
if (tag instanceof CompoundTag) {
|
||||
handleNbtToServer(item.tag(), (CompoundTag) tag);
|
||||
if (item.tag().remove("Via|LongArrayTags") instanceof CompoundTag tag) {
|
||||
handleNbtToServer(item.tag(), tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
|
||||
public class ChatPackets1_12 extends RewriterBase<Protocol1_11_1To1_12> {
|
||||
|
||||
public static final ComponentRewriter<ClientboundPackets1_12> COMPONENT_REWRITER = new ComponentRewriter<ClientboundPackets1_12>(null, ComponentRewriter.ReadType.JSON) {
|
||||
public static final ComponentRewriter<ClientboundPackets1_12> COMPONENT_REWRITER = new ComponentRewriter<>(null, ComponentRewriter.ReadType.JSON) {
|
||||
@Override
|
||||
public void processText(UserConnection connection, JsonElement element) {
|
||||
super.processText(connection, element);
|
||||
|
@ -54,7 +54,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
|
||||
private final EntityPackets1_13 entityRewriter = new EntityPackets1_13(this);
|
||||
private final BlockItemPackets1_13 blockItemPackets = new BlockItemPackets1_13(this);
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this, ComponentRewriter.ReadType.JSON) {
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String mappedKey = mappedTranslationKey(translate);
|
||||
@ -63,7 +63,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
}
|
||||
};
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableToLegacyRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this, ComponentRewriter.ReadType.JSON) {
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableToLegacyRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String mappedKey = mappedTranslationKey(translate);
|
||||
|
@ -64,18 +64,11 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
|
||||
int mappedId = super.getNewBlockStateId(id);
|
||||
|
||||
// https://github.com/ViaVersion/ViaBackwards/issues/290
|
||||
switch (mappedId) {
|
||||
case 1595:
|
||||
case 1596:
|
||||
case 1597:
|
||||
return 1584; // brown mushroom block
|
||||
case 1611:
|
||||
case 1612:
|
||||
case 1613:
|
||||
return 1600; // red mushroom block
|
||||
default:
|
||||
return mappedId;
|
||||
}
|
||||
return switch (mappedId) {
|
||||
case 1595, 1596, 1597 -> 1584; // brown mushroom block
|
||||
case 1611, 1612, 1613 -> 1600; // red mushroom block
|
||||
default -> mappedId;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,22 +20,14 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class EntityTypeMapping {
|
||||
private static final Int2IntMap TYPES = new Int2IntOpenHashMap();
|
||||
|
||||
static {
|
||||
TYPES.defaultReturnValue(-1);
|
||||
try {
|
||||
Field field = EntityTypeRewriter.class.getDeclaredField("ENTITY_TYPES");
|
||||
field.setAccessible(true);
|
||||
Int2IntMap entityTypes = (Int2IntMap) field.get(null);
|
||||
for (Int2IntMap.Entry entry : entityTypes.int2IntEntrySet()) {
|
||||
EntityTypeMapping.TYPES.put(entry.getIntValue(), entry.getIntKey());
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
for (Int2IntMap.Entry entry : EntityTypeRewriter.getEntityTypes().int2IntEntrySet()) {
|
||||
EntityTypeMapping.TYPES.put(entry.getIntValue(), entry.getIntKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ParticleMapping {
|
||||
private static final ParticleData[] particles;
|
||||
@ -31,7 +32,7 @@ public class ParticleMapping {
|
||||
static {
|
||||
ParticleHandler blockHandler = new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) {
|
||||
return rewrite(wrapper.read(Type.VAR_INT));
|
||||
}
|
||||
|
||||
@ -63,13 +64,13 @@ public class ParticleMapping {
|
||||
rewrite(4), // (4->4) minecraft:bubble -> bubble
|
||||
rewrite(29), // (5->29) minecraft:cloud -> cloud
|
||||
rewrite(9), // (6->9) minecraft:crit -> crit
|
||||
rewrite(44), // (7->44) minecraft:damage_indicator -> damageIndicator
|
||||
rewrite(44), // (7->44) minecraft:damage_indicator -> damageIndicator
|
||||
rewrite(42), // (8->42) minecraft:dragon_breath -> dragonbreath
|
||||
rewrite(19), // (9->19) minecraft:dripping_lava -> dripLava
|
||||
rewrite(18), // (10->18) minecraft:dripping_water -> dripWater
|
||||
rewrite(30, new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) {
|
||||
float r = wrapper.read(Type.FLOAT);
|
||||
float g = wrapper.read(Type.FLOAT);
|
||||
float b = wrapper.read(Type.FLOAT);
|
||||
@ -107,7 +108,7 @@ public class ParticleMapping {
|
||||
rewrite(14), // (26->14) minecraft:instant_effect -> instantSpell
|
||||
rewrite(36, new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) {
|
||||
return rewrite(protocol, wrapper.read(Type.ITEM1_13));
|
||||
}
|
||||
|
||||
@ -160,7 +161,7 @@ public class ParticleMapping {
|
||||
|
||||
public interface ParticleHandler {
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception;
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper);
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData<?>> data);
|
||||
|
||||
@ -182,12 +183,12 @@ public class ParticleMapping {
|
||||
this(historyId, null);
|
||||
}
|
||||
|
||||
public int[] rewriteData(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
public int @Nullable [] rewriteData(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) {
|
||||
if (handler == null) return null;
|
||||
return handler.rewrite(protocol, wrapper);
|
||||
}
|
||||
|
||||
public int[] rewriteMeta(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData<?>> data) {
|
||||
public int @Nullable [] rewriteMeta(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData<?>> data) {
|
||||
if (handler == null) return null;
|
||||
return handler.rewrite(protocol, data);
|
||||
}
|
||||
|
@ -358,28 +358,13 @@ public class BlockItemPackets1_13 extends BackwardsItemRewriter<ClientboundPacke
|
||||
if (chunk.isBiomeData()) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
int biome = chunk.getBiomeData()[i];
|
||||
int newId = -1;
|
||||
switch (biome) {
|
||||
case 40: // end biomes
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
newId = 9;
|
||||
break;
|
||||
case 47: // deep ocean biomes
|
||||
case 48:
|
||||
case 49:
|
||||
newId = 24;
|
||||
break;
|
||||
case 50: // deep frozen... let's just pick the frozen variant
|
||||
newId = 10;
|
||||
break;
|
||||
case 44: // the other new ocean biomes
|
||||
case 45:
|
||||
case 46:
|
||||
newId = 0;
|
||||
break;
|
||||
}
|
||||
int newId = switch (biome) {
|
||||
case 40, 41, 42, 43 -> 9; // end biomes
|
||||
case 47, 48, 49 -> 24; // deep ocean biomes
|
||||
case 50 -> 10; // deep frozen... let's just pick the frozen variant
|
||||
case 44, 45, 46 -> 0; // the other new ocean biomes
|
||||
default -> -1;
|
||||
};
|
||||
|
||||
if (newId != -1) {
|
||||
chunk.getBiomeData()[i] = newId;
|
||||
@ -978,7 +963,7 @@ public class BlockItemPackets1_13 extends BackwardsItemRewriter<ClientboundPacke
|
||||
}
|
||||
|
||||
// TODO find a less hacky way to do this (https://bugs.mojang.com/browse/MC-74231)
|
||||
private static void flowerPotSpecialTreatment(UserConnection user, int blockState, Position position) throws Exception {
|
||||
private static void flowerPotSpecialTreatment(UserConnection user, int blockState, Position position) {
|
||||
if (FlowerPotHandler.isFlowah(blockState)) {
|
||||
BackwardsBlockEntityProvider beProvider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
||||
|
||||
|
@ -66,9 +66,9 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
PlayerPositionStorage1_13 playerStorage = wrapper.user().get(PlayerPositionStorage1_13.class);
|
||||
byte bitField = wrapper.get(Type.BYTE, 0);
|
||||
playerStorage.setX(toSet(bitField, 0, playerStorage.getX(), wrapper.get(Type.DOUBLE, 0)));
|
||||
playerStorage.setY(toSet(bitField, 1, playerStorage.getY(), wrapper.get(Type.DOUBLE, 1)));
|
||||
playerStorage.setZ(toSet(bitField, 2, playerStorage.getZ(), wrapper.get(Type.DOUBLE, 2)));
|
||||
playerStorage.setX(toSet(bitField, 0, playerStorage.x(), wrapper.get(Type.DOUBLE, 0)));
|
||||
playerStorage.setY(toSet(bitField, 1, playerStorage.y(), wrapper.get(Type.DOUBLE, 1)));
|
||||
playerStorage.setZ(toSet(bitField, 2, playerStorage.z(), wrapper.get(Type.DOUBLE, 2)));
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -90,7 +90,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
handler(wrapper -> {
|
||||
Optional<EntityTypes1_13.ObjectType> optionalType = EntityTypes1_13.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (!optionalType.isPresent()) return;
|
||||
if (optionalType.isEmpty()) return;
|
||||
|
||||
EntityTypes1_13.ObjectType type = optionalType.get();
|
||||
if (type == EntityTypes1_13.ObjectType.FALLING_BLOCK) {
|
||||
@ -100,17 +100,12 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
wrapper.set(Type.INT, 0, combined);
|
||||
} else if (type == EntityTypes1_13.ObjectType.ITEM_FRAME) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
switch (data) {
|
||||
case 3:
|
||||
data = 0;
|
||||
break;
|
||||
case 4:
|
||||
data = 1;
|
||||
break;
|
||||
case 5:
|
||||
data = 3;
|
||||
break;
|
||||
}
|
||||
data = switch (data) {
|
||||
case 3 -> 0;
|
||||
case 4 -> 1;
|
||||
case 5 -> 3;
|
||||
default -> data;
|
||||
};
|
||||
wrapper.set(Type.INT, 0, data);
|
||||
} else if (type == EntityTypes1_13.ObjectType.TRIDENT) {
|
||||
wrapper.set(Type.BYTE, 0, (byte) EntityTypes1_13.ObjectType.TIPPED_ARROW.getId());
|
||||
@ -230,9 +225,9 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
positionAndLook.write(Type.DOUBLE, 0D);
|
||||
|
||||
//TODO properly cache and calculate head position?
|
||||
EntityPositionHandler.writeFacingDegrees(positionAndLook, positionStorage.getX(),
|
||||
anchor == 1 ? positionStorage.getY() + 1.62 : positionStorage.getY(),
|
||||
positionStorage.getZ(), x, y, z);
|
||||
EntityPositionHandler.writeFacingDegrees(positionAndLook, positionStorage.x(),
|
||||
anchor == 1 ? positionStorage.y() + 1.62 : positionStorage.y(),
|
||||
positionStorage.z(), x, y, z);
|
||||
|
||||
positionAndLook.write(Type.BYTE, (byte) 7); // bitfield, 0=absolute, 1=relative - x,y,z relative, yaw,pitch absolute
|
||||
positionAndLook.write(Type.VAR_INT, -1);
|
||||
|
@ -377,18 +377,15 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.PLUGIN_MESSAGE, wrapper -> {
|
||||
String channel = wrapper.read(Type.STRING);
|
||||
switch (channel) {
|
||||
case "MC|BSign":
|
||||
case "MC|BEdit":
|
||||
case "MC|BSign", "MC|BEdit" -> {
|
||||
wrapper.setPacketType(ServerboundPackets1_13.EDIT_BOOK);
|
||||
Item book = wrapper.read(Type.ITEM1_8);
|
||||
wrapper.write(Type.ITEM1_13, protocol.getItemRewriter().handleItemToServer(wrapper.user(), book));
|
||||
boolean signing = channel.equals("MC|BSign");
|
||||
wrapper.write(Type.BOOLEAN, signing);
|
||||
break;
|
||||
case "MC|ItemName":
|
||||
wrapper.setPacketType(ServerboundPackets1_13.RENAME_ITEM);
|
||||
break;
|
||||
case "MC|AdvCmd":
|
||||
}
|
||||
case "MC|ItemName" -> wrapper.setPacketType(ServerboundPackets1_13.RENAME_ITEM);
|
||||
case "MC|AdvCmd" -> {
|
||||
byte type = wrapper.read(Type.BYTE);
|
||||
if (type == 0) {
|
||||
//Information from https://wiki.vg/index.php?title=Plugin_channels&oldid=14089
|
||||
@ -406,8 +403,8 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
break;
|
||||
case "MC|AutoCmd": {
|
||||
}
|
||||
case "MC|AutoCmd" -> {
|
||||
wrapper.setPacketType(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK);
|
||||
|
||||
int x = wrapper.read(Type.INT);
|
||||
@ -430,9 +427,8 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x04; //Automatic
|
||||
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
break;
|
||||
}
|
||||
case "MC|Struct": {
|
||||
case "MC|Struct" -> {
|
||||
wrapper.setPacketType(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK);
|
||||
int x = wrapper.read(Type.INT);
|
||||
int y = wrapper.read(Type.INT);
|
||||
@ -471,24 +467,18 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.passthrough(Type.VAR_LONG); //Seed
|
||||
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
break;
|
||||
}
|
||||
case "MC|Beacon":
|
||||
case "MC|Beacon" -> {
|
||||
wrapper.setPacketType(ServerboundPackets1_13.SET_BEACON_EFFECT);
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Primary Effect
|
||||
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Secondary Effect
|
||||
|
||||
break;
|
||||
case "MC|TrSel":
|
||||
}
|
||||
case "MC|TrSel" -> {
|
||||
wrapper.setPacketType(ServerboundPackets1_13.SELECT_TRADE);
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Slot
|
||||
|
||||
break;
|
||||
case "MC|PickItem":
|
||||
wrapper.setPacketType(ServerboundPackets1_13.PICK_ITEM);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
case "MC|PickItem" -> wrapper.setPacketType(ServerboundPackets1_13.PICK_ITEM);
|
||||
default -> {
|
||||
String newChannel = InventoryPackets.getNewPluginChannelId(channel);
|
||||
if (newChannel == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
@ -514,10 +504,9 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -535,25 +524,19 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
String name = "";
|
||||
// categories 0-7 (items, blocks, entities) - probably not feasible
|
||||
switch (categoryId) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 0, 1, 2, 3, 4, 5, 6, 7 -> {
|
||||
wrapper.read(Type.VAR_INT); // remove value
|
||||
newSize--;
|
||||
continue;
|
||||
case 8:
|
||||
}
|
||||
case 8 -> {
|
||||
name = protocol.getMappingData().getStatisticMappings().get(statisticId);
|
||||
if (name == null) {
|
||||
wrapper.read(Type.VAR_INT);
|
||||
newSize--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, name); // string id
|
||||
|
@ -62,7 +62,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
* @param position The position of the block entity
|
||||
* @param tag The block entity tag
|
||||
*/
|
||||
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) throws Exception {
|
||||
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) {
|
||||
final StringTag idTag = tag.getStringTag("id");
|
||||
if (idTag == null) {
|
||||
return tag;
|
||||
@ -90,7 +90,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
* @param position The position of the block entity
|
||||
* @param id The block entity id
|
||||
*/
|
||||
public CompoundTag transform(UserConnection user, Position position, String id) throws Exception {
|
||||
public CompoundTag transform(UserConnection user, Position position, String id) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putString("id", id);
|
||||
tag.putInt("x", Math.toIntExact(position.x()));
|
||||
|
@ -28,9 +28,7 @@ public class CommandRewriter1_14 extends CommandRewriter<ClientboundPackets1_14>
|
||||
public CommandRewriter1_14(Protocol1_13_2To1_14 protocol) {
|
||||
super(protocol);
|
||||
|
||||
this.parserHandlers.put("minecraft:nbt_tag", wrapper -> {
|
||||
wrapper.write(Type.VAR_INT, 2); // Greedy phrase
|
||||
});
|
||||
this.parserHandlers.put("minecraft:nbt_tag", wrapper -> wrapper.write(Type.VAR_INT, 2)); // Greedy phrase
|
||||
this.parserHandlers.put("minecraft:time", wrapper -> {
|
||||
wrapper.write(Type.BYTE, (byte) (0x01)); // Flags
|
||||
wrapper.write(Type.INT, 0); // Min value
|
||||
@ -39,15 +37,12 @@ public class CommandRewriter1_14 extends CommandRewriter<ClientboundPackets1_14>
|
||||
|
||||
@Override
|
||||
public @Nullable String handleArgumentType(String argumentType) {
|
||||
switch (argumentType) {
|
||||
case "minecraft:nbt_compound_tag":
|
||||
return "minecraft:nbt";
|
||||
case "minecraft:nbt_tag":
|
||||
return "brigadier:string";
|
||||
case "minecraft:time":
|
||||
return "brigadier:integer";
|
||||
}
|
||||
return super.handleArgumentType(argumentType);
|
||||
return switch (argumentType) {
|
||||
case "minecraft:nbt_compound_tag" -> "minecraft:nbt";
|
||||
case "minecraft:nbt_tag" -> "brigadier:string";
|
||||
case "minecraft:time" -> "brigadier:integer";
|
||||
default -> super.handleArgumentType(argumentType);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -86,50 +86,40 @@ public class BlockItemPackets1_14 extends BackwardsItemRewriter<ClientboundPacke
|
||||
slotSize = (type + 1) * 9;
|
||||
} else {
|
||||
switch (type) {
|
||||
case 11:
|
||||
stringType = "minecraft:crafting_table";
|
||||
break;
|
||||
case 9: //blast furnace
|
||||
case 20: //smoker
|
||||
case 13: //furnace
|
||||
case 14: //grindstone
|
||||
case 11 -> stringType = "minecraft:crafting_table";
|
||||
case 9, 20, 13, 14 -> {
|
||||
if (type == 9) containerTitle = "Blast Furnace";
|
||||
else if (type == 20) containerTitle = "Smoker";
|
||||
else if (type == 14) containerTitle = "Grindstone";
|
||||
stringType = "minecraft:furnace";
|
||||
slotSize = 3;
|
||||
break;
|
||||
case 6:
|
||||
}
|
||||
case 6 -> {
|
||||
stringType = "minecraft:dropper";
|
||||
slotSize = 9;
|
||||
break;
|
||||
case 12:
|
||||
stringType = "minecraft:enchanting_table";
|
||||
break;
|
||||
case 10:
|
||||
}
|
||||
case 12 -> stringType = "minecraft:enchanting_table";
|
||||
case 10 -> {
|
||||
stringType = "minecraft:brewing_stand";
|
||||
slotSize = 5;
|
||||
break;
|
||||
case 18:
|
||||
stringType = "minecraft:villager";
|
||||
break;
|
||||
case 8:
|
||||
}
|
||||
case 18 -> stringType = "minecraft:villager";
|
||||
case 8 -> {
|
||||
stringType = "minecraft:beacon";
|
||||
slotSize = 1;
|
||||
break;
|
||||
case 21: //cartography_table
|
||||
case 7:
|
||||
}
|
||||
case 21, 7 -> {
|
||||
if (type == 21) containerTitle = "Cartography Table";
|
||||
stringType = "minecraft:anvil";
|
||||
break;
|
||||
case 15:
|
||||
}
|
||||
case 15 -> {
|
||||
stringType = "minecraft:hopper";
|
||||
slotSize = 5;
|
||||
break;
|
||||
case 19:
|
||||
}
|
||||
case 19 -> {
|
||||
stringType = "minecraft:shulker_box";
|
||||
slotSize = 27;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,20 +256,18 @@ public class BlockItemPackets1_14 extends BackwardsItemRewriter<ClientboundPacke
|
||||
type = Key.stripMinecraftNamespace(type);
|
||||
if (removedTypes.contains(type)) {
|
||||
switch (type) {
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
case "blasting", "smoking", "campfire_cooking" -> {
|
||||
wrapper.read(Type.STRING); // Group
|
||||
wrapper.read(Type.ITEM1_13_2_ARRAY); // Ingredients
|
||||
wrapper.read(Type.ITEM1_13_2);
|
||||
wrapper.read(Type.FLOAT); // EXP
|
||||
wrapper.read(Type.VAR_INT); // Cooking time
|
||||
break;
|
||||
case "stonecutting":
|
||||
}
|
||||
case "stonecutting" -> {
|
||||
wrapper.read(Type.STRING); // Group?
|
||||
wrapper.read(Type.ITEM1_13_2_ARRAY); // Ingredients
|
||||
wrapper.read(Type.ITEM1_13_2); // Result
|
||||
break;
|
||||
}
|
||||
}
|
||||
deleted++;
|
||||
continue;
|
||||
|
@ -53,7 +53,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
//TODO work the method into this class alone
|
||||
@Override
|
||||
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception {
|
||||
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) {
|
||||
super.addTrackedEntity(wrapper, entityId, type);
|
||||
|
||||
// Cache the position for every newly tracked entity
|
||||
@ -143,27 +143,15 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
EntityTypes1_13.ObjectType objectType;
|
||||
if (entityType.isOrHasParent(EntityTypes1_13.EntityType.MINECART_ABSTRACT)) {
|
||||
objectType = EntityTypes1_13.ObjectType.MINECART;
|
||||
int data = 0;
|
||||
switch (entityType) {
|
||||
case CHEST_MINECART:
|
||||
data = 1;
|
||||
break;
|
||||
case FURNACE_MINECART:
|
||||
data = 2;
|
||||
break;
|
||||
case TNT_MINECART:
|
||||
data = 3;
|
||||
break;
|
||||
case SPAWNER_MINECART:
|
||||
data = 4;
|
||||
break;
|
||||
case HOPPER_MINECART:
|
||||
data = 5;
|
||||
break;
|
||||
case COMMAND_BLOCK_MINECART:
|
||||
data = 6;
|
||||
break;
|
||||
}
|
||||
int data = switch (entityType) {
|
||||
case CHEST_MINECART -> 1;
|
||||
case FURNACE_MINECART -> 2;
|
||||
case TNT_MINECART -> 3;
|
||||
case SPAWNER_MINECART -> 4;
|
||||
case HOPPER_MINECART -> 5;
|
||||
case COMMAND_BLOCK_MINECART -> 6;
|
||||
default -> 0;
|
||||
};
|
||||
if (data != 0)
|
||||
wrapper.set(Type.INT, 0, data);
|
||||
} else {
|
||||
|
@ -61,9 +61,9 @@ public class SoundPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
|
||||
float volume = wrapper.read(Type.FLOAT);
|
||||
float pitch = wrapper.read(Type.FLOAT);
|
||||
int x = (int) (entityStorage.getX() * 8D);
|
||||
int y = (int) (entityStorage.getY() * 8D);
|
||||
int z = (int) (entityStorage.getZ() * 8D);
|
||||
int x = (int) (entityStorage.x() * 8D);
|
||||
int y = (int) (entityStorage.y() * 8D);
|
||||
int z = (int) (entityStorage.z() * 8D);
|
||||
|
||||
PacketWrapper soundPacket = wrapper.create(ClientboundPackets1_13.SOUND);
|
||||
soundPacket.write(Type.VAR_INT, newId);
|
||||
|
@ -71,21 +71,22 @@ public class ChunkLightStorage implements StorableObject {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
public static class ChunkLight {
|
||||
private final byte[][] skyLight;
|
||||
private final byte[][] blockLight;
|
||||
public record ChunkLight(byte[][] skyLight, byte[][] blockLight) {
|
||||
|
||||
public ChunkLight(byte[][] skyLight, byte[][] blockLight) {
|
||||
this.skyLight = skyLight;
|
||||
this.blockLight = blockLight;
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final ChunkLight that = (ChunkLight) o;
|
||||
if (!Arrays.deepEquals(skyLight, that.skyLight)) return false;
|
||||
return Arrays.deepEquals(blockLight, that.blockLight);
|
||||
}
|
||||
|
||||
public byte[][] skyLight() {
|
||||
return skyLight;
|
||||
}
|
||||
|
||||
public byte[][] blockLight() {
|
||||
return blockLight;
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Arrays.deepHashCode(skyLight);
|
||||
result = 31 * result + Arrays.deepHashCode(blockLight);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
|
||||
map(Type.STRING, new ValueTransformer<>(Type.STRING) {
|
||||
@Override
|
||||
public String transform(PacketWrapper wrapper, String inputValue) {
|
||||
// 1.13 starts sending slash at start, so we remove it for compatibility
|
||||
|
@ -28,9 +28,7 @@ public class CommandRewriter1_13_1 extends CommandRewriter<ClientboundPackets1_1
|
||||
public CommandRewriter1_13_1(Protocol1_13To1_13_1 protocol) {
|
||||
super(protocol);
|
||||
|
||||
this.parserHandlers.put("minecraft:dimension", wrapper -> {
|
||||
wrapper.write(Type.VAR_INT, 0); // Single word
|
||||
});
|
||||
this.parserHandlers.put("minecraft:dimension", wrapper -> wrapper.write(Type.VAR_INT, 0)); // Single word
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,26 +70,17 @@ public class WorldPackets1_13_1 {
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (id == 2000) { // Smoke
|
||||
switch (data) {
|
||||
case 0: // Down
|
||||
case 1: // Up
|
||||
switch (data) { // Down
|
||||
case 0, 1 -> { // Up
|
||||
Position pos = wrapper.get(Type.POSITION1_8, 0);
|
||||
BlockFace relative = data == 0 ? BlockFace.BOTTOM : BlockFace.TOP;
|
||||
wrapper.set(Type.POSITION1_8, 0, pos.getRelative(relative)); // Y Offset
|
||||
wrapper.set(Type.INT, 1, 4); // Self
|
||||
break;
|
||||
case 2: // North
|
||||
wrapper.set(Type.INT, 1, 1); // North
|
||||
break;
|
||||
case 3: // South
|
||||
wrapper.set(Type.INT, 1, 7); // South
|
||||
break;
|
||||
case 4: // West
|
||||
wrapper.set(Type.INT, 1, 3); // West
|
||||
break;
|
||||
case 5: // East
|
||||
wrapper.set(Type.INT, 1, 5); // East
|
||||
break;
|
||||
}
|
||||
case 2 -> wrapper.set(Type.INT, 1, 1); // North
|
||||
case 3 -> wrapper.set(Type.INT, 1, 7); // South
|
||||
case 4 -> wrapper.set(Type.INT, 1, 3); // West
|
||||
case 5 -> wrapper.set(Type.INT, 1, 5); // East
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -113,7 +113,9 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter<ClientboundPa
|
||||
|
||||
private final String colorName;
|
||||
private final int rgb;
|
||||
private final int r, g, b;
|
||||
private final int r;
|
||||
private final int g;
|
||||
private final int b;
|
||||
|
||||
ChatColor(String colorName, int rgb) {
|
||||
this.colorName = colorName;
|
||||
|
@ -162,11 +162,10 @@ public class BlockItemPackets1_16 extends BackwardsItemRewriter<ClientboundPacke
|
||||
|
||||
CompoundTag heightMaps = chunk.getHeightMap();
|
||||
for (Tag heightMapTag : heightMaps.values()) {
|
||||
if (!(heightMapTag instanceof LongArrayTag)) {
|
||||
if (!(heightMapTag instanceof LongArrayTag heightMap)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LongArrayTag heightMap = (LongArrayTag) heightMapTag;
|
||||
int[] heightMapData = new int[256];
|
||||
CompactArrayUtil.iterateCompactArrayWithPadding(9, heightMapData.length, heightMap.getValue(), (i, v) -> heightMapData[i] = v);
|
||||
heightMap.setValue(CompactArrayUtil.createCompactArray(9, heightMapData.length, i -> heightMapData[i]));
|
||||
@ -188,12 +187,7 @@ public class BlockItemPackets1_16 extends BackwardsItemRewriter<ClientboundPacke
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
int biome = chunk.getBiomeData()[i];
|
||||
switch (biome) {
|
||||
case 170: // new nether biomes
|
||||
case 171:
|
||||
case 172:
|
||||
case 173:
|
||||
chunk.getBiomeData()[i] = 8;
|
||||
break;
|
||||
case 170, 171, 172, 173 -> chunk.getBiomeData()[i] = 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -266,19 +260,16 @@ public class BlockItemPackets1_16 extends BackwardsItemRewriter<ClientboundPacke
|
||||
UUID targetUuid = UUIDUtil.fromIntArray((int[]) targetUuidTag.getValue());
|
||||
tag.putString("target_uuid", targetUuid.toString());
|
||||
} else if (id.equals("minecraft:skull")) {
|
||||
Tag skullOwnerTag = tag.remove("SkullOwner");
|
||||
if (!(skullOwnerTag instanceof CompoundTag)) return;
|
||||
if (!(tag.remove("SkullOwner") instanceof CompoundTag skullOwnerTag)) return;
|
||||
|
||||
CompoundTag skullOwnerCompoundTag = (CompoundTag) skullOwnerTag;
|
||||
Tag ownerUuidTag = skullOwnerCompoundTag.remove("Id");
|
||||
if (ownerUuidTag instanceof IntArrayTag) {
|
||||
UUID ownerUuid = UUIDUtil.fromIntArray((int[]) ownerUuidTag.getValue());
|
||||
skullOwnerCompoundTag.putString("Id", ownerUuid.toString());
|
||||
if (skullOwnerTag.remove("Id") instanceof IntArrayTag ownerUuidTag) {
|
||||
UUID ownerUuid = UUIDUtil.fromIntArray(ownerUuidTag.getValue());
|
||||
skullOwnerTag.putString("Id", ownerUuid.toString());
|
||||
}
|
||||
|
||||
// SkullOwner -> Owner
|
||||
CompoundTag ownerTag = new CompoundTag();
|
||||
for (Map.Entry<String, Tag> entry : skullOwnerCompoundTag) {
|
||||
for (Map.Entry<String, Tag> entry : skullOwnerTag) {
|
||||
ownerTag.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
tag.put("Owner", ownerTag);
|
||||
@ -349,13 +340,6 @@ public class BlockItemPackets1_16 extends BackwardsItemRewriter<ClientboundPacke
|
||||
return item;
|
||||
}
|
||||
|
||||
private static final class EquipmentData {
|
||||
private final int slot;
|
||||
private final Item item;
|
||||
|
||||
private EquipmentData(final int slot, final Item item) {
|
||||
this.slot = slot;
|
||||
this.item = item;
|
||||
}
|
||||
private record EquipmentData(int slot, Item item) {
|
||||
}
|
||||
}
|
||||
|
@ -44,19 +44,15 @@ import com.viaversion.viaversion.util.Key;
|
||||
|
||||
public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Protocol1_15_2To1_16> {
|
||||
|
||||
private final ValueTransformer<String, Integer> dimensionTransformer = new ValueTransformer<String, Integer>(Type.STRING, Type.INT) {
|
||||
private final ValueTransformer<String, Integer> dimensionTransformer = new ValueTransformer<>(Type.STRING, Type.INT) {
|
||||
@Override
|
||||
public Integer transform(PacketWrapper wrapper, String input) {
|
||||
input = Key.namespaced(input);
|
||||
switch (input) {
|
||||
case "minecraft:the_nether":
|
||||
return -1;
|
||||
default:
|
||||
case "minecraft:overworld":
|
||||
return 0;
|
||||
case "minecraft:the_end":
|
||||
return 1;
|
||||
}
|
||||
return switch (input) {
|
||||
case "minecraft:the_nether" -> -1;
|
||||
case "minecraft:the_end" -> 1;
|
||||
default -> 0; // Including overworld
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_16_2.STATISTICS);
|
||||
}
|
||||
|
||||
private static void sendSeenRecipePacket(int recipeType, PacketWrapper wrapper) throws Exception {
|
||||
private static void sendSeenRecipePacket(int recipeType, PacketWrapper wrapper) {
|
||||
boolean open = wrapper.read(Type.BOOLEAN);
|
||||
boolean filter = wrapper.read(Type.BOOLEAN);
|
||||
|
||||
|
@ -28,9 +28,7 @@ public class CommandRewriter1_16_2 extends CommandRewriter<ClientboundPackets1_1
|
||||
public CommandRewriter1_16_2(Protocol1_16_1To1_16_2 protocol) {
|
||||
super(protocol);
|
||||
|
||||
this.parserHandlers.put("minecraft:angle", wrapper -> {
|
||||
wrapper.write(Type.VAR_INT, 0); // Single word
|
||||
});
|
||||
this.parserHandlers.put("minecraft:angle", wrapper -> wrapper.write(Type.VAR_INT, 0)); // Single word
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -244,7 +244,7 @@ public final class BlockItemPackets1_17 extends BackwardsItemRewriter<Clientboun
|
||||
}
|
||||
|
||||
private void writeLightArrays(PacketWrapper wrapper, BitSet bitMask, int cutBitMask,
|
||||
int startFromSection, int sectionHeight) throws Exception {
|
||||
int startFromSection, int sectionHeight) {
|
||||
wrapper.read(Type.VAR_INT); // Length - throw it away
|
||||
|
||||
List<byte[]> light = new ArrayList<>();
|
||||
|
@ -120,10 +120,7 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
map(Type.FLOAT);
|
||||
map(Type.BYTE);
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
// Dismount vehicle ¯\_(ツ)_/¯
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
});
|
||||
read(Type.BOOLEAN); // Dismount vehicle ¯\_(ツ)_/¯
|
||||
}
|
||||
});
|
||||
|
||||
@ -131,9 +128,7 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Type.INT, wrapper.read(Type.VAR_INT)); // Collection length
|
||||
});
|
||||
handler(wrapper -> wrapper.write(Type.INT, wrapper.read(Type.VAR_INT))); // Collection length
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -56,6 +56,7 @@ import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import java.security.SignatureException;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -254,7 +255,12 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
final List<Pair<String, String>> arguments = argumentsProvider.getSignableArguments(command);
|
||||
wrapper.write(Type.VAR_INT, arguments.size());
|
||||
for (final Pair<String, String> argument : arguments) {
|
||||
final byte[] signature = chatSession.signChatMessage(metadata, new DecoratableMessage(argument.value()));
|
||||
final byte[] signature;
|
||||
try {
|
||||
signature = chatSession.signChatMessage(metadata, new DecoratableMessage(argument.value()));
|
||||
} catch (final SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, argument.key());
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signature);
|
||||
@ -266,7 +272,12 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
if (chatSession != null) {
|
||||
final MessageMetadata metadata = new MessageMetadata(sender, timestamp, salt);
|
||||
final DecoratableMessage decoratableMessage = new DecoratableMessage(message);
|
||||
final byte[] signature = chatSession.signChatMessage(metadata, decoratableMessage);
|
||||
final byte[] signature;
|
||||
try {
|
||||
signature = chatSession.signChatMessage(metadata, decoratableMessage);
|
||||
} catch (final SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signature); // Signature
|
||||
} else {
|
||||
@ -330,10 +341,15 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
wrapper.write(Type.BOOLEAN, chatSession == null); // Is nonce
|
||||
if (chatSession != null) {
|
||||
final long salt = ThreadLocalRandom.current().nextLong();
|
||||
final byte[] signature = chatSession.sign(signer -> {
|
||||
signer.accept(wrapper.user().remove(NonceStorage.class).nonce());
|
||||
signer.accept(Longs.toByteArray(salt));
|
||||
});
|
||||
final byte[] signature;
|
||||
try {
|
||||
signature = chatSession.sign(signer -> {
|
||||
signer.accept(wrapper.user().remove(NonceStorage.class).nonce());
|
||||
signer.accept(Longs.toByteArray(salt));
|
||||
});
|
||||
} catch (final SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
wrapper.write(Type.LONG, salt); // Salt
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signature); // Signature
|
||||
} else {
|
||||
|
@ -20,15 +20,6 @@ package com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.storage;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class NonceStorage implements StorableObject {
|
||||
public record NonceStorage(byte @Nullable [] nonce) implements StorableObject {
|
||||
|
||||
private final byte[] nonce;
|
||||
|
||||
public NonceStorage(final byte @Nullable [] nonce) {
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
public byte @Nullable [] nonce() {
|
||||
return nonce;
|
||||
}
|
||||
}
|
||||
|
@ -52,19 +52,13 @@ public final class StoredPainting implements StorableObject {
|
||||
}
|
||||
|
||||
private byte to2dDirection(int direction) {
|
||||
switch (direction) {
|
||||
case 0:
|
||||
case 1:
|
||||
return -1; // No worky
|
||||
case 2:
|
||||
return 2;
|
||||
case 3:
|
||||
return 0;
|
||||
case 4:
|
||||
return 1;
|
||||
case 5:
|
||||
return 3;
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid direction: " + direction);
|
||||
return switch (direction) {
|
||||
case 0, 1 -> -1; // No worky
|
||||
case 2 -> 2;
|
||||
case 3 -> 0;
|
||||
case 4 -> 1;
|
||||
case 5 -> 3;
|
||||
default -> throw new IllegalArgumentException("Invalid direction: " + direction);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.util.CipherUtil;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import java.security.SignatureException;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@ -231,7 +232,12 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
final long salt = wrapper.get(Type.LONG, 1);
|
||||
|
||||
final MessageMetadata metadata = new MessageMetadata(null, timestamp, salt);
|
||||
final byte[] signature = chatSession.signChatMessage(metadata, message, new PlayerMessageSignature[0]);
|
||||
final byte[] signature;
|
||||
try {
|
||||
signature = chatSession.signChatMessage(metadata, message, new PlayerMessageSignature[0]);
|
||||
} catch (final SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
wrapper.write(Protocol1_19_1To1_19_3.OPTIONAL_SIGNATURE_BYTES_TYPE, signature); // Signature
|
||||
} else {
|
||||
@ -271,7 +277,12 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
final List<Pair<String, String>> arguments = argumentsProvider.getSignableArguments(command);
|
||||
wrapper.write(Type.VAR_INT, arguments.size());
|
||||
for (final Pair<String, String> argument : arguments) {
|
||||
final byte[] signature = chatSession.signChatMessage(metadata, argument.value(), new PlayerMessageSignature[0]);
|
||||
final byte[] signature;
|
||||
try {
|
||||
signature = chatSession.signChatMessage(metadata, argument.value(), new PlayerMessageSignature[0]);
|
||||
} catch (final SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, argument.key());
|
||||
wrapper.write(Protocol1_19_1To1_19_3.SIGNATURE_BYTES_TYPE, signature);
|
||||
@ -350,7 +361,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
cancelServerbound(ServerboundPackets1_19_1.CHAT_ACK);
|
||||
}
|
||||
|
||||
private @Nullable String rewriteSound(final PacketWrapper wrapper) throws Exception {
|
||||
private @Nullable String rewriteSound(final PacketWrapper wrapper) {
|
||||
final Holder<SoundEvent> holder = wrapper.read(Type.SOUND_EVENT);
|
||||
if (holder.hasId()) {
|
||||
final int mappedId = MAPPINGS.getSoundMappings().getNewId(holder.id());
|
||||
|
@ -180,15 +180,9 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
||||
continue;
|
||||
}
|
||||
switch (action) {
|
||||
case UPDATE_GAMEMODE:
|
||||
gamemode = wrapper.read(Type.VAR_INT);
|
||||
break;
|
||||
case UPDATE_LATENCY:
|
||||
latency = wrapper.read(Type.VAR_INT);
|
||||
break;
|
||||
case UPDATE_DISPLAYNAME:
|
||||
displayName = wrapper.read(Type.OPTIONAL_COMPONENT);
|
||||
break;
|
||||
case UPDATE_GAMEMODE -> gamemode = wrapper.read(Type.VAR_INT);
|
||||
case UPDATE_LATENCY -> latency = wrapper.read(Type.VAR_INT);
|
||||
case UPDATE_DISPLAYNAME -> displayName = wrapper.read(Type.OPTIONAL_COMPONENT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +207,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
||||
});
|
||||
}
|
||||
|
||||
private void sendPlayerProfileUpdate(final UserConnection connection, final int action, final PlayerProfileUpdate[] updates) throws Exception {
|
||||
private void sendPlayerProfileUpdate(final UserConnection connection, final int action, final PlayerProfileUpdate[] updates) {
|
||||
final PacketWrapper playerInfoPacket = PacketWrapper.create(ClientboundPackets1_19_1.PLAYER_INFO, connection);
|
||||
playerInfoPacket.write(Type.VAR_INT, action);
|
||||
playerInfoPacket.write(Type.VAR_INT, updates.length);
|
||||
@ -274,33 +268,6 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
||||
return EntityTypes1_19_3.getTypeFromId(typeId);
|
||||
}
|
||||
|
||||
private static final class PlayerProfileUpdate {
|
||||
private final UUID uuid;
|
||||
private final int gamemode;
|
||||
private final int latency;
|
||||
private final JsonElement displayName;
|
||||
|
||||
private PlayerProfileUpdate(final UUID uuid, final int gamemode, final int latency, @Nullable final JsonElement displayName) {
|
||||
this.uuid = uuid;
|
||||
this.gamemode = gamemode;
|
||||
this.latency = latency;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public UUID uuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public int gamemode() {
|
||||
return gamemode;
|
||||
}
|
||||
|
||||
public int latency() {
|
||||
return latency;
|
||||
}
|
||||
|
||||
public @Nullable JsonElement displayName() {
|
||||
return displayName;
|
||||
}
|
||||
private record PlayerProfileUpdate(UUID uuid, int gamemode, int latency, @Nullable JsonElement displayName) {
|
||||
}
|
||||
}
|
||||
|
@ -20,15 +20,5 @@ package com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.storage;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class NonceStorage implements StorableObject {
|
||||
|
||||
private final byte[] nonce;
|
||||
|
||||
public NonceStorage(final byte @Nullable [] nonce) {
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
public byte @Nullable [] nonce() {
|
||||
return nonce;
|
||||
}
|
||||
public record NonceStorage(byte @Nullable [] nonce) implements StorableObject {
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.DISGUISED_CHAT);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
new CommandRewriter<ClientboundPackets1_19_4>(this) {
|
||||
new CommandRewriter<>(this) {
|
||||
@Override
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception {
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) {
|
||||
switch (argumentType) {
|
||||
case "minecraft:heightmap":
|
||||
wrapper.write(Type.VAR_INT, 0);
|
||||
|
@ -75,9 +75,9 @@ public final class BlockItemPackets1_19_4 extends BackwardsItemRewriter<Clientbo
|
||||
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_4.WINDOW_PROPERTY);
|
||||
registerSpawnParticle1_19(ClientboundPackets1_19_4.SPAWN_PARTICLE);
|
||||
|
||||
final RecipeRewriter1_19_3<ClientboundPackets1_19_4> recipeRewriter = new RecipeRewriter1_19_3<ClientboundPackets1_19_4>(protocol) {
|
||||
final RecipeRewriter1_19_3<ClientboundPackets1_19_4> recipeRewriter = new RecipeRewriter1_19_3<>(protocol) {
|
||||
@Override
|
||||
public void handleCraftingShaped(final PacketWrapper wrapper) throws Exception {
|
||||
public void handleCraftingShaped(final PacketWrapper wrapper) {
|
||||
final int ingredients = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.passthrough(Type.VAR_INT); // Crafting book category
|
||||
|
@ -198,8 +198,7 @@ public final class BlockItemPackets1_20 extends BackwardsItemRewriter<Clientboun
|
||||
final Tag frontText = tag.remove("front_text");
|
||||
tag.remove("back_text");
|
||||
|
||||
if (frontText instanceof CompoundTag) {
|
||||
final CompoundTag frontTextTag = (CompoundTag) frontText;
|
||||
if (frontText instanceof CompoundTag frontTextTag) {
|
||||
writeMessages(frontTextTag, tag, false);
|
||||
writeMessages(frontTextTag, tag, true);
|
||||
|
||||
|
@ -20,15 +20,5 @@ package com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.storage;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
|
||||
public final class BackSignEditStorage implements StorableObject {
|
||||
|
||||
private final Position position;
|
||||
|
||||
public BackSignEditStorage(final Position position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public Position position() {
|
||||
return position;
|
||||
}
|
||||
public record BackSignEditStorage(Position position) implements StorableObject {
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ import com.viaversion.viaversion.util.CipherUtil;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import com.viaversion.viaversion.util.TagUtil;
|
||||
import java.security.SignatureException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@ -205,7 +206,12 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
final MessageMetadata metadata = new MessageMetadata(sender, timestamp, salt);
|
||||
final DecoratableMessage decoratableMessage = new DecoratableMessage(message);
|
||||
final byte[] signature = chatSession.signChatMessage(metadata, decoratableMessage, messagesStorage.lastSignatures());
|
||||
final byte[] signature;
|
||||
try {
|
||||
signature = chatSession.signChatMessage(metadata, decoratableMessage, messagesStorage.lastSignatures());
|
||||
} catch (final SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signature); // Signature
|
||||
wrapper.write(Type.BOOLEAN, decoratableMessage.isDecorated()); // Signed preview
|
||||
@ -249,7 +255,12 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
final List<Pair<String, String>> arguments = argumentsProvider.getSignableArguments(command);
|
||||
wrapper.write(Type.VAR_INT, arguments.size());
|
||||
for (final Pair<String, String> argument : arguments) {
|
||||
final byte[] signature = chatSession.signChatMessage(metadata, new DecoratableMessage(argument.value()), messagesStorage.lastSignatures());
|
||||
final byte[] signature;
|
||||
try {
|
||||
signature = chatSession.signChatMessage(metadata, new DecoratableMessage(argument.value()), messagesStorage.lastSignatures());
|
||||
} catch (final SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, argument.key());
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signature);
|
||||
|
@ -18,17 +18,6 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class NonceStorage implements StorableObject {
|
||||
|
||||
private final byte[] nonce;
|
||||
|
||||
public NonceStorage(final byte @Nullable [] nonce) {
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
public byte @Nullable [] nonce() {
|
||||
return nonce;
|
||||
}
|
||||
public record NonceStorage(byte[] nonce) implements StorableObject {
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundP
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_20_3.STOP_SOUND);
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_3.STATISTICS);
|
||||
new CommandRewriter1_19_4<ClientboundPacket1_20_3>(this) {
|
||||
new CommandRewriter1_19_4<>(this) {
|
||||
@Override
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception {
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) {
|
||||
if (argumentType.equals("minecraft:style")) {
|
||||
wrapper.write(Type.VAR_INT, 1); // Phrase
|
||||
} else {
|
||||
@ -364,13 +364,13 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundP
|
||||
};
|
||||
}
|
||||
|
||||
private void convertComponent(final PacketWrapper wrapper) throws Exception {
|
||||
private void convertComponent(final PacketWrapper wrapper) {
|
||||
final Tag tag = wrapper.read(Type.TAG);
|
||||
translatableRewriter.processTag(wrapper.user(), tag);
|
||||
wrapper.write(Type.COMPONENT, ComponentUtil.tagToJson(tag));
|
||||
}
|
||||
|
||||
private void convertOptionalComponent(final PacketWrapper wrapper) throws Exception {
|
||||
private void convertOptionalComponent(final PacketWrapper wrapper) {
|
||||
final Tag tag = wrapper.read(Type.OPTIONAL_TAG);
|
||||
translatableRewriter.processTag(wrapper.user(), tag);
|
||||
wrapper.write(Type.OPTIONAL_COMPONENT, ComponentUtil.tagToJson(tag));
|
||||
|
@ -90,9 +90,9 @@ public final class BlockItemPacketRewriter1_20_3 extends BackwardsItemRewriter<C
|
||||
}
|
||||
});
|
||||
|
||||
new RecipeRewriter1_20_3<ClientboundPacket1_20_3>(protocol) {
|
||||
new RecipeRewriter1_20_3<>(protocol) {
|
||||
@Override
|
||||
public void handleCraftingShaped(final PacketWrapper wrapper) throws Exception {
|
||||
public void handleCraftingShaped(final PacketWrapper wrapper) {
|
||||
// Move width and height up
|
||||
final String group = wrapper.read(Type.STRING);
|
||||
final int craftingBookCategory = wrapper.read(Type.VAR_INT);
|
||||
|
@ -20,16 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.storage;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ResourcepackIDStorage implements StorableObject {
|
||||
private final UUID uuid;
|
||||
|
||||
public ResourcepackIDStorage(final UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public UUID uuid() {
|
||||
return uuid;
|
||||
}
|
||||
public record ResourcepackIDStorage(UUID uuid) implements StorableObject {
|
||||
|
||||
@Override
|
||||
public boolean clearOnServerSwitch() {
|
||||
|
@ -151,9 +151,9 @@ public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol<ClientboundP
|
||||
response.sendToServer(Protocol1_20_3To1_20_5.class);
|
||||
});
|
||||
|
||||
new CommandRewriter1_19_4<ClientboundPacket1_20_5>(this) {
|
||||
new CommandRewriter1_19_4<>(this) {
|
||||
@Override
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception {
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) {
|
||||
if (argumentType.equals("minecraft:loot_table")
|
||||
|| argumentType.equals("minecraft:loot_predicate")
|
||||
|| argumentType.equals("minecraft:loot_modifier")) {
|
||||
@ -182,7 +182,7 @@ public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol<ClientboundP
|
||||
cancelClientbound(ClientboundPackets1_20_5.DEBUG_SAMPLE);
|
||||
}
|
||||
|
||||
private void handleStoreCookie(final PacketWrapper wrapper) throws Exception {
|
||||
private void handleStoreCookie(final PacketWrapper wrapper) {
|
||||
wrapper.cancel();
|
||||
|
||||
final String resourceLocation = wrapper.read(Type.STRING);
|
||||
@ -194,7 +194,7 @@ public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol<ClientboundP
|
||||
wrapper.user().get(CookieStorage.class).cookies().put(resourceLocation, data);
|
||||
}
|
||||
|
||||
private void handleCookieRequest(final PacketWrapper wrapper, final ServerboundPacketType responseType) throws Exception {
|
||||
private void handleCookieRequest(final PacketWrapper wrapper, final ServerboundPacketType responseType) {
|
||||
wrapper.cancel();
|
||||
|
||||
final String resourceLocation = wrapper.read(Type.STRING);
|
||||
@ -205,7 +205,7 @@ public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol<ClientboundP
|
||||
responsePacket.sendToServer(Protocol1_20_3To1_20_5.class);
|
||||
}
|
||||
|
||||
private void handleTransfer(final PacketWrapper wrapper) throws Exception {
|
||||
private void handleTransfer(final PacketWrapper wrapper) {
|
||||
wrapper.cancel();
|
||||
|
||||
final String host = wrapper.read(Type.STRING);
|
||||
|
@ -294,40 +294,24 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem
|
||||
}
|
||||
|
||||
private static int colorId(final String color) {
|
||||
switch (color) {
|
||||
case "orange":
|
||||
return 1;
|
||||
case "magenta":
|
||||
return 2;
|
||||
case "light_blue":
|
||||
return 3;
|
||||
case "yellow":
|
||||
return 4;
|
||||
case "lime":
|
||||
return 5;
|
||||
case "pink":
|
||||
return 6;
|
||||
case "gray":
|
||||
return 7;
|
||||
case "light_gray":
|
||||
return 8;
|
||||
case "cyan":
|
||||
return 9;
|
||||
case "purple":
|
||||
return 10;
|
||||
case "blue":
|
||||
return 11;
|
||||
case "brown":
|
||||
return 12;
|
||||
case "green":
|
||||
return 13;
|
||||
case "red":
|
||||
return 14;
|
||||
case "black":
|
||||
return 15;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return switch (color) {
|
||||
case "orange" -> 1;
|
||||
case "magenta" -> 2;
|
||||
case "light_blue" -> 3;
|
||||
case "yellow" -> 4;
|
||||
case "lime" -> 5;
|
||||
case "pink" -> 6;
|
||||
case "gray" -> 7;
|
||||
case "light_gray" -> 8;
|
||||
case "cyan" -> 9;
|
||||
case "purple" -> 10;
|
||||
case "blue" -> 11;
|
||||
case "brown" -> 12;
|
||||
case "green" -> 13;
|
||||
case "red" -> 14;
|
||||
case "black" -> 15;
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +35,7 @@ import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.exception.CancelException;
|
||||
import com.viaversion.viaversion.exception.InformativeException;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
|
||||
@ -170,7 +171,7 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(final Direction direction, final State state, final PacketWrapper wrapper) throws Exception {
|
||||
public void transform(final Direction direction, final State state, final PacketWrapper wrapper) throws InformativeException, CancelException {
|
||||
final ConfigurationPacketStorage configurationPacketStorage = wrapper.user().get(ConfigurationPacketStorage.class);
|
||||
if (configurationPacketStorage == null || configurationPacketStorage.isFinished()) {
|
||||
super.transform(direction, state, wrapper);
|
||||
|
@ -286,9 +286,9 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
}
|
||||
});
|
||||
|
||||
new RecipeRewriter1_20_2<ClientboundPackets1_20_2>(protocol) {
|
||||
new RecipeRewriter1_20_2<>(protocol) {
|
||||
@Override
|
||||
public void handleCraftingShapeless(final PacketWrapper wrapper) throws Exception {
|
||||
public void handleCraftingShapeless(final PacketWrapper wrapper) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.passthrough(Type.VAR_INT); // Crafting book category
|
||||
handleIngredients(wrapper);
|
||||
@ -299,7 +299,7 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSmelting(final PacketWrapper wrapper) throws Exception {
|
||||
public void handleSmelting(final PacketWrapper wrapper) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.passthrough(Type.VAR_INT); // Crafting book category
|
||||
handleIngredient(wrapper);
|
||||
@ -313,7 +313,7 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCraftingShaped(final PacketWrapper wrapper) throws Exception {
|
||||
public void handleCraftingShaped(final PacketWrapper wrapper) {
|
||||
final int ingredients = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.passthrough(Type.VAR_INT); // Crafting book category
|
||||
@ -329,7 +329,7 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleStonecutting(final PacketWrapper wrapper) throws Exception {
|
||||
public void handleStonecutting(final PacketWrapper wrapper) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
handleIngredient(wrapper);
|
||||
|
||||
@ -339,7 +339,7 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSmithing(final PacketWrapper wrapper) throws Exception {
|
||||
public void handleSmithing(final PacketWrapper wrapper) {
|
||||
handleIngredient(wrapper); // Base
|
||||
handleIngredient(wrapper); // Addition
|
||||
|
||||
@ -349,7 +349,7 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSmithingTransform(final PacketWrapper wrapper) throws Exception {
|
||||
public void handleSmithingTransform(final PacketWrapper wrapper) {
|
||||
handleIngredient(wrapper); // Template
|
||||
handleIngredient(wrapper); // Base
|
||||
handleIngredient(wrapper); // Additions
|
||||
@ -360,7 +360,7 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleIngredient(final PacketWrapper wrapper) throws Exception {
|
||||
protected void handleIngredient(final PacketWrapper wrapper) {
|
||||
final Item[] items = wrapper.read(itemArrayType());
|
||||
wrapper.write(Type.ITEM1_13_2_ARRAY, items);
|
||||
for (final Item item : items) {
|
||||
|
@ -39,7 +39,7 @@ public final class ConfigurationPacketStorage implements StorableObject {
|
||||
private boolean finished;
|
||||
private QueuedPacket resourcePack;
|
||||
|
||||
public void setResourcePack(final PacketWrapper wrapper) throws Exception {
|
||||
public void setResourcePack(final PacketWrapper wrapper) {
|
||||
resourcePack = toQueuedPacket(wrapper, ClientboundPackets1_19_4.RESOURCE_PACK);
|
||||
}
|
||||
|
||||
@ -60,11 +60,11 @@ public final class ConfigurationPacketStorage implements StorableObject {
|
||||
this.enabledFeatures = enabledFeatures;
|
||||
}
|
||||
|
||||
public void addRawPacket(final PacketWrapper wrapper, final PacketType type) throws Exception {
|
||||
public void addRawPacket(final PacketWrapper wrapper, final PacketType type) {
|
||||
rawPackets.add(toQueuedPacket(wrapper, type));
|
||||
}
|
||||
|
||||
private QueuedPacket toQueuedPacket(final PacketWrapper wrapper, final PacketType type) throws Exception {
|
||||
private QueuedPacket toQueuedPacket(final PacketWrapper wrapper, final PacketType type) {
|
||||
Preconditions.checkArgument(!wrapper.isCancelled(), "Wrapper should be cancelled AFTER calling toQueuedPacket");
|
||||
|
||||
// It's easier to just copy it to a byte array buffer than to manually read the data
|
||||
@ -75,7 +75,7 @@ public final class ConfigurationPacketStorage implements StorableObject {
|
||||
return new QueuedPacket(buf, type);
|
||||
}
|
||||
|
||||
public void sendQueuedPackets(final UserConnection connection) throws Exception {
|
||||
public void sendQueuedPackets(final UserConnection connection) {
|
||||
// Send resource pack at the end
|
||||
if (resourcePack != null) {
|
||||
rawPackets.add(resourcePack);
|
||||
@ -100,21 +100,6 @@ public final class ConfigurationPacketStorage implements StorableObject {
|
||||
this.finished = finished;
|
||||
}
|
||||
|
||||
public static final class QueuedPacket {
|
||||
private final ByteBuf buf;
|
||||
private final PacketType packetType;
|
||||
|
||||
public QueuedPacket(final ByteBuf buf, final PacketType packetType) {
|
||||
this.buf = buf;
|
||||
this.packetType = packetType;
|
||||
}
|
||||
|
||||
public ByteBuf buf() {
|
||||
return buf;
|
||||
}
|
||||
|
||||
public PacketType packetType() {
|
||||
return packetType;
|
||||
}
|
||||
public record QueuedPacket(ByteBuf buf, PacketType packetType) {
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class BlockEntity {
|
||||
TYPES.put("Sign", 9);
|
||||
}
|
||||
|
||||
public static void handle(List<CompoundTag> tags, UserConnection connection) throws Exception {
|
||||
public static void handle(List<CompoundTag> tags, UserConnection connection) {
|
||||
for (CompoundTag tag : tags) {
|
||||
StringTag idTag = tag.getStringTag("id");
|
||||
if (idTag == null) {
|
||||
@ -71,7 +71,7 @@ public class BlockEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateBlockEntity(Position pos, short id, CompoundTag tag, UserConnection connection) throws Exception {
|
||||
private static void updateBlockEntity(Position pos, short id, CompoundTag tag, UserConnection connection) {
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, null, connection);
|
||||
wrapper.write(Type.POSITION1_8, pos);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, id);
|
||||
|
@ -37,8 +37,8 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPac
|
||||
public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.10", "1.9.4");
|
||||
private static final ValueTransformer<Float, Short> TO_OLD_PITCH = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) {
|
||||
public Short transform(PacketWrapper packetWrapper, Float inputValue) throws Exception {
|
||||
private static final ValueTransformer<Float, Short> TO_OLD_PITCH = new ValueTransformer<>(Type.UNSIGNED_BYTE) {
|
||||
public Short transform(PacketWrapper packetWrapper, Float inputValue) {
|
||||
return (short) Math.round(inputValue * 63.5F);
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
projectVersion=4.10.3-SNAPSHOT
|
||||
projectVersion=5.0.0-SNAPSHOT
|
||||
|
||||
# Smile emoji
|
||||
mcVersions=1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10
|
||||
|
@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
||||
[versions]
|
||||
|
||||
# ViaVersion
|
||||
viaver = "4.10.2-SNAPSHOT"
|
||||
viaver = "5.0.0-SNAPSHOT"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
|
@ -4,6 +4,7 @@ rootProject.name = "viabackwards-parent"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven("https://repo.viaversion.com")
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||
|
Loading…
Reference in New Issue
Block a user