Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-17 13:30:14 +01:00
23w32a
Dieser Commit ist enthalten in:
Ursprung
9df7debb7e
Commit
406733b13a
@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.8.0-23w31a-SNAPSHOT"
|
||||
version = "4.8.0-23w32a-SNAPSHOT"
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.Protocol1_19_
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.Protocol1_19_4To1_20;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_4to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
|
@ -15,13 +15,12 @@
|
||||
* 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.protocol1_20_4to1_20_2;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_20to1_20_2;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_4to1_20_2.rewriter.BlockItemPacketRewriter1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_4to1_20_2.rewriter.EntityPacketRewriter1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_4to1_20_2.storage.ConfigurationPacketStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter.BlockItemPacketRewriter1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter.EntityPacketRewriter1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage.ConfigurationPacketStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||
@ -55,7 +54,6 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol<ClientboundPac
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
;
|
||||
|
||||
registerClientbound(ClientboundPackets1_20_2.SCOREBOARD_OBJECTIVE, wrapper -> {
|
||||
final int slot = wrapper.read(Type.VAR_INT);
|
||||
@ -73,7 +71,6 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol<ClientboundPac
|
||||
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.getId(), ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.getId(), wrapper -> {
|
||||
wrapper.cancel();
|
||||
wrapper.create(ServerboundConfigurationPackets1_20_2.FINISH_CONFIGURATION).sendToServer(Protocol1_20To1_20_2.class);
|
||||
wrapper.user().getProtocolInfo().setState(State.PLAY);
|
||||
wrapper.user().get(ConfigurationPacketStorage.class).setFinished(true);
|
||||
});
|
||||
|
||||
@ -86,6 +83,7 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol<ClientboundPac
|
||||
});
|
||||
|
||||
cancelClientbound(ClientboundPackets1_20_2.START_CONFIGURATION); // TODO Implement switch back
|
||||
cancelClientbound(ClientboundPackets1_20_2.PONG_RESPONSE);
|
||||
|
||||
// Some can be directly remapped to play packets, others need to be queued
|
||||
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.DISCONNECT.getId(), ClientboundPackets1_19_4.DISCONNECT.getId());
|
@ -15,32 +15,83 @@
|
||||
* 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.protocol1_20_4to1_20_2.rewriter;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_4to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viaversion.api.data.ParticleMappings;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter.RecipeRewriter1_19_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.MathUtil;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_19_4, Protocol1_20To1_20_2> {
|
||||
|
||||
private final Object2IntMap<String> effects = new Object2IntOpenHashMap<>();
|
||||
|
||||
public BlockItemPacketRewriter1_20_2(final Protocol1_20To1_20_2 protocol) {
|
||||
super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_VAR_INT_ARRAY);
|
||||
|
||||
final List<String> effects = Arrays.asList(
|
||||
"speed",
|
||||
"slowness",
|
||||
"haste",
|
||||
"mining_fatigue",
|
||||
"strength",
|
||||
"instant_health",
|
||||
"instant_damage",
|
||||
"jump_boost",
|
||||
"nausea",
|
||||
"regeneration",
|
||||
"resistance",
|
||||
"fire_resistance",
|
||||
"water_breathing",
|
||||
"invisibility",
|
||||
"blindness",
|
||||
"night_vision",
|
||||
"hunger",
|
||||
"weakness",
|
||||
"poison",
|
||||
"wither",
|
||||
"health_boost",
|
||||
"absorption",
|
||||
"saturation",
|
||||
"glowing",
|
||||
"levitation",
|
||||
"luck",
|
||||
"unluck",
|
||||
"slow_falling",
|
||||
"conduit_power",
|
||||
"dolphins_grace",
|
||||
"bad_omen",
|
||||
"hero_of_the_village",
|
||||
"darkness"
|
||||
);
|
||||
for (int i = 0; i < effects.size(); i++) {
|
||||
final String effect = effects.get(i);
|
||||
this.effects.put(effect, i + 1); // Effects start at 1 before 1.20.2
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,7 +119,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.BLOCK_ENTITY_DATA, wrapper -> {
|
||||
wrapper.passthrough(Type.POSITION1_14); // Position
|
||||
wrapper.passthrough(Type.VAR_INT); // Type
|
||||
wrapper.write(Type.NBT, wrapper.read(Type.NAMELESS_NBT));
|
||||
wrapper.write(Type.NBT, handleBlockEntity(wrapper.read(Type.NAMELESS_NBT)));
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.CHUNK_DATA, wrapper -> {
|
||||
@ -82,6 +133,17 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
|
||||
MathUtil.ceilLog2(Protocol1_20To1_19_4.MAPPINGS.getBlockStateMappings().mappedSize()),
|
||||
MathUtil.ceilLog2(tracker.biomesSent()));
|
||||
wrapper.write(newChunkType, chunk);
|
||||
|
||||
for (final BlockEntity blockEntity : chunk.blockEntities()) {
|
||||
handleBlockEntity(blockEntity.tag());
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_19_4.SET_BEACON_EFFECT, wrapper -> {
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
// Effects start at 1 before 1.20.2
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT) - 1);
|
||||
}
|
||||
});
|
||||
|
||||
// Replace the NBT type everywhere
|
||||
@ -305,4 +367,23 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
|
||||
}
|
||||
}.register(ClientboundPackets1_20_2.DECLARE_RECIPES);
|
||||
}
|
||||
|
||||
private @Nullable CompoundTag handleBlockEntity(@Nullable final CompoundTag tag) {
|
||||
if (tag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final StringTag primaryEffect = tag.remove("primary_effect");
|
||||
if (primaryEffect != null) {
|
||||
final String effectKey = Key.stripMinecraftNamespace(primaryEffect.getValue());
|
||||
tag.put("Primary", new IntTag(effects.getInt(effectKey)));
|
||||
}
|
||||
|
||||
final StringTag secondaryEffect = tag.remove("secondary_effect");
|
||||
if (secondaryEffect != null) {
|
||||
final String effectKey = Key.stripMinecraftNamespace(secondaryEffect.getValue());
|
||||
tag.put("Secondary", new IntTag(effects.getInt(effectKey)));
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
@ -15,11 +15,11 @@
|
||||
* 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.protocol1_20_4to1_20_2.rewriter;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_4to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_4to1_20_2.storage.ConfigurationPacketStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage.ConfigurationPacketStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.GlobalPosition;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
@ -43,6 +43,15 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
|
||||
registerMetadataRewriter(ClientboundPackets1_20_2.ENTITY_METADATA, Types1_20_2.METADATA_LIST, Types1_20.METADATA_LIST);
|
||||
registerRemoveEntities(ClientboundPackets1_20_2.REMOVE_ENTITIES);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.REMOVE_ENTITY_EFFECT, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT); // Entity id
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT) + 1); // Effect id
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.ENTITY_EFFECT, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT); // Entity id
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT) + 1); // Effect id
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
@ -15,10 +15,10 @@
|
||||
* 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.protocol1_20_4to1_20_2.storage;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_4to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
||||
[versions]
|
||||
|
||||
# ViaVersion
|
||||
viaver = "4.8.0-23w31a-SNAPSHOT"
|
||||
viaver = "4.8.0-23w32a-SNAPSHOT"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren