Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Update template protocol
Dieser Commit ist enthalten in:
Ursprung
e0f32d9f2f
Commit
d76edced04
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.viaversion.rewriter;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public class AttributeRewriter<C extends ClientboundPacketType> {
|
||||
private final Protocol<C, ?, ?, ?> protocol;
|
||||
|
||||
public AttributeRewriter(Protocol<C, ?, ?, ?> protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public void register1_20_5(C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT); // Entity ID
|
||||
|
||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final int attributeId = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewAttributeId(attributeId));
|
||||
|
||||
wrapper.passthrough(Type.DOUBLE); // Base
|
||||
final int modifierSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < modifierSize; j++) {
|
||||
wrapper.passthrough(Type.UUID); // ID
|
||||
wrapper.passthrough(Type.DOUBLE); // Amount
|
||||
wrapper.passthrough(Type.BYTE); // Operation
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.Clientb
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPacket1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPacket1_20_5;
|
||||
import com.viaversion.viaversion.rewriter.AttributeRewriter;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
@ -56,18 +57,16 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
// Registers renames etc. as well as registry type id changes
|
||||
final TagRewriter<ClientboundPacket1_20_5> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_20_5.TAGS);
|
||||
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_5.UPDATE_TAGS);
|
||||
|
||||
// Registers sound id changes
|
||||
final SoundRewriter<ClientboundPacket1_20_5> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.register1_19_3Sound(ClientboundPackets1_20_5.SOUND);
|
||||
soundRewriter.register1_19_3Sound(ClientboundPackets1_20_5.ENTITY_SOUND);
|
||||
|
||||
// Registers registry type id changes as well as stat id changes if also included in the json mappings
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.STATISTICS);
|
||||
new AttributeRewriter<>(this).register1_20_5(ClientboundPackets1_20_5.ENTITY_PROPERTIES);
|
||||
|
||||
// Uncomment if an existing type changed serialization format. Mappings for argument type keys can also be defined in mapping files
|
||||
/*final CommandRewriter1_19_4<ClientboundPackets1_20_5> commandRewriter = new CommandRewriter1_19_4<ClientboundPackets1_20_5>(this) {
|
||||
@ -82,7 +81,6 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
||||
}
|
||||
}.registerDeclareCommands1_19(ClientboundPackets1_20_5.DECLARE_COMMANDS);*/
|
||||
|
||||
// TODO Attributes
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.template.protocols.rewriter;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.RecipeRewriter1_20_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPacket1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5;
|
||||
@ -63,10 +63,10 @@ public final class BlockItemPacketRewriter1_99 extends ItemRewriter<ClientboundP
|
||||
registerTradeList1_20_5(ClientboundPackets1_20_5.TRADE_LIST);
|
||||
registerCreativeInvAction(ServerboundPackets1_20_5.CREATIVE_INVENTORY_ACTION);
|
||||
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_5.WINDOW_PROPERTY);
|
||||
registerSpawnParticle1_20_5(ClientboundPackets1_20_5.SPAWN_PARTICLE, Types1_20_3.PARTICLE, Types1_20_3.PARTICLE);
|
||||
registerExplosion(ClientboundPackets1_20_5.EXPLOSION, Types1_20_3.PARTICLE, Types1_20_3.PARTICLE); // Rewrites the included sound and particles
|
||||
registerSpawnParticle1_20_5(ClientboundPackets1_20_5.SPAWN_PARTICLE, Types1_20_5.PARTICLE, Types1_20_5.PARTICLE);
|
||||
registerExplosion(ClientboundPackets1_20_5.EXPLOSION, Types1_20_5.PARTICLE, Types1_20_5.PARTICLE); // Rewrites the included sound and particles
|
||||
|
||||
new RecipeRewriter1_20_3<>(protocol).register(ClientboundPackets1_20_5.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.DECLARE_RECIPES);
|
||||
// OR do this if serialization of recipes changed and override the relevant method
|
||||
// Add new serializers to RecipeRewriter, or extend the last one for changes
|
||||
// new RecipeRewriter1_20_3<ClientboundPackets1_20_5>(this) {}.register1_20_5(ClientboundPackets1_20_5.DECLARE_RECIPES);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren