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