mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2026-11-04 17:00:16 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9af3076c54 | ||
|
|
4c75ea98f1 | ||
|
|
5194c27e4c | ||
|
|
c887ab740b | ||
|
|
63afb2d063 | ||
|
|
827c00f625 | ||
|
|
8c07e58d40 | ||
|
|
3b30aa2454 | ||
|
|
74b0bfb5ab |
No files matched your search
@@ -15,7 +15,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # 5.0.1
|
||||
uses: gradle/actions/setup-gradle@39e147cb9de83bb9910b8ef8bd7fff0ee20fcd6f # 6.0.1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # 5.2.0
|
||||
with:
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # 5.0.1
|
||||
uses: gradle/actions/setup-gradle@39e147cb9de83bb9910b8ef8bd7fff0ee20fcd6f # 6.0.1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # 5.2.0
|
||||
with:
|
||||
|
||||
+9
-12
@@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.template;
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_11;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21_11;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes26_1;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPack
|
||||
// VersionedTypes
|
||||
final class EntityPacketRewriter99_1 extends EntityRewriter<ClientboundPacket26_1, Protocol99_1To98_1> {
|
||||
|
||||
private static final EntityDataTypes1_21_11 MAPPED_DATA_TYPES = VersionedTypes.V1_21_11.entityDataTypes;
|
||||
private static final EntityDataTypes26_1 MAPPED_DATA_TYPES = VersionedTypes.V26_1.entityDataTypes;
|
||||
|
||||
public EntityPacketRewriter99_1(final Protocol99_1To98_1 protocol) {
|
||||
super(protocol, MAPPED_DATA_TYPES.optionalComponentType, MAPPED_DATA_TYPES.booleanType);
|
||||
@@ -40,16 +40,13 @@ final class EntityPacketRewriter99_1 extends EntityRewriter<ClientboundPacket26_
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
/*filter().handler((event, data) -> {
|
||||
int id = data.dataType().typeId();
|
||||
if (id >= ac) {
|
||||
return;
|
||||
} else if (id >= ab) {
|
||||
id--;
|
||||
}
|
||||
|
||||
data.setDataType(MAPPED_DATA_TYPES.byId(id));
|
||||
});*/
|
||||
dataTypeMapper().register();
|
||||
/* ... or like this for additions and removals that are not at the very end
|
||||
dataTypeMapper()
|
||||
.added(MAPPED_DATA_TYPES.catSoundVariant)
|
||||
.removed(MAPPED_DATA_TYPES.cowSoundVariant)
|
||||
.skip(MAPPED_DATA_TYPES.pigSoundVariant) // if neither removed nor added, but the value type has to be changed separately
|
||||
.register();*/
|
||||
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
MAPPED_DATA_TYPES.itemType,
|
||||
|
||||
+11
-24
@@ -21,7 +21,6 @@ package com.viaversion.viabackwards.protocol.v1_12_2to1_12_1;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.v1_12_2to1_12_1.storage.KeepAliveTracker;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPackets1_12_1;
|
||||
@@ -34,32 +33,20 @@ public class Protocol1_12_2To1_12_1 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
Long keepAlive = packetWrapper.read(Types.LONG);
|
||||
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(keepAlive);
|
||||
packetWrapper.write(Types.VAR_INT, keepAlive.hashCode());
|
||||
});
|
||||
}
|
||||
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, wrapper -> {
|
||||
long keepAlive = wrapper.read(Types.LONG);
|
||||
int id = wrapper.user().get(KeepAliveTracker.class).track(keepAlive);
|
||||
wrapper.write(Types.VAR_INT, id);
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
int keepAlive = packetWrapper.read(Types.VAR_INT);
|
||||
long realKeepAlive = packetWrapper.user().get(KeepAliveTracker.class).getKeepAlive();
|
||||
if (keepAlive != Long.hashCode(realKeepAlive)) {
|
||||
packetWrapper.cancel(); // Wrong data, cancel packet
|
||||
return;
|
||||
}
|
||||
packetWrapper.write(Types.LONG, realKeepAlive);
|
||||
// Reset KeepAliveTracker (to prevent sending same valid value in a row causing a timeout)
|
||||
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(Integer.MAX_VALUE);
|
||||
});
|
||||
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, wrapper -> {
|
||||
int keepAlive = wrapper.read(Types.VAR_INT);
|
||||
Long realKeepAlive = wrapper.user().get(KeepAliveTracker.class).consume(keepAlive);
|
||||
if (realKeepAlive == null) {
|
||||
wrapper.cancel(); // stale/bad
|
||||
return;
|
||||
}
|
||||
wrapper.write(Types.LONG, realKeepAlive);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+12
-10
@@ -19,20 +19,22 @@
|
||||
package com.viaversion.viabackwards.protocol.v1_12_2to1_12_1.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class KeepAliveTracker implements StorableObject {
|
||||
private long keepAlive = Integer.MAX_VALUE;
|
||||
|
||||
public long getKeepAlive() {
|
||||
return keepAlive;
|
||||
private final Map<Integer, Long> pending = new HashMap<>();
|
||||
private int nextId;
|
||||
|
||||
public int track(long original) {
|
||||
int id = nextId++;
|
||||
pending.put(id, original);
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setKeepAlive(long keepAlive) {
|
||||
this.keepAlive = keepAlive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KeepAliveTracker{" + "keepAlive=" + keepAlive + '}';
|
||||
public @Nullable Long consume(int id) {
|
||||
return pending.remove(id);
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -71,7 +71,7 @@ public final class Protocol1_17_1To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
// Length is encoded as a var int in 1.17.1
|
||||
wrapper.write(Types.ITEM1_13_2_SHORT_ARRAY, wrapper.read(Types.ITEM1_13_2_ARRAY));
|
||||
|
||||
// Carried item - should work without adding it to the array above
|
||||
// Carried item - forward as CONTAINER_SET_SLOT for <1.17 clients
|
||||
Item carried = wrapper.read(Types.ITEM1_13_2);
|
||||
|
||||
PlayerLastCursorItem lastCursorItem = wrapper.user().get(PlayerLastCursorItem.class);
|
||||
@@ -82,6 +82,16 @@ public final class Protocol1_17_1To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
// for a subsequent drag
|
||||
|
||||
lastCursorItem.setLastCursorItem(carried);
|
||||
|
||||
// In 1.17.1+, the carried/cursor item is part of CONTAINER_SET_CONTENT,
|
||||
// but <1.17 clients don't have this field. Send it as a separate
|
||||
// CONTAINER_SET_SLOT packet so the client's cursor state is properly synced.
|
||||
// This fixes inventory desyncs when the server cancels InventoryClickEvents.
|
||||
PacketWrapper cursorPacket = wrapper.create(ClientboundPackets1_17.CONTAINER_SET_SLOT);
|
||||
cursorPacket.write(Types.BYTE, (byte) -1); // Window ID: -1 for cursor
|
||||
cursorPacket.write(Types.SHORT, (short) -1); // Slot: -1 for cursor
|
||||
cursorPacket.write(Types.ITEM1_13_2, carried);
|
||||
cursorPacket.send(Protocol1_17_1To1_17.class);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+21
-2
@@ -26,6 +26,7 @@ import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.MapColorRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.data.MapColorMappings1_16_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_17_1to1_17.storage.InventoryStateIds;
|
||||
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.storage.PlayerLastCursorItem;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
@@ -83,8 +84,26 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
|
||||
int mode = wrapper.passthrough(Types.VAR_INT); // Mode
|
||||
Item clicked = handleItemToServer(wrapper.user(), wrapper.read(Types.ITEM1_13_2)); // Clicked item
|
||||
|
||||
// The 1.17 client would check the entire inventory for changes before -> after a click and send the changed slots here
|
||||
wrapper.write(Types.VAR_INT, 0); // Empty array of slot+item
|
||||
// The 1.17 client would check the entire inventory for changes before -> after a click
|
||||
// and send the changed slots here. We include the clicked slot so the server
|
||||
// detects any desync (e.g. cancelled InventoryClickEvent) and sends corrections.
|
||||
if (slot >= 0 && clicked != null) {
|
||||
wrapper.write(Types.VAR_INT, 1); // One modified slot
|
||||
wrapper.write(Types.SHORT, slot); // The clicked slot
|
||||
wrapper.write(Types.ITEM1_13_2, (Item) null); // Predicted: empty (item picked up)
|
||||
} else {
|
||||
wrapper.write(Types.VAR_INT, 0); // Empty array of slot+item
|
||||
}
|
||||
|
||||
// Non-PICKUP modes (shift-click, swap, throw, drag, etc.) affect multiple slots
|
||||
// that we can't easily predict. Force a state ID mismatch so the server
|
||||
// sends a full inventory resync instead of individual slot corrections.
|
||||
if (mode != 0) {
|
||||
InventoryStateIds stateIds = wrapper.user().get(InventoryStateIds.class);
|
||||
if (stateIds != null) {
|
||||
stateIds.setStateId(wrapper.get(Types.BYTE, 0), -1);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerLastCursorItem state = wrapper.user().get(PlayerLastCursorItem.class);
|
||||
if (mode == 0 && button == 0 && clicked != null) {
|
||||
|
||||
+2
-2
@@ -159,7 +159,7 @@ public final class BlockItemPacketRewriter1_19 extends BackwardsItemRewriter<Cli
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_17.SET_BEACON, wrapper -> {
|
||||
final int primaryEffect = wrapper.read(Types.VAR_INT);
|
||||
if (primaryEffect != -1) {
|
||||
if (primaryEffect > 0) {
|
||||
wrapper.write(Types.BOOLEAN, true);
|
||||
wrapper.write(Types.VAR_INT, primaryEffect);
|
||||
} else {
|
||||
@@ -167,7 +167,7 @@ public final class BlockItemPacketRewriter1_19 extends BackwardsItemRewriter<Cli
|
||||
}
|
||||
|
||||
final int secondaryEffect = wrapper.read(Types.VAR_INT);
|
||||
if (secondaryEffect != -1) {
|
||||
if (secondaryEffect > 0) {
|
||||
wrapper.write(Types.BOOLEAN, true);
|
||||
wrapper.write(Types.VAR_INT, secondaryEffect);
|
||||
} else {
|
||||
|
||||
+4
-1
@@ -102,7 +102,10 @@ public final class BlockPacketRewriter1_20_5 extends BlockRewriter<ClientboundPa
|
||||
final String value = propertyTag.getString("value", "");
|
||||
final String signature = propertyTag.getString("signature");
|
||||
|
||||
final ListTag<CompoundTag> list = new ListTag<>(CompoundTag.class);
|
||||
ListTag<CompoundTag> list = propertiesTag.getListTag(property, CompoundTag.class);
|
||||
if (list == null) {
|
||||
list = new ListTag<>(CompoundTag.class);
|
||||
}
|
||||
final CompoundTag updatedPropertyTag = new CompoundTag();
|
||||
updatedPropertyTag.putString("Value", value);
|
||||
if (signature != null) {
|
||||
|
||||
+7
-15
@@ -63,21 +63,13 @@ public final class EntityPacketRewriter1_21_11 extends EntityRewriter<Clientboun
|
||||
protected void registerRewrites() {
|
||||
final EntityDataTypes1_21_11 unmappedDataTypes = VersionedTypes.V1_21_11.entityDataTypes;
|
||||
final EntityDataTypes1_21_9 entityDataTypes = VersionedTypes.V1_21_9.entityDataTypes;
|
||||
filter().handler((event, data) -> {
|
||||
if (data.dataType() == unmappedDataTypes.humanoidArmType) {
|
||||
final int arm = data.value();
|
||||
data.setTypeAndValue(entityDataTypes.byteType, (byte) arm);
|
||||
return;
|
||||
} else if (data.dataType() == unmappedDataTypes.zombieNautilusVariantType) {
|
||||
event.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
int id = data.dataType().typeId();
|
||||
if (id > unmappedDataTypes.zombieNautilusVariantType.typeId()) {
|
||||
id--;
|
||||
}
|
||||
data.setDataType(entityDataTypes.byId(id));
|
||||
dataTypeMapper()
|
||||
.removed(unmappedDataTypes.zombieNautilusVariantType)
|
||||
.skip(unmappedDataTypes.humanoidArmType)
|
||||
.register();
|
||||
filter().dataType(unmappedDataTypes.humanoidArmType).handler((event, data) -> {
|
||||
final int arm = data.value();
|
||||
data.setTypeAndValue(entityDataTypes.byteType, (byte) arm);
|
||||
});
|
||||
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
|
||||
+1
-1
@@ -626,7 +626,7 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().mapDataType(VersionedTypes.V1_21.entityDataTypes::byId);
|
||||
dataTypeMapper().register();
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
VersionedTypes.V1_21.entityDataTypes.itemType,
|
||||
VersionedTypes.V1_21.entityDataTypes.blockStateType,
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public final class EntityPacketRewriter1_21_4 extends EntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().mapDataType(VersionedTypes.V1_21_2.entityDataTypes::byId);
|
||||
dataTypeMapper().register();
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
VersionedTypes.V1_21_2.entityDataTypes.itemType,
|
||||
VersionedTypes.V1_21_2.entityDataTypes.blockStateType,
|
||||
|
||||
+43
-57
@@ -136,62 +136,17 @@ public final class EntityPacketRewriter1_21_5 extends EntityRewriter<Clientbound
|
||||
protected void registerRewrites() {
|
||||
final EntityDataTypes1_21_5 entityDataTypes = VersionedTypes.V1_21_5.entityDataTypes;
|
||||
final EntityDataTypes1_21_2 mappedEntityDataTypes = VersionedTypes.V1_21_4.entityDataTypes;
|
||||
filter().handler((event, data) -> {
|
||||
final int id = data.dataType().typeId();
|
||||
if (id == entityDataTypes.wolfVariantType.typeId()) {
|
||||
final int type = data.value();
|
||||
final Holder<WolfVariant> variant = Holder.of(type);
|
||||
data.setTypeAndValue(mappedEntityDataTypes.wolfVariantType, variant);
|
||||
return;
|
||||
} else if (id == entityDataTypes.frogVariantType.typeId()) {
|
||||
final int value = data.value();
|
||||
final String variantKey = protocol.getRegistryDataRewriter().getMappings("frog_variant").idToKey(value);
|
||||
final int newValue = (variantKey == null) ? 0 : switch (variantKey) {
|
||||
case "cold" -> 2;
|
||||
case "temperate" -> 0;
|
||||
case "warm" -> 1;
|
||||
default -> 0;
|
||||
};
|
||||
data.setTypeAndValue(mappedEntityDataTypes.frogVariantType, newValue);
|
||||
return;
|
||||
} else if (id == entityDataTypes.catVariantType.typeId()) {
|
||||
final int value = data.value();
|
||||
final String variantKey = protocol.getRegistryDataRewriter().getMappings("cat_variant").idToKey(value);
|
||||
final int newValue = (variantKey == null) ? 1 : switch (variantKey) {
|
||||
case "all_black" -> 10;
|
||||
case "black" -> 1;
|
||||
case "british_shorthair" -> 4;
|
||||
case "calico" -> 5;
|
||||
case "jellie" -> 9;
|
||||
case "persian" -> 6;
|
||||
case "ragdoll" -> 7;
|
||||
case "red" -> 2;
|
||||
case "siamese" -> 3;
|
||||
case "tabby" -> 0;
|
||||
case "white" -> 8;
|
||||
default -> 1;
|
||||
};
|
||||
data.setTypeAndValue(mappedEntityDataTypes.catVariantType, newValue);
|
||||
return;
|
||||
}
|
||||
|
||||
int mappedId = id;
|
||||
if (id == entityDataTypes.cowVariantType.typeId()
|
||||
|| id == entityDataTypes.pigVariantType.typeId()
|
||||
|| id == entityDataTypes.chickenVariantType.typeId()
|
||||
|| id == entityDataTypes.wolfSoundVariantType.typeId()) {
|
||||
event.cancel();
|
||||
return;
|
||||
} else if (id > entityDataTypes.chickenVariantType.typeId()) {
|
||||
mappedId -= 4;
|
||||
} else if (id > entityDataTypes.pigVariantType.typeId()) {
|
||||
mappedId -= 3;
|
||||
} else if (id > entityDataTypes.wolfSoundVariantType.typeId()) {
|
||||
mappedId -= 2;
|
||||
} else if (id > entityDataTypes.cowVariantType.typeId()) {
|
||||
mappedId -= 1;
|
||||
}
|
||||
data.setDataType(mappedEntityDataTypes.byId(mappedId));
|
||||
dataTypeMapper()
|
||||
.removed(entityDataTypes.cowVariantType)
|
||||
.removed(entityDataTypes.wolfSoundVariantType)
|
||||
.removed(entityDataTypes.pigVariantType)
|
||||
.removed(entityDataTypes.chickenVariantType)
|
||||
.skip(entityDataTypes.wolfVariantType)
|
||||
.register();
|
||||
filter().dataType(entityDataTypes.wolfVariantType).handler((event, data) -> {
|
||||
final int type = data.value();
|
||||
final Holder<WolfVariant> variant = Holder.of(type);
|
||||
data.setTypeAndValue(mappedEntityDataTypes.wolfVariantType, variant);
|
||||
});
|
||||
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
@@ -204,6 +159,37 @@ public final class EntityPacketRewriter1_21_5 extends EntityRewriter<Clientbound
|
||||
mappedEntityDataTypes.optionalComponentType
|
||||
);
|
||||
|
||||
filter().dataType(mappedEntityDataTypes.frogVariantType).handler((event, data) -> {
|
||||
final int value = data.value();
|
||||
final String variantKey = protocol.getRegistryDataRewriter().getMappings("frog_variant").idToKey(value);
|
||||
final int newValue = (variantKey == null) ? 0 : switch (variantKey) {
|
||||
case "cold" -> 2;
|
||||
case "temperate" -> 0;
|
||||
case "warm" -> 1;
|
||||
default -> 0;
|
||||
};
|
||||
data.setValue(newValue);
|
||||
});
|
||||
filter().dataType(mappedEntityDataTypes.catVariantType).handler((event, data) -> {
|
||||
final int value = data.value();
|
||||
final String variantKey = protocol.getRegistryDataRewriter().getMappings("cat_variant").idToKey(value);
|
||||
final int newValue = (variantKey == null) ? 1 : switch (variantKey) {
|
||||
case "all_black" -> 10;
|
||||
case "black" -> 1;
|
||||
case "british_shorthair" -> 4;
|
||||
case "calico" -> 5;
|
||||
case "jellie" -> 9;
|
||||
case "persian" -> 6;
|
||||
case "ragdoll" -> 7;
|
||||
case "red" -> 2;
|
||||
case "siamese" -> 3;
|
||||
case "tabby" -> 0;
|
||||
case "white" -> 8;
|
||||
default -> 1;
|
||||
};
|
||||
data.setValue(newValue);
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_21_5.ABSTRACT_MINECART).addIndex(13); // Custom display
|
||||
filter().type(EntityTypes1_21_5.ABSTRACT_MINECART).index(11).handler((event, data) -> {
|
||||
final int state = (int) data.getValue();
|
||||
@@ -240,7 +226,7 @@ public final class EntityPacketRewriter1_21_5 extends EntityRewriter<Clientbound
|
||||
|
||||
filter().type(EntityTypes1_21_5.CHICKEN).cancel(17); // Chicken variant
|
||||
filter().type(EntityTypes1_21_5.COW).cancel(17); // Cow variant
|
||||
filter().type(EntityTypes1_21_5.PIG).cancel(19); // Pig variant
|
||||
filter().type(EntityTypes1_21_5.PIG).cancel(18); // Pig variant
|
||||
filter().type(EntityTypes1_21_5.WOLF).cancel(23); // Sound variant
|
||||
filter().type(EntityTypes1_21_5.EXPERIENCE_ORB).cancel(8); // Value
|
||||
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public final class EntityPacketRewriter1_21_6 extends EntityRewriter<Clientbound
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
final EntityDataTypes1_21_5 entityDataTypes = VersionedTypes.V1_21_5.entityDataTypes;
|
||||
filter().mapDataType(entityDataTypes::byId);
|
||||
dataTypeMapper().register();
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
entityDataTypes.itemType,
|
||||
entityDataTypes.blockStateType,
|
||||
|
||||
+6
-21
@@ -338,27 +338,12 @@ public final class EntityPacketRewriter1_21_9 extends EntityRewriter<Clientbound
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
final EntityDataTypes1_21_5 entityDataTypes = protocol.mappedTypes().entityDataTypes();
|
||||
filter().handler((event, data) -> {
|
||||
int id = data.dataType().typeId();
|
||||
if (id == VersionedTypes.V1_21_9.entityDataTypes.copperGolemState.typeId()
|
||||
|| id == VersionedTypes.V1_21_9.entityDataTypes.weatheringCopperState.typeId()) {
|
||||
event.cancel();
|
||||
return;
|
||||
}
|
||||
if (id == VersionedTypes.V1_21_9.entityDataTypes.mannequinProfileType.typeId()) {
|
||||
if (event.entityType() == null) {
|
||||
event.cancel();
|
||||
}
|
||||
return; // Handled separately
|
||||
}
|
||||
if (id > VersionedTypes.V1_21_9.entityDataTypes.armadilloState.typeId()) {
|
||||
id -= 2;
|
||||
}
|
||||
if (id >= entityDataTypes.compoundTagType.typeId()) {
|
||||
id++;
|
||||
}
|
||||
data.setDataType(entityDataTypes.byId(id));
|
||||
});
|
||||
dataTypeMapper()
|
||||
.added(entityDataTypes.compoundTagType)
|
||||
.removed(VersionedTypes.V1_21_9.entityDataTypes.copperGolemState)
|
||||
.removed(VersionedTypes.V1_21_9.entityDataTypes.weatheringCopperState)
|
||||
.removed(VersionedTypes.V1_21_9.entityDataTypes.mannequinProfileType)
|
||||
.register();
|
||||
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
entityDataTypes.itemType,
|
||||
|
||||
+20
-20
@@ -29,7 +29,6 @@ import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||
import com.viaversion.viaversion.api.minecraft.WolfVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_20_5;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
@@ -147,26 +146,27 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
final EntityDataTypes1_20_5 mappedEntityDataTypes = VersionedTypes.V1_20_5.entityDataTypes;
|
||||
filter().handler((event, data) -> {
|
||||
final EntityDataType type = data.dataType();
|
||||
if (type == VersionedTypes.V1_21.entityDataTypes.wolfVariantType) {
|
||||
final Holder<WolfVariant> variant = data.value();
|
||||
if (variant.hasId()) {
|
||||
data.setTypeAndValue(mappedEntityDataTypes.wolfVariantType, variant.id());
|
||||
} else {
|
||||
event.cancel();
|
||||
}
|
||||
} else if (type == VersionedTypes.V1_21.entityDataTypes.paintingVariantType) {
|
||||
final Holder<PaintingVariant> variant = data.value();
|
||||
if (variant.hasId()) {
|
||||
final EnchantmentsPaintingsStorage storage = event.user().get(EnchantmentsPaintingsStorage.class);
|
||||
final int mappedId = storage.mappedPainting(variant.id());
|
||||
data.setTypeAndValue(mappedEntityDataTypes.paintingVariantType, mappedId);
|
||||
} else {
|
||||
event.cancel();
|
||||
}
|
||||
dataTypeMapper()
|
||||
.skip(VersionedTypes.V1_21.entityDataTypes.wolfVariantType)
|
||||
.skip(VersionedTypes.V1_21.entityDataTypes.paintingVariantType)
|
||||
.register();
|
||||
|
||||
filter().dataType(VersionedTypes.V1_21.entityDataTypes.wolfVariantType).handler((event, data) -> {
|
||||
final Holder<WolfVariant> variant = data.value();
|
||||
if (variant.hasId()) {
|
||||
data.setTypeAndValue(mappedEntityDataTypes.wolfVariantType, variant.id());
|
||||
} else {
|
||||
data.setDataType(mappedEntityDataTypes.byId(type.typeId()));
|
||||
event.cancel();
|
||||
}
|
||||
});
|
||||
filter().dataType(VersionedTypes.V1_21.entityDataTypes.paintingVariantType).handler((event, data) -> {
|
||||
final Holder<PaintingVariant> variant = data.value();
|
||||
if (variant.hasId()) {
|
||||
final EnchantmentsPaintingsStorage storage = event.user().get(EnchantmentsPaintingsStorage.class);
|
||||
final int mappedId = storage.mappedPainting(variant.id());
|
||||
data.setTypeAndValue(mappedEntityDataTypes.paintingVariantType, mappedId);
|
||||
} else {
|
||||
event.cancel();
|
||||
}
|
||||
});
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
|
||||
+7
-3
@@ -27,6 +27,7 @@ import com.viaversion.viabackwards.protocol.v26_1to1_21_11.rewriter.BlockItemPac
|
||||
import com.viaversion.viabackwards.protocol.v26_1to1_21_11.rewriter.ComponentRewriter26_1;
|
||||
import com.viaversion.viabackwards.protocol.v26_1to1_21_11.rewriter.EntityPacketRewriter26_1;
|
||||
import com.viaversion.viabackwards.protocol.v26_1to1_21_11.storage.DayTimeStorage;
|
||||
import com.viaversion.viabackwards.protocol.v26_1to1_21_11.storage.GameModeStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_21_11;
|
||||
@@ -88,9 +89,11 @@ public final class Protocol26_1To1_21_11 extends BackwardsProtocol<ClientboundPa
|
||||
// Remove new environment attributes
|
||||
registryDataRewriter.addHandler("dimension_type", (key, tag) -> {
|
||||
final CompoundTag attributes = tag.getCompoundTag("attributes");
|
||||
removeNamespaced(attributes, "visual/block_light_tint");
|
||||
removeNamespaced(attributes, "visual/night_vision_color");
|
||||
removeNamespaced(attributes, "visual/ambient_light_color");
|
||||
if (attributes != null) {
|
||||
removeNamespaced(attributes, "visual/block_light_tint");
|
||||
removeNamespaced(attributes, "visual/night_vision_color");
|
||||
removeNamespaced(attributes, "visual/ambient_light_color");
|
||||
}
|
||||
});
|
||||
|
||||
// Move around entity variant names and sounds
|
||||
@@ -168,6 +171,7 @@ public final class Protocol26_1To1_21_11 extends BackwardsProtocol<ClientboundPa
|
||||
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER));
|
||||
addItemHasher(connection, new ItemHasherBase(this, connection));
|
||||
connection.put(new DayTimeStorage());
|
||||
connection.put(new GameModeStorage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+20
-21
@@ -19,6 +19,8 @@ package com.viaversion.viabackwards.protocol.v26_1to1_21_11.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v26_1to1_21_11.Protocol26_1To1_21_11;
|
||||
import com.viaversion.viabackwards.protocol.v26_1to1_21_11.storage.GameModeStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.GameMode;
|
||||
import com.viaversion.viaversion.api.minecraft.Vector3d;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_11;
|
||||
@@ -27,6 +29,7 @@ import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes2
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPackets26_1;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ServerboundPackets26_1;
|
||||
import com.viaversion.viaversion.protocols.v1_21_5to1_21_6.packet.ServerboundPackets1_21_6;
|
||||
|
||||
@@ -42,13 +45,23 @@ public final class EntityPacketRewriter26_1 extends EntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
protocol.appendClientbound(ClientboundPackets26_1.RESPAWN, wrapper -> {
|
||||
final byte gamemode = wrapper.get(Types.BYTE, 0);
|
||||
wrapper.user().get(GameModeStorage.class).setGameMode(gamemode);
|
||||
});
|
||||
protocol.appendClientbound(ClientboundPackets26_1.LOGIN, wrapper -> {
|
||||
final byte gamemode = wrapper.get(Types.BYTE, 0);
|
||||
wrapper.user().get(GameModeStorage.class).setGameMode(gamemode);
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_21_6.INTERACT, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Entity ID
|
||||
final int action = wrapper.read(Types.VAR_INT);
|
||||
switch (action) {
|
||||
case INTERACT_ACTION -> wrapper.cancel(); // Drop "normal" interacts, as interact_at is always sent by Vanilla clients, and always sent first, with this following after
|
||||
case ATTACK_ACTION -> {
|
||||
wrapper.setPacketType(ServerboundPackets26_1.ATTACK);
|
||||
final boolean spectator = wrapper.user().get(GameModeStorage.class).gameMode() == GameMode.SPECTATOR.id();
|
||||
wrapper.setPacketType(spectator ? ServerboundPackets26_1.SPECTATE_ENTITY : ServerboundPackets26_1.ATTACK);
|
||||
wrapper.read(Types.BOOLEAN); // Using secondary action
|
||||
}
|
||||
case INTERACT_AT_ACTION -> {
|
||||
@@ -68,26 +81,12 @@ public final class EntityPacketRewriter26_1 extends EntityRewriter<ClientboundPa
|
||||
protected void registerRewrites() {
|
||||
final EntityDataTypes26_1 entityDataTypes = VersionedTypes.V26_1.entityDataTypes;
|
||||
final EntityDataTypes1_21_11 mappedEntityDataTypes = VersionedTypes.V1_21_11.entityDataTypes;
|
||||
filter().handler((event, data) -> {
|
||||
final int id = data.dataType().typeId();
|
||||
int mappedId = id;
|
||||
if (id == entityDataTypes.catSoundVariant.typeId()
|
||||
|| id == entityDataTypes.cowSoundVariant.typeId()
|
||||
|| id == entityDataTypes.pigSoundVariant.typeId()
|
||||
|| id == entityDataTypes.chickenSoundVariant.typeId()) {
|
||||
event.cancel();
|
||||
return;
|
||||
} else if (id > entityDataTypes.chickenSoundVariant.typeId()) {
|
||||
mappedId -= 4;
|
||||
} else if (id > entityDataTypes.pigSoundVariant.typeId()) {
|
||||
mappedId -= 3;
|
||||
} else if (id > entityDataTypes.cowSoundVariant.typeId()) {
|
||||
mappedId -= 2;
|
||||
} else if (id > entityDataTypes.catSoundVariant.typeId()) {
|
||||
mappedId -= 1;
|
||||
}
|
||||
data.setDataType(mappedEntityDataTypes.byId(mappedId));
|
||||
});
|
||||
dataTypeMapper()
|
||||
.removed(entityDataTypes.catSoundVariant)
|
||||
.removed(entityDataTypes.cowSoundVariant)
|
||||
.removed(entityDataTypes.pigSoundVariant)
|
||||
.removed(entityDataTypes.chickenSoundVariant)
|
||||
.register();
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
mappedEntityDataTypes.itemType,
|
||||
mappedEntityDataTypes.blockStateType,
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v26_1to1_21_11.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public final class GameModeStorage implements StorableObject {
|
||||
|
||||
private int gameMode = -1;
|
||||
|
||||
public int gameMode() {
|
||||
return gameMode;
|
||||
}
|
||||
|
||||
public void setGameMode(final int gameMode) {
|
||||
this.gameMode = gameMode;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
+3
-3
@@ -1,8 +1,8 @@
|
||||
projectVersion=5.9.0-SNAPSHOT
|
||||
projectVersion=5.9.0
|
||||
|
||||
# Smile emoji (note that modrinth may not have added the version on release yet)
|
||||
mcVersions=26.1, 1.21.11, 1.21.10, 1.21.9, 1.21.8, 1.21.7, 1.21.6, 1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 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
|
||||
mcVersionRange=1.10-26.1
|
||||
mcVersions=26.1.2, 26.1.1, 26.1, 1.21.11, 1.21.10, 1.21.9, 1.21.8, 1.21.7, 1.21.6, 1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 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
|
||||
mcVersionRange=1.10-26.1.2
|
||||
velocityVersion=3.4-3.5
|
||||
|
||||
org.gradle.configureondemand=true
|
||||
|
||||
@@ -3,14 +3,14 @@ metadata.format.version = "1.1"
|
||||
[versions]
|
||||
|
||||
# ViaVersion
|
||||
viaver = "5.9.0-SNAPSHOT"
|
||||
viaver = "5.9.0"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
guava = "17.0"
|
||||
log4j = "2.8.1"
|
||||
|
||||
checkerQual = "3.53.1"
|
||||
checkerQual = "3.54.0"
|
||||
|
||||
# Platforms
|
||||
paper = "1.16.5-R0.1-SNAPSHOT"
|
||||
|
||||
Reference in new issue
Block a user