mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2025-01-22 21:51:33 +01:00
Use packet type constants for automated channel mapping
This commit is contained in:
parent
d334a202e7
commit
5ff7767353
@ -1,43 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
|
||||
|
||||
public abstract class BackwardsProtocol extends Protocol {
|
||||
public abstract class BackwardsProtocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType>
|
||||
extends Protocol<C1, C2, S1, S2> {
|
||||
|
||||
protected BackwardsProtocol() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected BackwardsProtocol(boolean hasMappingDataToLoad) {
|
||||
super(hasMappingDataToLoad);
|
||||
}
|
||||
|
||||
public void out(State state, int oldPacketID, int newPacketID) {
|
||||
this.registerOutgoing(state, oldPacketID, newPacketID, null);
|
||||
protected BackwardsProtocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
|
||||
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, false);
|
||||
}
|
||||
|
||||
public void out(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
||||
this.registerOutgoing(state, oldPacketID, newPacketID, packetRemapper);
|
||||
}
|
||||
|
||||
public void in(State state, int oldPacketID, int newPacketID) {
|
||||
this.registerIncoming(state, oldPacketID, newPacketID, null);
|
||||
}
|
||||
|
||||
public void in(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
||||
this.registerIncoming(state, oldPacketID, newPacketID, packetRemapper);
|
||||
protected BackwardsProtocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum, boolean hasMappingDatatToLoad) {
|
||||
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, hasMappingDatatToLoad);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package nl.matsv.viabackwards.api.data;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
public class MappedLegacyBlockItem {
|
||||
@ -12,7 +13,7 @@ public class MappedLegacyBlockItem {
|
||||
private final Block block;
|
||||
private BlockEntityHandler blockEntityHandler;
|
||||
|
||||
public MappedLegacyBlockItem(int id, short data, String name, boolean block) {
|
||||
public MappedLegacyBlockItem(int id, short data, @Nullable String name, boolean block) {
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
this.name = name != null ? ChatColor.RESET + name : null;
|
||||
@ -43,11 +44,12 @@ public class MappedLegacyBlockItem {
|
||||
return blockEntityHandler != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockEntityHandler getBlockEntityHandler() {
|
||||
return blockEntityHandler;
|
||||
}
|
||||
|
||||
public void setBlockEntityHandler(BlockEntityHandler blockEntityHandler) {
|
||||
public void setBlockEntityHandler(@Nullable BlockEntityHandler blockEntityHandler) {
|
||||
this.blockEntityHandler = blockEntityHandler;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nl.matsv.viabackwards.api.data;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.data.Mappings;
|
||||
import us.myles.viaversion.libs.gson.JsonArray;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
@ -31,6 +32,7 @@ public class VBSoundMappings {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNewId(String oldId) {
|
||||
return namedSoundMappings.get(oldId);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ package nl.matsv.viabackwards.api.entities.meta;
|
||||
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
|
||||
@ -78,6 +79,7 @@ public class MetaHandlerEvent {
|
||||
/**
|
||||
* May be null, use {@link #createMeta(Metadata)} for adding metadata.
|
||||
*/
|
||||
@Nullable
|
||||
public List<Metadata> getExtraData() {
|
||||
return extraData;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
package nl.matsv.viabackwards.api.entities.meta;
|
||||
|
||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
|
||||
@ -43,7 +44,7 @@ public class MetaHandlerSettings {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void handle(MetaHandler handler) {
|
||||
public void handle(@Nullable MetaHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@ -100,6 +101,7 @@ public class MetaHandlerSettings {
|
||||
return filterIndex;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MetaHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
package nl.matsv.viabackwards.api.entities.storage;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
|
||||
public class EntityData {
|
||||
@ -46,6 +47,7 @@ public class EntityData {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMobName() {
|
||||
return mobName;
|
||||
}
|
||||
@ -54,6 +56,7 @@ public class EntityData {
|
||||
return replacementId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MetaCreator getDefaultMeta() {
|
||||
return defaultMeta;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
package nl.matsv.viabackwards.api.entities.storage;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
@ -29,6 +30,7 @@ public class EntityTracker extends StoredObject {
|
||||
trackers.put(protocol, new ProtocolEntityTracker());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ProtocolEntityTracker get(BackwardsProtocol protocol) {
|
||||
return trackers.get(protocol);
|
||||
}
|
||||
@ -44,11 +46,13 @@ public class EntityTracker extends StoredObject {
|
||||
entityMap.remove(id);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityType getEntityType(int id) {
|
||||
StoredEntity storedEntity = entityMap.get(id);
|
||||
return storedEntity != null ? storedEntity.getType() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public StoredEntity getEntity(int id) {
|
||||
return entityMap.get(id);
|
||||
}
|
||||
@ -71,6 +75,7 @@ public class EntityTracker extends StoredObject {
|
||||
* @param <T> The type of the class you want to get.
|
||||
* @return The requested object
|
||||
*/
|
||||
@Nullable
|
||||
public <T extends EntityStorage> T get(Class<T> objectClass) {
|
||||
return (T) storedObjects.get(objectClass);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
package nl.matsv.viabackwards.api.entities.storage;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
|
||||
import java.util.List;
|
||||
@ -37,6 +38,7 @@ public class MetaStorage {
|
||||
this.metaDataList.add(data);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Metadata get(int index) {
|
||||
for (Metadata meta : this.metaDataList) {
|
||||
if (index == meta.getId()) {
|
||||
|
@ -8,10 +8,10 @@ import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -25,8 +25,8 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
|
||||
super(protocol, displayType, 2);
|
||||
}
|
||||
|
||||
public void registerSpawnTrackerWithData(int oldPacketId, int newPacketId, EntityType fallingBlockType, IdRewriteFunction blockStateRewriter) {
|
||||
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
|
||||
public void registerSpawnTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType, IdRewriteFunction blockStateRewriter) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -49,8 +49,8 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
|
||||
});
|
||||
}
|
||||
|
||||
public void registerSpawnTracker(int oldPacketId, int newPacketId) {
|
||||
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
|
||||
public void registerSpawnTracker(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -77,8 +77,8 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
|
||||
/**
|
||||
* Helper method to handle a metadata list packet and its full initial meta rewrite.
|
||||
*/
|
||||
protected void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
|
||||
protected void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -108,7 +108,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> metaType) {
|
||||
registerMetadataRewriter(oldPacketId, newPacketId, null, metaType);
|
||||
protected void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> metaType) {
|
||||
registerMetadataRewriter(packetType, null, metaType);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@ -16,11 +17,11 @@ import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.exception.CancelException;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -66,6 +67,7 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
return entityTypes.containsKey(type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected EntityData getEntityData(EntityType type) {
|
||||
return entityTypes.get(type);
|
||||
}
|
||||
@ -192,8 +194,8 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
return storage;
|
||||
}
|
||||
|
||||
public void registerRespawn(int oldPacketId, int newPacketId) {
|
||||
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
|
||||
public void registerRespawn(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
@ -205,8 +207,8 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
});
|
||||
}
|
||||
|
||||
public void registerJoinGame(int oldPacketId, int newPacketId, EntityType playerType) {
|
||||
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
|
||||
public void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
@ -224,8 +226,8 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
/**
|
||||
* Helper method to handle player, painting, or xp orb trackers without meta changes.
|
||||
*/
|
||||
protected void registerExtraTracker(int oldId, int newId, EntityType entityType, Type intType) {
|
||||
getProtocol().registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
protected void registerExtraTracker(ClientboundPacketType packetType, EntityType entityType, Type intType) {
|
||||
getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(intType); // 0 - Entity id
|
||||
@ -234,20 +236,12 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerExtraTracker(int packetId, EntityType entityType, Type intType) {
|
||||
registerExtraTracker(packetId, packetId, entityType, intType);
|
||||
protected void registerExtraTracker(ClientboundPacketType packetType, EntityType entityType) {
|
||||
registerExtraTracker(packetType, entityType, Type.VAR_INT);
|
||||
}
|
||||
|
||||
protected void registerExtraTracker(int oldId, int newId, EntityType entityType) {
|
||||
registerExtraTracker(oldId, newId, entityType, Type.VAR_INT);
|
||||
}
|
||||
|
||||
protected void registerExtraTracker(int packetId, EntityType entityType) {
|
||||
registerExtraTracker(packetId, entityType, Type.VAR_INT);
|
||||
}
|
||||
|
||||
protected void registerEntityDestroy(int oldPacketId, int newPacketId) {
|
||||
getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
|
||||
protected void registerEntityDestroy(ClientboundPacketType packetType) {
|
||||
getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entity ids
|
||||
@ -261,10 +255,6 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerEntityDestroy(int packetId) {
|
||||
registerEntityDestroy(packetId, packetId);
|
||||
}
|
||||
|
||||
// ONLY TRACKS, DOESN'T REWRITE IDS
|
||||
protected PacketHandler getTrackerHandler(Type intType, int typeIndex) {
|
||||
return wrapper -> {
|
||||
|
@ -2,6 +2,7 @@ package nl.matsv.viabackwards.api.rewriters;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.MappedItem;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
@ -14,19 +15,21 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
private final MappedItemFunction mappedItemFunction;
|
||||
private final TranslatableRewriter translatableRewriter;
|
||||
|
||||
protected ItemRewriter(T protocol, TranslatableRewriter translatableRewriter, IdRewriteFunction oldRewriter, IdRewriteFunction newRewriter, MappedItemFunction mappedItemFunction) {
|
||||
protected ItemRewriter(T protocol, @Nullable TranslatableRewriter translatableRewriter,
|
||||
@Nullable IdRewriteFunction oldRewriter, @Nullable IdRewriteFunction newRewriter, MappedItemFunction mappedItemFunction) {
|
||||
super(protocol, oldRewriter, newRewriter, true);
|
||||
this.translatableRewriter = translatableRewriter;
|
||||
this.mappedItemFunction = mappedItemFunction;
|
||||
}
|
||||
|
||||
protected ItemRewriter(T protocol, TranslatableRewriter translatableRewriter, MappedItemFunction mappedItemFunction) {
|
||||
protected ItemRewriter(T protocol, @Nullable TranslatableRewriter translatableRewriter, MappedItemFunction mappedItemFunction) {
|
||||
super(protocol, true);
|
||||
this.translatableRewriter = translatableRewriter;
|
||||
this.mappedItemFunction = mappedItemFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
@ -94,6 +97,7 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
@FunctionalInterface
|
||||
public interface MappedItemFunction {
|
||||
|
||||
@Nullable
|
||||
MappedItem get(int id);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package nl.matsv.viabackwards.api.rewriters;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.viaversion.libs.opennbt.conversion.builtin.CompoundTagConverter;
|
||||
@ -17,7 +18,7 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
|
||||
protected final String nbtTagName;
|
||||
protected final boolean jsonNameFormat;
|
||||
|
||||
protected ItemRewriterBase(T protocol, IdRewriteFunction toClientRewriter, IdRewriteFunction toServerRewriter, boolean jsonNameFormat) {
|
||||
protected ItemRewriterBase(T protocol, @Nullable IdRewriteFunction toClientRewriter, @Nullable IdRewriteFunction toServerRewriter, boolean jsonNameFormat) {
|
||||
super(protocol);
|
||||
this.toClientRewriter = toClientRewriter;
|
||||
this.toServerRewriter = toServerRewriter;
|
||||
@ -29,6 +30,7 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
|
||||
this(protocol, null, null, jsonNameFormat);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
if (toClientRewriter != null) {
|
||||
@ -37,6 +39,7 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
|
||||
return item;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
|
@ -16,6 +16,7 @@ import nl.matsv.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -75,7 +76,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
}
|
||||
}
|
||||
|
||||
protected LegacyBlockItemRewriter(T protocol, IdRewriteFunction oldRewriter, IdRewriteFunction newRewriter) {
|
||||
protected LegacyBlockItemRewriter(T protocol, @Nullable IdRewriteFunction oldRewriter, @Nullable IdRewriteFunction newRewriter) {
|
||||
super(protocol, oldRewriter, newRewriter, false);
|
||||
replacementData = LEGACY_MAPPINGS.get(protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
@ -85,6 +86,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
@ -138,6 +140,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
return (b.getId() << 4 | (b.getData() & 15));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Block handleBlock(int blockId, int data) {
|
||||
MappedLegacyBlockItem settings = replacementData.get(blockId);
|
||||
if (settings == null || !settings.isBlock()) return null;
|
||||
|
@ -10,7 +10,7 @@ public class LegacyEnchantmentRewriter {
|
||||
private final String nbtTagName;
|
||||
private Set<Short> hideLevelForEnchants;
|
||||
|
||||
public LegacyEnchantmentRewriter(final String nbtTagName) {
|
||||
public LegacyEnchantmentRewriter(String nbtTagName) {
|
||||
this.nbtTagName = nbtTagName;
|
||||
}
|
||||
|
||||
|
@ -5,14 +5,15 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityObjectData;
|
||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.ObjectType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -36,12 +37,13 @@ public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends
|
||||
return entData;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected EntityData getObjectData(ObjectType type) {
|
||||
return objectTypes.get(type);
|
||||
}
|
||||
|
||||
protected void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
|
||||
protected void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -59,8 +61,8 @@ public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> metaType) {
|
||||
registerMetadataRewriter(oldPacketId, newPacketId, null, metaType);
|
||||
protected void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> metaType) {
|
||||
registerMetadataRewriter(packetType, null, metaType);
|
||||
}
|
||||
|
||||
protected PacketHandler getMobSpawnRewriter(Type<List<Metadata>> metaType) {
|
||||
|
@ -1,22 +1,22 @@
|
||||
package nl.matsv.viabackwards.api.rewriters;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public abstract class RecipeRewriter {
|
||||
|
||||
protected final ItemRewriterBase rewriter;
|
||||
|
||||
protected RecipeRewriter(final ItemRewriterBase rewriter) {
|
||||
protected RecipeRewriter(ItemRewriterBase rewriter) {
|
||||
this.rewriter = rewriter;
|
||||
}
|
||||
|
||||
public abstract void handle(PacketWrapper wrapper, String type) throws Exception;
|
||||
|
||||
public void registerDefaultHandler(int oldId, int newId) {
|
||||
rewriter.getProtocol().registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerDefaultHandler(ClientboundPacketType packetType) {
|
||||
rewriter.getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package nl.matsv.viabackwards.api.rewriters;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -21,8 +21,8 @@ public class SoundRewriter extends us.myles.ViaVersion.api.rewriters.SoundRewrit
|
||||
this(protocol, idRewriter, null);
|
||||
}
|
||||
|
||||
public void registerNamedSound(int oldId, int newId) {
|
||||
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerNamedSound(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // Sound identifier
|
||||
@ -40,8 +40,8 @@ public class SoundRewriter extends us.myles.ViaVersion.api.rewriters.SoundRewrit
|
||||
});
|
||||
}
|
||||
|
||||
public void registerStopSound(int oldId, int newId) {
|
||||
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerStopSound(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
|
@ -3,6 +3,7 @@ package nl.matsv.viabackwards.api.rewriters;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
@ -46,7 +47,7 @@ public class TranslatableRewriter {
|
||||
}
|
||||
|
||||
public void registerPing() {
|
||||
protocol.out(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
@ -54,8 +55,8 @@ public class TranslatableRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerDisconnect(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerDisconnect(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
@ -63,8 +64,8 @@ public class TranslatableRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerChatMessage(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerChatMessage(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
@ -72,8 +73,8 @@ public class TranslatableRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerBossBar(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerBossBar(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UUID);
|
||||
@ -88,8 +89,8 @@ public class TranslatableRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerLegacyOpenWindow(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerLegacyOpenWindow(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
@ -99,8 +100,8 @@ public class TranslatableRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerOpenWindow(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerOpenWindow(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Id
|
||||
@ -110,8 +111,8 @@ public class TranslatableRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatEvent(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerCombatEvent(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@ -125,8 +126,8 @@ public class TranslatableRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTitle(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerTitle(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@ -139,8 +140,8 @@ public class TranslatableRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerPlayerList(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
public void registerTabList(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
|
@ -18,12 +18,19 @@ import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.SoundPackets1_11;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_10To1_11 extends BackwardsProtocol {
|
||||
public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
private EntityPackets1_11 entityPackets; // Required for the item rewriter
|
||||
private BlockItemPackets1_11 blockItemPackets;
|
||||
|
||||
public Protocol1_10To1_11() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
(entityPackets = new EntityPackets1_11(this)).register();
|
||||
@ -35,15 +42,18 @@ public class Protocol1_10To1_11 extends BackwardsProtocol {
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class))
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
|
||||
if (!user.has(WindowTracker.class))
|
||||
if (!user.has(WindowTracker.class)) {
|
||||
user.put(new WindowTracker(user));
|
||||
}
|
||||
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
@ -29,9 +29,10 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
@ -53,8 +54,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
|
||||
// Set slot packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x16, 0x16, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
@ -81,8 +81,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
// Window items packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x14, 0x14, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
@ -113,11 +112,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
itemRewriter.registerEntityEquipment(Type.ITEM, 0x3C, 0x3C);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
@ -134,8 +132,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem)
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
@ -147,113 +146,102 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
// Click window packet
|
||||
protocol.registerIncoming(State.PLAY, 0x07, 0x07, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
|
||||
handler(itemRewriter.itemToServerHandler(Type.ITEM));
|
||||
|
||||
// Llama slot
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
return;
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
int clickSlot = wrapper.get(Type.SHORT, 0);
|
||||
int correctSlot = getOldSlotId(storage, clickSlot);
|
||||
|
||||
handler(itemRewriter.itemToServerHandler(Type.ITEM));
|
||||
|
||||
// Llama slot
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
return;
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
int clickSlot = wrapper.get(Type.SHORT, 0);
|
||||
int correctSlot = getOldSlotId(storage, clickSlot);
|
||||
|
||||
wrapper.set(Type.SHORT, 0, ((Integer) correctSlot).shortValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
wrapper.set(Type.SHORT, 0, ((Integer) correctSlot).shortValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Creative Inventory Action
|
||||
itemRewriter.registerCreativeInvAction(Type.ITEM, 0x18, 0x18);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
/* Block packets */
|
||||
// Chunk packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
handleChunk(chunk);
|
||||
|
||||
// only patch it for signs for now, TODO-> Find all the block entities old/new to replace ids and implement in ViaVersion
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag idTag = tag.get("id");
|
||||
if (!(idTag instanceof StringTag)) continue;
|
||||
// only patch it for signs for now, TODO-> Find all the block entities old/new to replace ids and implement in ViaVersion
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag idTag = tag.get("id");
|
||||
if (!(idTag instanceof StringTag)) continue;
|
||||
|
||||
String id = (String) idTag.getValue();
|
||||
if (id.equals("minecraft:sign")) {
|
||||
((StringTag) idTag).setValue("Sign");
|
||||
}
|
||||
}
|
||||
String id = (String) idTag.getValue();
|
||||
if (id.equals("minecraft:sign")) {
|
||||
((StringTag) idTag).setValue("Sign");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
});
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x10, 0x10, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Update Block Entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
@ -277,8 +265,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
// Open window packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x13, 0x13, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
@ -308,8 +295,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
// Close Window Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x12, 0x12, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
// Inventory tracking
|
||||
@ -325,8 +311,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
});
|
||||
|
||||
|
||||
// Close Window Incoming Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
// Inventory tracking
|
||||
|
@ -28,7 +28,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -40,7 +40,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerOutgoing(State.PLAY, 0x21, 0x21, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
@ -63,8 +63,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Object
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -102,14 +101,10 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
registerExtraTracker(0x01, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
// Spawn Global Entity
|
||||
registerExtraTracker(0x02, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
// Spawn Mob
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -162,17 +157,11 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Painting
|
||||
registerExtraTracker(0x04, Entity1_11Types.EntityType.PAINTING);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
// Join game
|
||||
registerJoinGame(0x23, 0x23, Entity1_11Types.EntityType.PLAYER);
|
||||
|
||||
// Respawn Packet
|
||||
registerRespawn(0x33, 0x33);
|
||||
|
||||
// Spawn Player
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -188,14 +177,10 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
registerEntityDestroy(0x30);
|
||||
registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||
|
||||
// Metadata packet
|
||||
registerMetadataRewriter(0x39, 0x39, Types1_9.METADATA_LIST);
|
||||
|
||||
// Entity Status
|
||||
protocol.registerOutgoing(State.PLAY, 0x1B, 0x1B, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.ENTITY_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
|
@ -16,11 +16,12 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
|
||||
public class PlayerPackets1_11 {
|
||||
private static final ValueTransformer<Short, Float> toNewFloat = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@Override
|
||||
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
|
||||
return inputValue / 15f;
|
||||
@ -28,10 +29,7 @@ public class PlayerPackets1_11 {
|
||||
};
|
||||
|
||||
public void register(Protocol1_10To1_11 protocol) {
|
||||
/* Outgoing packets */
|
||||
|
||||
// Title packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x45, 0x45, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Action
|
||||
@ -57,44 +55,35 @@ public class PlayerPackets1_11 {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action > 2)
|
||||
if (action > 2) {
|
||||
wrapper.set(Type.VAR_INT, 0, action - 1); // Move everything one position down
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// Collect item packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x48, 0x48, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Collected entity id
|
||||
map(Type.VAR_INT); // 1 - Collector entity id
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
packetWrapper.read(Type.VAR_INT); // Ignore pickup item count
|
||||
}
|
||||
});
|
||||
handler(wrapper -> wrapper.read(Type.VAR_INT)); // Ignore item pickup count
|
||||
}
|
||||
});
|
||||
|
||||
/* Incoming packets */
|
||||
|
||||
// Block placement packet
|
||||
protocol.registerIncoming(State.PLAY, 0x1C, 0x1C, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Location
|
||||
map(Type.VAR_INT); // 1 - Face
|
||||
map(Type.VAR_INT); // 2 - Hand
|
||||
|
||||
map(Type.UNSIGNED_BYTE, toNewFloat);
|
||||
map(Type.UNSIGNED_BYTE, toNewFloat);
|
||||
map(Type.UNSIGNED_BYTE, toNewFloat);
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
public class SoundPackets1_11 extends LegacySoundRewriter<Protocol1_10To1_11> {
|
||||
|
||||
@ -26,8 +26,7 @@ public class SoundPackets1_11 extends LegacySoundRewriter<Protocol1_10To1_11> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Named sound effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Sound name
|
||||
@ -40,8 +39,7 @@ public class SoundPackets1_11 extends LegacySoundRewriter<Protocol1_10To1_11> {
|
||||
}
|
||||
});
|
||||
|
||||
// Sound effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Sound name
|
||||
|
@ -13,32 +13,49 @@ package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.*;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.BlockItemPackets1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPackets1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol {
|
||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {
|
||||
|
||||
private EntityPackets1_12 entityPackets;
|
||||
private BlockItemPackets1_12 blockItemPackets;
|
||||
|
||||
public Protocol1_11_1To1_12() {
|
||||
super(ClientboundPackets1_12.class, ClientboundPackets1_9_3.class, ServerboundPackets1_12.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
new ChangedPacketIds1_12(this).register();
|
||||
(entityPackets = new EntityPackets1_12(this)).register();
|
||||
(blockItemPackets = new BlockItemPackets1_12(this)).register();
|
||||
new SoundPackets1_12(this).register();
|
||||
new ChatPackets1_12(this).register();
|
||||
|
||||
cancelOutgoing(ClientboundPackets1_12.ADVANCEMENTS);
|
||||
cancelOutgoing(ClientboundPackets1_12.UNLOCK_RECIPES);
|
||||
cancelOutgoing(ClientboundPackets1_12.SELECT_ADVANCEMENTS_TAB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class))
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
|
||||
user.put(new ShoulderTracker(user));
|
||||
|
||||
|
@ -22,8 +22,9 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1To1_12> {
|
||||
@ -34,7 +35,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -54,6 +55,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
short columns = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
if (columns <= 0) return;
|
||||
|
||||
short rows = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.passthrough(Type.BYTE); //X
|
||||
wrapper.passthrough(Type.BYTE); //Z
|
||||
@ -73,17 +75,12 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
|
||||
// Set slot packet
|
||||
itemRewriter.registerSetSlot(Type.ITEM, 0x16, 0x16);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.ITEM_ARRAY, 0x14, 0x14);
|
||||
|
||||
// Entity Equipment Packet
|
||||
itemRewriter.registerEntityEquipment(Type.ITEM, 0x3E, 0x3C);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
@ -113,53 +110,48 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
// Click window packet
|
||||
protocol.registerIncoming(State.PLAY, 0x08, 0x07, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click
|
||||
// https://github.com/ViaVersion/ViaVersion/pull/754
|
||||
// Previously clients grab the item from the clicked slot *before* it has
|
||||
// been moved however now they grab the slot item *after* it has been moved
|
||||
// and send that in the packet.
|
||||
wrapper.set(Type.ITEM, 0, null); // Set null item (probably will work)
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click
|
||||
// https://github.com/ViaVersion/ViaVersion/pull/754
|
||||
// Previously clients grab the item from the clicked slot *before* it has
|
||||
// been moved however now they grab the slot item *after* it has been moved
|
||||
// and send that in the packet.
|
||||
wrapper.set(Type.ITEM, 0, null); // Set null item (probably will work)
|
||||
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||
PacketWrapper confirm = wrapper.create(0x6);
|
||||
confirm.write(Type.BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue());
|
||||
confirm.write(Type.SHORT, wrapper.get(Type.SHORT, 1));
|
||||
confirm.write(Type.BOOLEAN, false); // Success - not used
|
||||
|
||||
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||
PacketWrapper confirm = wrapper.create(0x6);
|
||||
confirm.write(Type.BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue());
|
||||
confirm.write(Type.SHORT, wrapper.get(Type.SHORT, 1));
|
||||
confirm.write(Type.BOOLEAN, false); // Success - not used
|
||||
wrapper.sendToServer(Protocol1_11_1To1_12.class, true, true);
|
||||
wrapper.cancel();
|
||||
confirm.sendToServer(Protocol1_11_1To1_12.class, true, true);
|
||||
return;
|
||||
|
||||
wrapper.sendToServer(Protocol1_11_1To1_12.class, true, true);
|
||||
wrapper.cancel();
|
||||
confirm.sendToServer(Protocol1_11_1To1_12.class, true, true);
|
||||
return;
|
||||
}
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
handleItemToServer(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
handleItemToServer(item);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Creative Inventory Action
|
||||
itemRewriter.registerCreativeInvAction(Type.ITEM, 0x1B, 0x18);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
/* Block packets */
|
||||
|
||||
// Chunk packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -176,8 +168,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
@ -193,8 +184,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x10, 0x10, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
@ -212,8 +202,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
// Update Block Entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
@ -240,8 +229,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
return data;
|
||||
});
|
||||
|
||||
// Client Status
|
||||
protocol.registerIncoming(State.PLAY, 0x04, 0x03, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.CLIENT_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Action ID
|
||||
@ -250,8 +238,9 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Open Inventory
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 2)
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 2) {
|
||||
wrapper.cancel(); // TODO is this replaced by something else?
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class ChangedPacketIds1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
public ChangedPacketIds1_12(Protocol1_11_1To1_12 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x28); // Entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x26, 0x25); // Entity Relative Move
|
||||
protocol.registerOutgoing(State.PLAY, 0x27, 0x26); // Entity Look and Relative Move
|
||||
protocol.registerOutgoing(State.PLAY, 0x28, 0x27); // Entity Look
|
||||
|
||||
protocol.cancelOutgoing(State.PLAY, 0x30); // Unlock Recipes
|
||||
|
||||
// 0x31 -> 0x30 Destroy Entities handled in EntityPackets1_12.java
|
||||
protocol.registerOutgoing(State.PLAY, 0x32, 0x31); // Remove Entity Effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x33, 0x32); // Resource Pack Send
|
||||
// 0x34 -> 0x33 Respawn handled in EntityPackets1_12.java
|
||||
protocol.registerOutgoing(State.PLAY, 0x35, 0x34); // Entity Head Look
|
||||
|
||||
protocol.cancelOutgoing(State.PLAY, 0x36); // Advancement Progress
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x37, 0x35); // World Border
|
||||
protocol.registerOutgoing(State.PLAY, 0x38, 0x36); //Camera
|
||||
protocol.registerOutgoing(State.PLAY, 0x39, 0x37); // Held Item Change (ClientBound)
|
||||
protocol.registerOutgoing(State.PLAY, 0x3A, 0x38); // Display Scoreboard
|
||||
// 0x3B -> 0x39 Entity Metadata handled in EntityPackets1_12.java
|
||||
protocol.registerOutgoing(State.PLAY, 0x3C, 0x3A); // Attach Entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x3D, 0x3B); // Entity Velocity
|
||||
// 0x3E -> 0x3C Entity Equipment handled in BlockItemPackets1_12.java
|
||||
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3D); // Set Experience
|
||||
protocol.registerOutgoing(State.PLAY, 0x40, 0x3E); // Update Health
|
||||
protocol.registerOutgoing(State.PLAY, 0x41, 0x3F); // ScoreBoard Objective
|
||||
protocol.registerOutgoing(State.PLAY, 0x42, 0x40); // Set Passengers
|
||||
protocol.registerOutgoing(State.PLAY, 0x43, 0x41); // Teams
|
||||
protocol.registerOutgoing(State.PLAY, 0x44, 0x42); // Update Score
|
||||
protocol.registerOutgoing(State.PLAY, 0x45, 0x43); // Spawn Position
|
||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x44); // Time Update
|
||||
protocol.registerOutgoing(State.PLAY, 0x47, 0x45); // Title
|
||||
// 0x48 -> 0x46 Sound Effect handled in SoundPackets1_12.java
|
||||
protocol.registerOutgoing(State.PLAY, 0x49, 0x47); // Player List Header And Footer
|
||||
protocol.registerOutgoing(State.PLAY, 0x4A, 0x48); // Collect Item
|
||||
protocol.registerOutgoing(State.PLAY, 0x4B, 0x49); // Entity Teleport
|
||||
|
||||
protocol.cancelOutgoing(State.PLAY, 0x4C); // Advancements
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x4E, 0x4B); // Entity Effect
|
||||
|
||||
// New incoming packet 0x01 - Prepare Crafting Grid
|
||||
protocol.registerIncoming(State.PLAY, 0x02, 0x01); // Tab-Complete (Serverbound)
|
||||
protocol.registerIncoming(State.PLAY, 0x03, 0x02); // Chat Message (Serverbound)
|
||||
// 0x04->0x03 Client Status handled in BlockItemPackets1_12.java
|
||||
protocol.registerIncoming(State.PLAY, 0x05, 0x04); // Client Settings
|
||||
protocol.registerIncoming(State.PLAY, 0x06, 0x05); // Confirm Transaction (Serverbound)
|
||||
protocol.registerIncoming(State.PLAY, 0x07, 0x06); // Enchant Item
|
||||
// 0x08 -> 0x07 Click Window handled in BlockItemPackets1_12.java
|
||||
protocol.registerIncoming(State.PLAY, 0x09, 0x08); // Close Window (Serverbound)
|
||||
protocol.registerIncoming(State.PLAY, 0x0A, 0x09); // Plugin message (Serverbound)
|
||||
protocol.registerIncoming(State.PLAY, 0x0B, 0x0A); // Use Entity
|
||||
protocol.registerIncoming(State.PLAY, 0x0C, 0x0B); // Keep Alive (Serverbound)
|
||||
protocol.registerIncoming(State.PLAY, 0x0D, 0x0F); // Player
|
||||
protocol.registerIncoming(State.PLAY, 0x0E, 0x0C); // Player Position
|
||||
protocol.registerIncoming(State.PLAY, 0x0F, 0x0D); // Player Position And Look (ServerBound)
|
||||
protocol.registerIncoming(State.PLAY, 0x10, 0x0E); // Player Look
|
||||
protocol.registerIncoming(State.PLAY, 0x11, 0x10); // Vehicle Move
|
||||
protocol.registerIncoming(State.PLAY, 0x12, 0x11); // Steer Boat
|
||||
protocol.registerIncoming(State.PLAY, 0x13, 0x12); // Player Abilities (Serverbound)
|
||||
protocol.registerIncoming(State.PLAY, 0x14, 0x13); // Player Digging
|
||||
protocol.registerIncoming(State.PLAY, 0x15, 0x14); // Entity Action
|
||||
protocol.registerIncoming(State.PLAY, 0x16, 0x15); // Steer Vehicle
|
||||
// New incoming packet 0x17 - Crafting Book Data
|
||||
protocol.registerIncoming(State.PLAY, 0x18, 0x16); // Resource Pack Status
|
||||
// New incoming packet 0x19 - Advancement Tab
|
||||
protocol.registerIncoming(State.PLAY, 0x1A, 0x17); // Held Item Change (Serverbound)
|
||||
// 0x1B -> 0x18 Creative Inventory Action handled in BlockItemPackets.java
|
||||
protocol.registerIncoming(State.PLAY, 0x1C, 0x19); // Update Sign
|
||||
protocol.registerIncoming(State.PLAY, 0x1D, 0x1A); // Animatin (Serverbound)
|
||||
protocol.registerIncoming(State.PLAY, 0x1E, 0x1B); // Spectate
|
||||
protocol.registerIncoming(State.PLAY, 0x1F, 0x1C); // Player Block Placement
|
||||
protocol.registerIncoming(State.PLAY, 0x20, 0x1D); // Use Item
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.AdvancementTrans
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
@ -32,8 +32,7 @@ public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Chat Message (ClientBound)
|
||||
protocol.registerOutgoing(State.PLAY, 0x0F, 0x0F, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Json Data
|
||||
@ -42,10 +41,10 @@ public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
||||
handler(wrapper -> {
|
||||
try {
|
||||
JsonObject object = GsonUtil.getJsonParser().parse(wrapper.get(Type.STRING, 0)).getAsJsonObject();
|
||||
|
||||
// Skip if the root doesn't contain translate
|
||||
if (object.has("translate"))
|
||||
if (object.has("translate")) {
|
||||
handleTranslations(object);
|
||||
}
|
||||
|
||||
ChatItemRewriter.toClient(object, wrapper.user());
|
||||
wrapper.set(Type.STRING, 0, object.toString());
|
||||
|
@ -25,7 +25,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_12;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
import java.util.Optional;
|
||||
@ -38,8 +38,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Spawn Object
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -67,8 +66,9 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
int data = objectData >> 12 & 15;
|
||||
|
||||
Block block = getProtocol().getBlockItemPackets().handleBlock(objType, data);
|
||||
if (block == null)
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
@ -77,14 +77,10 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
registerExtraTracker(0x01, Entity1_12Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, Entity1_12Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, Entity1_12Types.EntityType.WEATHER);
|
||||
|
||||
// Spawn Global Entity
|
||||
registerExtraTracker(0x02, Entity1_12Types.EntityType.WEATHER);
|
||||
|
||||
// Spawn Mob
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -109,11 +105,9 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Painting
|
||||
registerExtraTracker(0x04, Entity1_12Types.EntityType.PAINTING);
|
||||
registerExtraTracker(ClientboundPackets1_12.SPAWN_PAINTING, Entity1_12Types.EntityType.PAINTING);
|
||||
|
||||
// Spawn Player
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -129,8 +123,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
});
|
||||
|
||||
// Join game
|
||||
protocol.registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
@ -165,17 +158,11 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
});
|
||||
|
||||
// Respawn Packet
|
||||
registerRespawn(0x34, 0x33);
|
||||
registerRespawn(ClientboundPackets1_12.RESPAWN);
|
||||
registerEntityDestroy(ClientboundPackets1_12.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_12.ENTITY_METADATA, Types1_12.METADATA_LIST);
|
||||
|
||||
// Destroy entities
|
||||
registerEntityDestroy(0x31, 0x30);
|
||||
|
||||
// Metadata packet
|
||||
registerMetadataRewriter(0x3B, 0x39, Types1_12.METADATA_LIST);
|
||||
|
||||
// Entity Properties
|
||||
protocol.registerOutgoing(State.PLAY, 0x4D, 0x4A, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
|
@ -16,7 +16,7 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
|
||||
public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
@ -26,8 +26,7 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Named sound effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Sound name
|
||||
@ -40,8 +39,7 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
}
|
||||
});
|
||||
|
||||
// Sound effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x48, 0x46, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Sound name
|
||||
@ -57,13 +55,15 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int oldId = wrapper.get(Type.VAR_INT, 0);
|
||||
int newId = handleSounds(oldId);
|
||||
if (newId == -1)
|
||||
if (newId == -1) {
|
||||
wrapper.cancel();
|
||||
else {
|
||||
if (hasPitch(oldId))
|
||||
wrapper.set(Type.FLOAT, 1, handlePitch(oldId));
|
||||
wrapper.set(Type.VAR_INT, 0, newId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasPitch(oldId)) {
|
||||
wrapper.set(Type.FLOAT, 1, handlePitch(oldId));
|
||||
}
|
||||
wrapper.set(Type.VAR_INT, 0, newId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -15,11 +15,18 @@ import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_11_1;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_11To1_11_1 extends BackwardsProtocol {
|
||||
public class Protocol1_11To1_11_1 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
private EntityPackets1_11_1 entityPackets;
|
||||
|
||||
public Protocol1_11To1_11_1() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
(entityPackets = new EntityPackets1_11_1(this)).register();
|
||||
@ -29,12 +36,14 @@ public class Protocol1_11To1_11_1 extends BackwardsProtocol {
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class))
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
@ -17,7 +17,7 @@ import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11_1> {
|
||||
|
||||
@ -27,8 +27,7 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Spawn Object
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -47,14 +46,10 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
registerExtraTracker(0x01, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
// Spawn Global Entity
|
||||
registerExtraTracker(0x02, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
// Spawn Mob
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -79,17 +74,11 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Painting
|
||||
registerExtraTracker(0x04, Entity1_11Types.EntityType.PAINTING);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
// Join game
|
||||
registerJoinGame(0x23, 0x23, Entity1_11Types.EntityType.PLAYER);
|
||||
|
||||
// Respawn Packet
|
||||
registerRespawn(0x33, 0x33);
|
||||
|
||||
// Spawn Player
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -105,11 +94,8 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
registerEntityDestroy(0x30);
|
||||
|
||||
// Metadata packet
|
||||
registerMetadataRewriter(0x39, 0x39, Types1_9.METADATA_LIST);
|
||||
registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,8 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
|
||||
@ -36,17 +37,12 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<Protocol1_11To1_1
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
|
||||
// Set slot packet
|
||||
itemRewriter.registerSetSlot(Type.ITEM, 0x16, 0x16);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.ITEM_ARRAY, 0x14, 0x14);
|
||||
|
||||
// Entity Equipment Packet
|
||||
itemRewriter.registerEntityEquipment(Type.ITEM, 0x3C, 0x3C);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
@ -63,8 +59,9 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<Protocol1_11To1_1
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem)
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
@ -76,18 +73,16 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<Protocol1_11To1_1
|
||||
}
|
||||
});
|
||||
|
||||
// Click window packet
|
||||
itemRewriter.registerClickWindow(Type.ITEM, 0x07, 0x07);
|
||||
|
||||
// Creative Inventory Action
|
||||
itemRewriter.registerCreativeInvAction(Type.ITEM, 0x18, 0x18);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
// Handle item metadata
|
||||
protocol.getEntityPackets().registerMetaHandler().handle(e -> {
|
||||
Metadata data = e.getData();
|
||||
|
||||
if (data.getMetaType().getType().equals(Type.ITEM)) // Is Item
|
||||
if (data.getMetaType().getType().equals(Type.ITEM)) { // Is Item
|
||||
data.setValue(handleItemToClient((Item) data.getValue()));
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
|
@ -16,14 +16,18 @@ import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
|
||||
public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets1_12_1, ClientboundPackets1_12_1, ServerboundPackets1_12_1, ServerboundPackets1_12_1> {
|
||||
|
||||
public Protocol1_12_1To1_12_2() {
|
||||
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12_1.class);
|
||||
}
|
||||
|
||||
public class Protocol1_12_1To1_12_2 extends BackwardsProtocol {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Outgoing
|
||||
// 0x1f - Keep alive
|
||||
registerOutgoing(State.PLAY, 0x1f, 0x1f, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -37,9 +41,7 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Incoming
|
||||
// 0xb - Keep alive
|
||||
registerIncoming(State.PLAY, 0xb, 0xb, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software withregisterOutgoing restriction, including withregisterOutgoing limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHregisterOutgoing WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, registerOutgoing OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13;
|
||||
@ -24,19 +24,24 @@ import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBl
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
|
||||
|
||||
private BlockItemPackets1_13 blockItemPackets;
|
||||
|
||||
public Protocol1_12_2To1_13() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_12_1.class, ServerboundPackets1_13.class, ServerboundPackets1_12_1.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_13To1_12_2.class, () -> {
|
||||
@ -55,123 +60,60 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
}
|
||||
};
|
||||
translatableRewriter.registerPing();
|
||||
translatableRewriter.registerBossBar(0x0C, 0x0C);
|
||||
translatableRewriter.registerChatMessage(0x0E, 0x0F);
|
||||
translatableRewriter.registerLegacyOpenWindow(0x14, 0x13);
|
||||
translatableRewriter.registerDisconnect(0x1B, 0x1A);
|
||||
translatableRewriter.registerCombatEvent(0x2F, 0x2D);
|
||||
translatableRewriter.registerTitle(0x4B, 0x48);
|
||||
translatableRewriter.registerPlayerList(0x4E, 0x4A);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_13.BOSSBAR);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_WINDOW);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
|
||||
|
||||
(blockItemPackets = new BlockItemPackets1_13(this)).register();
|
||||
new EntityPackets1_13(this).register();
|
||||
new PlayerPacket1_13(this).register();
|
||||
new SoundPackets1_13(this).register();
|
||||
|
||||
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150
|
||||
cancelOutgoing(ClientboundPackets1_13.DECLARE_COMMANDS); //TODO
|
||||
cancelOutgoing(ClientboundPackets1_13.NBT_QUERY);
|
||||
cancelOutgoing(ClientboundPackets1_13.CRAFT_RECIPE_RESPONSE);
|
||||
cancelOutgoing(ClientboundPackets1_13.UNLOCK_RECIPES);
|
||||
cancelOutgoing(ClientboundPackets1_13.ADVANCEMENTS);
|
||||
cancelOutgoing(ClientboundPackets1_13.DECLARE_RECIPES); //TODO ?
|
||||
cancelOutgoing(ClientboundPackets1_13.TAGS);
|
||||
|
||||
out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW
|
||||
out(State.PLAY, 0x12, 0x11); // Confirm Transaction (clientbound)
|
||||
out(State.PLAY, 0x13, 0x12); // Close Window (clientbound)
|
||||
out(State.PLAY, 0x1C, 0x1B); // Entity Status
|
||||
out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response (client won't send a request, so the server should not answer)
|
||||
out(State.PLAY, 0x1E, 0x1C); // Explosion
|
||||
out(State.PLAY, 0x20, 0x1E); // Change Game State
|
||||
out(State.PLAY, 0x21, 0x1F); // Keep Alive (clientbound)
|
||||
out(State.PLAY, 0x27, 0x25); // Entity
|
||||
out(State.PLAY, 0x28, 0x26); // Entity Relative Move
|
||||
out(State.PLAY, 0x29, 0x27); // Entity Look And Relative Move
|
||||
out(State.PLAY, 0x2A, 0x28); // Entity Look
|
||||
out(State.PLAY, 0x2B, 0x29); // Vehicle Move (clientbound)
|
||||
out(State.PLAY, 0x2C, 0x2A); // Open Sign Editor
|
||||
out(State.PLAY, 0x2D, 0x2B, cancel()); // Craft Recipe Response TODO MODIFIED
|
||||
out(State.PLAY, 0x2E, 0x2C); // Player Abilities (clientbound)
|
||||
out(State.PLAY, 0x33, 0x30); // Use Bed
|
||||
out(State.PLAY, 0x34, 0x31, cancel()); // Unlock Recipes TODO MODIFIED
|
||||
out(State.PLAY, 0x36, 0x33); // Remove Entity Effect
|
||||
out(State.PLAY, 0x37, 0x34); // Resource Pack Send
|
||||
out(State.PLAY, 0x39, 0x36); // Entity Head Look
|
||||
out(State.PLAY, 0x3A, 0x37); // Select Advancement Tab
|
||||
out(State.PLAY, 0x3B, 0x38); // World Border
|
||||
out(State.PLAY, 0x3C, 0x39); // Camera
|
||||
out(State.PLAY, 0x3D, 0x3A); // Held Item Change (clientbound)
|
||||
out(State.PLAY, 0x3E, 0x3B); // Display Scoreboard
|
||||
out(State.PLAY, 0x40, 0x3D); // Attach Entity
|
||||
out(State.PLAY, 0x41, 0x3E); // Entity Velocity
|
||||
out(State.PLAY, 0x43, 0x40); // Set Experience
|
||||
out(State.PLAY, 0x44, 0x41); // Update Health
|
||||
out(State.PLAY, 0x46, 0x43); // Set Passengers
|
||||
out(State.PLAY, 0x48, 0x45); // Update Score
|
||||
out(State.PLAY, 0x49, 0x46); // Spawn Position
|
||||
out(State.PLAY, 0x4A, 0x47); // Time Update
|
||||
out(State.PLAY, 0x4F, 0x4B); // Collect Item
|
||||
out(State.PLAY, 0x50, 0x4C); // Entity Teleport
|
||||
out(State.PLAY, 0x51, 0x4D, cancel()); // Advancements
|
||||
out(State.PLAY, 0x52, 0x4E); // Entity Properties
|
||||
out(State.PLAY, 0x53, 0x4F); // Entity Effect
|
||||
out(State.PLAY, 0x54, -1, cancel()); // Declare Recipes TODO NEW
|
||||
out(State.PLAY, 0x55, -1, cancel()); // Tags (the client won't need this)
|
||||
|
||||
in(State.PLAY, 0x06, 0x05); // Confirm Transaction (serverbound)
|
||||
in(State.PLAY, 0x07, 0x06); // Enchant Item
|
||||
in(State.PLAY, 0x09, 0x08); // Close Window (serverbound)
|
||||
in(State.PLAY, 0x0D, 0x0A); // Use Entity
|
||||
in(State.PLAY, 0x0E, 0x0B); // Keep Alive (serverbound)
|
||||
in(State.PLAY, 0x0F, 0x0C); // Player
|
||||
in(State.PLAY, 0x12, 0x0F); // Player Look
|
||||
in(State.PLAY, 0x14, 0x11); // Steer Boat
|
||||
in(State.PLAY, 0x16, 0x12, cancel()); // Craft Recipe Request TODO MODIFIED
|
||||
in(State.PLAY, 0x17, 0x13); // Player Abilities (serverbound)
|
||||
in(State.PLAY, 0x18, 0x14); // Player Digging
|
||||
in(State.PLAY, 0x19, 0x15); // Entity Action
|
||||
in(State.PLAY, 0x1A, 0x16); // Steer Vehicle
|
||||
in(State.PLAY, 0x1B, 0x17, cancel()); // Recipe Book Data TODO MODIFIED
|
||||
in(State.PLAY, 0x1D, 0x18); // Resource Pack Status
|
||||
in(State.PLAY, 0x1E, 0x19); // Advancement Tab
|
||||
//in(State.PLAY, 0x1F, -1); // Select Trade (the client won't send this)
|
||||
//in(State.PLAY, 0x20, -1); // Set Beacon Effect (the client won't send this)
|
||||
in(State.PLAY, 0x21, 0x1A); // Held Item Change (serverbound)
|
||||
in(State.PLAY, 0x26, 0x1C); // Update Sign
|
||||
in(State.PLAY, 0x27, 0x1D); // Animation (serverbound)
|
||||
in(State.PLAY, 0x28, 0x1E); // Spectate
|
||||
in(State.PLAY, 0x29, 0x1F); // Player Block Placement
|
||||
in(State.PLAY, 0x2A, 0x20); // Use Item
|
||||
cancelIncoming(ServerboundPackets1_12_1.CRAFT_RECIPE_REQUEST);
|
||||
cancelIncoming(ServerboundPackets1_12_1.RECIPE_BOOK_DATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class))
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
||||
// Register Block Storage
|
||||
if (!user.has(BackwardsBlockStorage.class))
|
||||
if (!user.has(BackwardsBlockStorage.class)) {
|
||||
user.put(new BackwardsBlockStorage(user));
|
||||
}
|
||||
// Register Block Storage
|
||||
if (!user.has(TabCompleteStorage.class))
|
||||
if (!user.has(TabCompleteStorage.class)) {
|
||||
user.put(new TabCompleteStorage(user));
|
||||
}
|
||||
|
||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
|
||||
user.put(new PlayerPositionStorage1_13(user));
|
||||
}
|
||||
}
|
||||
|
||||
public PacketRemapper cancel() {
|
||||
return new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(PacketWrapper::cancel);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public BlockItemPackets1_13 getBlockItemPackets() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||
@ -93,8 +94,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Set Cooldown
|
||||
protocol.out(State.PLAY, 0x18, 0x17, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.COOLDOWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -116,8 +116,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Block Action
|
||||
protocol.out(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // Location
|
||||
@ -156,8 +155,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Update Block Entity
|
||||
protocol.out(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
@ -185,8 +183,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Unload chunk
|
||||
protocol.registerOutgoing(State.PLAY, 0x1F, 0x1D, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.UNLOAD_CHUNK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -208,7 +205,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
});
|
||||
|
||||
// Block Change
|
||||
protocol.out(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
@ -233,7 +230,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
});
|
||||
|
||||
// Multi Block Change
|
||||
protocol.out(State.PLAY, 0x0F, 0x10, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
@ -269,8 +266,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
|
||||
// Windows Items
|
||||
protocol.out(State.PLAY, 0x15, 0x14, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
@ -280,8 +276,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Set Slot
|
||||
protocol.out(State.PLAY, 0x17, 0x16, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE);
|
||||
@ -292,127 +287,121 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Chunk packet
|
||||
protocol.out(State.PLAY, 0x22, 0x20, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type_old = new Chunk1_9_3_4Type(clientWorld);
|
||||
Chunk1_13Type type = new Chunk1_13Type(clientWorld);
|
||||
Chunk chunk = wrapper.read(type);
|
||||
Chunk1_9_3_4Type type_old = new Chunk1_9_3_4Type(clientWorld);
|
||||
Chunk1_13Type type = new Chunk1_13Type(clientWorld);
|
||||
Chunk chunk = wrapper.read(type);
|
||||
|
||||
// Handle Block Entities before block rewrite
|
||||
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag idTag = tag.get("id");
|
||||
if (idTag == null) continue;
|
||||
// Handle Block Entities before block rewrite
|
||||
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag idTag = tag.get("id");
|
||||
if (idTag == null) continue;
|
||||
|
||||
String id = (String) idTag.getValue();
|
||||
String id = (String) idTag.getValue();
|
||||
|
||||
// Ignore if we don't handle it
|
||||
if (!provider.isHandled(id)) continue;
|
||||
// Ignore if we don't handle it
|
||||
if (!provider.isHandled(id)) continue;
|
||||
|
||||
int sectionIndex = ((int) tag.get("y").getValue()) >> 4;
|
||||
ChunkSection section = chunk.getSections()[sectionIndex];
|
||||
int sectionIndex = ((int) tag.get("y").getValue()) >> 4;
|
||||
ChunkSection section = chunk.getSections()[sectionIndex];
|
||||
|
||||
int x = (int) tag.get("x").getValue();
|
||||
int y = (int) tag.get("y").getValue();
|
||||
int z = (int) tag.get("z").getValue();
|
||||
Position position = new Position(x, (short) y, z);
|
||||
int x = (int) tag.get("x").getValue();
|
||||
int y = (int) tag.get("y").getValue();
|
||||
int z = (int) tag.get("z").getValue();
|
||||
Position position = new Position(x, (short) y, z);
|
||||
|
||||
int block = section.getFlatBlock(x & 0xF, y & 0xF, z & 0xF);
|
||||
storage.checkAndStore(position, block);
|
||||
int block = section.getFlatBlock(x & 0xF, y & 0xF, z & 0xF);
|
||||
storage.checkAndStore(position, block);
|
||||
|
||||
provider.transform(wrapper.user(), position, tag);
|
||||
}
|
||||
|
||||
// Rewrite new blocks to old blocks
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Flower pots require a special treatment, they are no longer block entities :(
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
int block = section.getFlatBlock(x, y, z);
|
||||
|
||||
// Check if the block is a flower
|
||||
if (FlowerPotHandler.isFlowah(block)) {
|
||||
Position pos = new Position(
|
||||
(x + (chunk.getX() << 4)),
|
||||
(short) (y + (i << 4)),
|
||||
(z + (chunk.getZ() << 4))
|
||||
);
|
||||
// Store block
|
||||
storage.checkAndStore(pos, block);
|
||||
|
||||
CompoundTag nbt = provider.transform(wrapper.user(), pos, "minecraft:flower_pot");
|
||||
|
||||
chunk.getBlockEntities().add(nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int p = 0; p < section.getPaletteSize(); p++) {
|
||||
int old = section.getPaletteEntry(p);
|
||||
if (old != 0) {
|
||||
int oldId = toOldId(old);
|
||||
section.setPaletteEntry(p, oldId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (chunk.isBiomeData()) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
int biome = chunk.getBiomeData()[i];
|
||||
int newId = -1;
|
||||
switch (biome) {
|
||||
case 40: // end biomes
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
newId = 9;
|
||||
break;
|
||||
case 47: // deep ocean biomes
|
||||
case 48:
|
||||
case 49:
|
||||
newId = 24;
|
||||
break;
|
||||
case 50: // deep frozen... let's just pick the frozen variant
|
||||
newId = 10;
|
||||
break;
|
||||
case 44: // the other new ocean biomes
|
||||
case 45:
|
||||
case 46:
|
||||
newId = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (newId != -1) {
|
||||
chunk.getBiomeData()[i] = newId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wrapper.write(type_old, chunk);
|
||||
}
|
||||
});
|
||||
provider.transform(wrapper.user(), position, tag);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Effect
|
||||
protocol.out(State.PLAY, 0x23, 0x21, new PacketRemapper() {
|
||||
// Rewrite new blocks to old blocks
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Flower pots require a special treatment, they are no longer block entities :(
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
int block = section.getFlatBlock(x, y, z);
|
||||
|
||||
// Check if the block is a flower
|
||||
if (FlowerPotHandler.isFlowah(block)) {
|
||||
Position pos = new Position(
|
||||
(x + (chunk.getX() << 4)),
|
||||
(short) (y + (i << 4)),
|
||||
(z + (chunk.getZ() << 4))
|
||||
);
|
||||
// Store block
|
||||
storage.checkAndStore(pos, block);
|
||||
|
||||
CompoundTag nbt = provider.transform(wrapper.user(), pos, "minecraft:flower_pot");
|
||||
|
||||
chunk.getBlockEntities().add(nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int p = 0; p < section.getPaletteSize(); p++) {
|
||||
int old = section.getPaletteEntry(p);
|
||||
if (old != 0) {
|
||||
int oldId = toOldId(old);
|
||||
section.setPaletteEntry(p, oldId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (chunk.isBiomeData()) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
int biome = chunk.getBiomeData()[i];
|
||||
int newId = -1;
|
||||
switch (biome) {
|
||||
case 40: // end biomes
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
newId = 9;
|
||||
break;
|
||||
case 47: // deep ocean biomes
|
||||
case 48:
|
||||
case 49:
|
||||
newId = 24;
|
||||
break;
|
||||
case 50: // deep frozen... let's just pick the frozen variant
|
||||
newId = 10;
|
||||
break;
|
||||
case 44: // the other new ocean biomes
|
||||
case 45:
|
||||
case 46:
|
||||
newId = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (newId != -1) {
|
||||
chunk.getBiomeData()[i] = newId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wrapper.write(type_old, chunk);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Effect Id
|
||||
@ -436,8 +425,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Map
|
||||
protocol.out(State.PLAY, 0x26, 0x24, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -468,8 +456,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment
|
||||
protocol.out(State.PLAY, 0x42, 0x3F, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -480,8 +467,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Window Property
|
||||
protocol.out(State.PLAY, 0x16, 0x15, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Window Id
|
||||
@ -499,8 +485,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
});
|
||||
|
||||
|
||||
// Set Creative Slot
|
||||
protocol.in(State.PLAY, 0x24, 0x1B, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT);
|
||||
@ -510,8 +495,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Click Window
|
||||
protocol.in(State.PLAY, 0x08, 0x07, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
|
@ -22,8 +22,9 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_12;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -35,8 +36,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Player Position And Look (clientbound)
|
||||
protocol.out(State.PLAY, 0x32, 0x2F, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.PLAYER_POSITION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.DOUBLE);
|
||||
@ -65,8 +65,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Object
|
||||
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -115,14 +114,10 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
registerExtraTracker(0x01, Entity1_13Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, Entity1_13Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, Entity1_13Types.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
// Spawn Global Entity
|
||||
registerExtraTracker(0x02, Entity1_13Types.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
//Spawn Mob
|
||||
protocol.out(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -161,8 +156,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Player
|
||||
protocol.out(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -178,8 +172,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Painting
|
||||
protocol.out(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PAINTING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -197,11 +190,9 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Join game
|
||||
registerJoinGame(0x25, 0x23, Entity1_13Types.EntityType.PLAYER);
|
||||
registerJoinGame(ClientboundPackets1_13.JOIN_GAME, Entity1_13Types.EntityType.PLAYER);
|
||||
|
||||
// Respawn Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x38, 0x35, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
@ -211,14 +202,11 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy Entities Packet
|
||||
registerEntityDestroy(0x35, 0x32);
|
||||
|
||||
// Entity Metadata packet
|
||||
registerMetadataRewriter(0x3F, 0x3C, Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
registerEntityDestroy(ClientboundPackets1_13.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
|
||||
// Face Player (new packet)
|
||||
protocol.out(State.PLAY, 0x31, -1, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.FACE_PLAYER, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -243,7 +231,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
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(),
|
||||
anchor == 1 ? positionStorage.getY() + 1.62 : positionStorage.getY(),
|
||||
positionStorage.getZ(), x, y, z);
|
||||
@ -266,13 +254,9 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
handler(wrapper -> wrapper.user().get(PlayerPositionStorage1_13.class).setCoordinates(wrapper, false));
|
||||
}
|
||||
};
|
||||
protocol.in(State.PLAY, 0x10, 0x0D, movementRemapper); // Player Position
|
||||
protocol.in(State.PLAY, 0x11, 0x0E, movementRemapper); // Player Position And Look (serverbound)
|
||||
protocol.in(State.PLAY, 0x13, 0x10, movementRemapper); // Vehicle Move (serverbound)
|
||||
} else {
|
||||
protocol.in(State.PLAY, 0x10, 0x0D); // Player Position
|
||||
protocol.in(State.PLAY, 0x11, 0x0E); // Player Position And Look (serverbound)
|
||||
protocol.in(State.PLAY, 0x13, 0x10); // Vehicle Move (serverbound)
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.PLAYER_POSITION, movementRemapper); // Player Position
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.PLAYER_POSITION_AND_ROTATION, movementRemapper); // Player Position And Look (serverbound)
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.VEHICLE_MOVE, movementRemapper); // Vehicle Move (serverbound)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,9 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -35,7 +37,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Login Plugin Request
|
||||
protocol.out(State.LOGIN, 0x04, -1, new PacketRemapper() {
|
||||
protocol.registerOutgoing(State.LOGIN, 0x04, -1, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -54,8 +56,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
//Plugin Message
|
||||
protocol.out(State.PLAY, 0x19, 0x18, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -100,12 +101,12 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
if (oldChannel.equals("REGISTER") || oldChannel.equals("UNREGISTER")) {
|
||||
String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0");
|
||||
List<String> rewrittenChannels = new ArrayList<>();
|
||||
for (int i = 0; i < channels.length; i++) {
|
||||
String rewritten = InventoryPackets.getOldPluginChannelId(channels[i]);
|
||||
for (String s : channels) {
|
||||
String rewritten = InventoryPackets.getOldPluginChannelId(s);
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + channels[i]);
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + s);
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||
@ -116,8 +117,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Particle
|
||||
protocol.out(State.PLAY, 0x24, 0x22, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
@ -130,7 +130,6 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
map(Type.FLOAT); // 7 - Offset Z
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
@ -147,8 +146,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
// Player List Item
|
||||
protocol.out(State.PLAY, 0x30, 0x2E, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.PLAYER_INFO, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -192,8 +190,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
//Scoreboard Objective
|
||||
protocol.out(State.PLAY, 0x45, 0x42, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SCOREBOARD_OBJECTIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
@ -215,8 +212,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
//Teams
|
||||
protocol.out(State.PLAY, 0x47, 0x44, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.TEAMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
@ -274,8 +270,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
// Tab-Complete (clientbound)
|
||||
protocol.out(State.PLAY, 0x10, 0x0E, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -311,67 +306,64 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
// Tab-Complete (serverbound)
|
||||
protocol.in(State.PLAY, 0x05, 0x01, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
int id = ThreadLocalRandom.current().nextInt();
|
||||
wrapper.write(Type.VAR_INT, id);
|
||||
handler(wrapper -> {
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
int id = ThreadLocalRandom.current().nextInt();
|
||||
wrapper.write(Type.VAR_INT, id);
|
||||
|
||||
String command = wrapper.read(Type.STRING);
|
||||
boolean assumeCommand = wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.OPTIONAL_POSITION);
|
||||
String command = wrapper.read(Type.STRING);
|
||||
boolean assumeCommand = wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.OPTIONAL_POSITION);
|
||||
|
||||
if (!assumeCommand) {
|
||||
if (command.startsWith("/")) {
|
||||
command = command.substring(1);
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
PacketWrapper response = wrapper.create(0xE);
|
||||
List<String> usernames = new ArrayList<>();
|
||||
for (String value : storage.usernames.values()) {
|
||||
if (value.toLowerCase().startsWith(command.substring(command.lastIndexOf(' ') + 1).toLowerCase())) {
|
||||
usernames.add(value);
|
||||
}
|
||||
if (!assumeCommand) {
|
||||
if (command.startsWith("/")) {
|
||||
command = command.substring(1);
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
PacketWrapper response = wrapper.create(0xE);
|
||||
List<String> usernames = new ArrayList<>();
|
||||
for (String value : storage.usernames.values()) {
|
||||
if (value.toLowerCase().startsWith(command.substring(command.lastIndexOf(' ') + 1).toLowerCase())) {
|
||||
usernames.add(value);
|
||||
}
|
||||
response.write(Type.VAR_INT, usernames.size());
|
||||
for (String value : usernames) {
|
||||
response.write(Type.STRING, value);
|
||||
}
|
||||
response.send(protocol.getClass());
|
||||
}
|
||||
response.write(Type.VAR_INT, usernames.size());
|
||||
for (String value : usernames) {
|
||||
response.write(Type.STRING, value);
|
||||
}
|
||||
response.send(protocol.getClass());
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, command);
|
||||
storage.lastId = id;
|
||||
storage.lastAssumeCommand = assumeCommand;
|
||||
storage.lastRequest = command;
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, command);
|
||||
storage.lastId = id;
|
||||
storage.lastAssumeCommand = assumeCommand;
|
||||
storage.lastRequest = command;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Plugin Message
|
||||
protocol.in(State.PLAY, 0x0A, 0x09, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
String channel = wrapper.read(Type.STRING);
|
||||
if (channel.equals("MC|BSign") || channel.equals("MC|BEdit")) {
|
||||
handler(wrapper -> {
|
||||
String channel = wrapper.read(Type.STRING);
|
||||
switch (channel) {
|
||||
case "MC|BSign":
|
||||
case "MC|BEdit":
|
||||
wrapper.setId(0x0B);
|
||||
Item book = wrapper.read(Type.ITEM);
|
||||
wrapper.write(Type.FLAT_ITEM, getProtocol().getBlockItemPackets().handleItemToServer(book));
|
||||
boolean signing = channel.equals("MC|BSign");
|
||||
wrapper.write(Type.BOOLEAN, signing);
|
||||
} else if (channel.equals("MC|ItemName")) {
|
||||
break;
|
||||
case "MC|ItemName":
|
||||
wrapper.setId(0x1C);
|
||||
} else if (channel.equals("MC|AdvCmd")) {
|
||||
break;
|
||||
case "MC|AdvCmd":
|
||||
byte type = wrapper.read(Type.BYTE);
|
||||
if (type == 0) {
|
||||
//Information from https://wiki.vg/index.php?title=Plugin_channels&oldid=14089
|
||||
@ -389,7 +381,8 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
} else if (channel.equals("MC|AutoCmd")) {
|
||||
break;
|
||||
case "MC|AutoCmd": {
|
||||
wrapper.setId(0x22);
|
||||
|
||||
int x = wrapper.read(Type.INT);
|
||||
@ -400,6 +393,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
wrapper.passthrough(Type.STRING); //Command
|
||||
|
||||
|
||||
byte flags = 0;
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x01; //Track Output
|
||||
|
||||
@ -412,7 +406,9 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x04; //Automatic
|
||||
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
} else if (channel.equals("MC|Struct")) {
|
||||
break;
|
||||
}
|
||||
case "MC|Struct": {
|
||||
wrapper.setId(0x25);
|
||||
int x = wrapper.read(Type.INT);
|
||||
int y = wrapper.read(Type.INT);
|
||||
@ -423,34 +419,52 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
int modeId = mode.equals("SAVE") ? 0 : mode.equals("LOAD") ? 1 : mode.equals("CORNER") ? 2 : 3;
|
||||
wrapper.write(Type.VAR_INT, modeId);
|
||||
wrapper.passthrough(Type.STRING); //Name
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset X
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset Y
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset Z
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size X
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size Y
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size Z
|
||||
|
||||
String mirror = wrapper.read(Type.STRING);
|
||||
int mirrorId = mode.equals("NONE") ? 0 : mode.equals("LEFT_RIGHT") ? 1 : 2;
|
||||
String rotation = wrapper.read(Type.STRING);
|
||||
int rotationId = mode.equals("NONE") ? 0 : mode.equals("CLOCKWISE_90") ? 1 : mode.equals("CLOCKWISE_180") ? 2 : 3;
|
||||
wrapper.passthrough(Type.STRING); //Metadata
|
||||
|
||||
byte flags = 0;
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x01; //Ignore entities
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x02; //Show air
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x04; //Show bounding box
|
||||
wrapper.passthrough(Type.FLOAT); //Integrity
|
||||
|
||||
wrapper.passthrough(Type.VAR_LONG); //Seed
|
||||
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
} else if (channel.equals("MC|Beacon")) {
|
||||
break;
|
||||
}
|
||||
case "MC|Beacon":
|
||||
wrapper.setId(0x20);
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Primary Effect
|
||||
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Secondary Effect
|
||||
} else if (channel.equals("MC|TrSel")) {
|
||||
|
||||
break;
|
||||
case "MC|TrSel":
|
||||
wrapper.setId(0x1F);
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Slot
|
||||
} else if (channel.equals("MC|PickItem")) {
|
||||
|
||||
break;
|
||||
case "MC|PickItem":
|
||||
wrapper.setId(0x15);
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
String newChannel = InventoryPackets.getNewPluginChannelId(channel);
|
||||
if (newChannel == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
@ -464,12 +478,12 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
if (newChannel.equals("minecraft:register") || newChannel.equals("minecraft:unregister")) {
|
||||
String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0");
|
||||
List<String> rewrittenChannels = new ArrayList<>();
|
||||
for (int i = 0; i < channels.length; i++) {
|
||||
String rewritten = InventoryPackets.getNewPluginChannelId(channels[i]);
|
||||
for (String s : channels) {
|
||||
String rewritten = InventoryPackets.getNewPluginChannelId(s);
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + channels[i]);
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + s);
|
||||
}
|
||||
}
|
||||
if (!rewrittenChannels.isEmpty()) {
|
||||
@ -479,14 +493,13 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Statistics
|
||||
protocol.out(State.PLAY, 0x07, 0x07, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.STATISTICS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -527,8 +540,9 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
wrapper.passthrough(Type.VAR_INT); // value
|
||||
}
|
||||
|
||||
if (newSize != size)
|
||||
if (newSize != size) {
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.NamedSoundMappin
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
private static final String[] SOUND_SOURCES = {"master", "music", "record", "weather", "block", "hostile", "neutral", "player", "ambient", "voice"};
|
||||
@ -19,8 +20,7 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Named Sound Event
|
||||
protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
@ -36,8 +36,8 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
// Stop Sound
|
||||
protocol.out(State.PLAY, 0x4C, 0x18, new PacketRemapper() {
|
||||
// Stop Sound -> Plugin Message
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.STOP_SOUND, ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@ -66,8 +66,7 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
});
|
||||
|
||||
// Sound Effect
|
||||
protocol.out(State.PLAY, 0x4D, 0x49, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
|
@ -1,83 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_12_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
|
||||
public class Protocol1_12To1_12_1 extends BackwardsProtocol<ClientboundPackets1_12_1, ClientboundPackets1_12, ServerboundPackets1_12_1, ServerboundPackets1_12> {
|
||||
|
||||
public Protocol1_12To1_12_1() {
|
||||
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12.class);
|
||||
}
|
||||
|
||||
public class Protocol1_12To1_12_1 extends BackwardsProtocol {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
cancelOutgoing(State.PLAY, 0x2B); //TODO
|
||||
registerOutgoing(State.PLAY, 0x2c, 0x2b);
|
||||
registerOutgoing(State.PLAY, 0x2d, 0x2c);
|
||||
registerOutgoing(State.PLAY, 0x2e, 0x2d);
|
||||
registerOutgoing(State.PLAY, 0x2f, 0x2e);
|
||||
registerOutgoing(State.PLAY, 0x30, 0x2f);
|
||||
registerOutgoing(State.PLAY, 0x31, 0x30);
|
||||
registerOutgoing(State.PLAY, 0x32, 0x31);
|
||||
registerOutgoing(State.PLAY, 0x33, 0x32);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x33);
|
||||
registerOutgoing(State.PLAY, 0x35, 0x34);
|
||||
registerOutgoing(State.PLAY, 0x36, 0x35);
|
||||
registerOutgoing(State.PLAY, 0x37, 0x36);
|
||||
registerOutgoing(State.PLAY, 0x38, 0x37);
|
||||
registerOutgoing(State.PLAY, 0x39, 0x38);
|
||||
registerOutgoing(State.PLAY, 0x3a, 0x39);
|
||||
registerOutgoing(State.PLAY, 0x3b, 0x3a);
|
||||
registerOutgoing(State.PLAY, 0x3c, 0x3b);
|
||||
registerOutgoing(State.PLAY, 0x3d, 0x3c);
|
||||
registerOutgoing(State.PLAY, 0x3e, 0x3d);
|
||||
registerOutgoing(State.PLAY, 0x3f, 0x3e);
|
||||
registerOutgoing(State.PLAY, 0x40, 0x3f);
|
||||
registerOutgoing(State.PLAY, 0x41, 0x40);
|
||||
registerOutgoing(State.PLAY, 0x42, 0x41);
|
||||
registerOutgoing(State.PLAY, 0x43, 0x42);
|
||||
registerOutgoing(State.PLAY, 0x44, 0x43);
|
||||
registerOutgoing(State.PLAY, 0x45, 0x44);
|
||||
registerOutgoing(State.PLAY, 0x46, 0x45);
|
||||
registerOutgoing(State.PLAY, 0x47, 0x46);
|
||||
registerOutgoing(State.PLAY, 0x48, 0x47);
|
||||
registerOutgoing(State.PLAY, 0x49, 0x48);
|
||||
registerOutgoing(State.PLAY, 0x4a, 0x49);
|
||||
registerOutgoing(State.PLAY, 0x4b, 0x4a);
|
||||
registerOutgoing(State.PLAY, 0x4c, 0x4b);
|
||||
registerOutgoing(State.PLAY, 0x4d, 0x4c);
|
||||
registerOutgoing(State.PLAY, 0x4e, 0x4d);
|
||||
registerOutgoing(State.PLAY, 0x4f, 0x4e);
|
||||
|
||||
cancelIncoming(State.PLAY, 0x01); //TODO
|
||||
registerIncoming(State.PLAY, 0x1, 0x2);
|
||||
registerIncoming(State.PLAY, 0x2, 0x3);
|
||||
registerIncoming(State.PLAY, 0x3, 0x4);
|
||||
registerIncoming(State.PLAY, 0x4, 0x5);
|
||||
registerIncoming(State.PLAY, 0x5, 0x6);
|
||||
registerIncoming(State.PLAY, 0x6, 0x7);
|
||||
registerIncoming(State.PLAY, 0x7, 0x8);
|
||||
registerIncoming(State.PLAY, 0x8, 0x9);
|
||||
registerIncoming(State.PLAY, 0x9, 0xa);
|
||||
registerIncoming(State.PLAY, 0xa, 0xb);
|
||||
registerIncoming(State.PLAY, 0xb, 0xc);
|
||||
registerIncoming(State.PLAY, 0xc, 0xd);
|
||||
registerIncoming(State.PLAY, 0xd, 0xe);
|
||||
registerIncoming(State.PLAY, 0xe, 0xf);
|
||||
registerIncoming(State.PLAY, 0xf, 0x10);
|
||||
registerIncoming(State.PLAY, 0x10, 0x11);
|
||||
registerIncoming(State.PLAY, 0x11, 0x12);
|
||||
// New incoming 0x12 - No sent by client, sad :(
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
|
||||
cancelOutgoing(ClientboundPackets1_12_1.CRAFT_RECIPE_RESPONSE);
|
||||
cancelIncoming(ServerboundPackets1_12.PREPARE_CRAFTING_GRID);
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,18 @@ import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.EntityPacke
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.InventoryPackets1_13_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.WorldPackets1_13_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
|
||||
public class Protocol1_13_1To1_13_2 extends BackwardsProtocol {
|
||||
public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
||||
|
||||
public Protocol1_13_1To1_13_2() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
@ -20,16 +24,14 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol {
|
||||
WorldPackets1_13_2.register(this);
|
||||
EntityPackets1_13_2.register(this);
|
||||
|
||||
//Edit Book
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM);
|
||||
}
|
||||
});
|
||||
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -71,9 +73,4 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,22 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
public class EntityPackets1_13_2 {
|
||||
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
// Spawn mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||
public static void register(Protocol1_13_1To1_13_2 protocol) {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -47,8 +46,7 @@ public class EntityPackets1_13_2 {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -73,8 +71,7 @@ public class EntityPackets1_13_2 {
|
||||
}
|
||||
});
|
||||
|
||||
// Metadata packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_METADATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
|
@ -1,21 +1,17 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
|
||||
public class InventoryPackets1_13_2 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
/*
|
||||
Outgoing packets
|
||||
*/
|
||||
|
||||
// Set slot packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() {
|
||||
public static void register(Protocol1_13_1To1_13_2 protocol) {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
@ -24,8 +20,7 @@ public class InventoryPackets1_13_2 {
|
||||
}
|
||||
});
|
||||
|
||||
// Window items packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
@ -33,8 +28,7 @@ public class InventoryPackets1_13_2 {
|
||||
}
|
||||
});
|
||||
|
||||
// Plugin message
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // Channel
|
||||
@ -67,8 +61,7 @@ public class InventoryPackets1_13_2 {
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -77,8 +70,7 @@ public class InventoryPackets1_13_2 {
|
||||
}
|
||||
});
|
||||
|
||||
// Declare Recipes
|
||||
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -117,32 +109,24 @@ public class InventoryPackets1_13_2 {
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
Incoming packets
|
||||
*/
|
||||
protocol.registerIncoming(ServerboundPackets1_13.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item
|
||||
}
|
||||
});
|
||||
|
||||
// Click window packet
|
||||
protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Creative Inventory Action
|
||||
protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item
|
||||
}
|
||||
}
|
||||
);
|
||||
protocol.registerIncoming(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
public class WorldPackets1_13_2 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
//spawn particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
public static void register(Protocol1_13_1To1_13_2 protocol) {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
|
@ -15,27 +15,34 @@ import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_13_2To1_14 extends BackwardsProtocol {
|
||||
public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_13, ServerboundPackets1_14, ServerboundPackets1_13> {
|
||||
|
||||
private BlockItemPackets1_14 blockItemPackets;
|
||||
private EntityPackets1_14 entityPackets;
|
||||
|
||||
public Protocol1_13_2To1_14() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_13.class, ServerboundPackets1_14.class, ServerboundPackets1_13.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_14To1_13_2.class, BackwardsMappings::init);
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(0x0C, 0x0C);
|
||||
translatableRewriter.registerChatMessage(0x0E, 0x0E);
|
||||
translatableRewriter.registerCombatEvent(0x32, 0x2F);
|
||||
translatableRewriter.registerDisconnect(0x1A, 0x1B);
|
||||
translatableRewriter.registerPlayerList(0x53, 0x4E);
|
||||
translatableRewriter.registerTitle(0x4F, 0x4B);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_14.CHAT_MESSAGE);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_14.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_14.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_14.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_14.TITLE);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
blockItemPackets = new BlockItemPackets1_14(this, translatableRewriter);
|
||||
@ -45,45 +52,11 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
|
||||
new PlayerPackets1_14(this).register();
|
||||
new SoundPackets1_14(this).register();
|
||||
|
||||
registerOutgoing(State.PLAY, 0x15, 0x16);
|
||||
registerOutgoing(State.PLAY, 0x18, 0x19);
|
||||
registerOutgoing(State.PLAY, 0x54, 0x1D);
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x20);
|
||||
registerOutgoing(State.PLAY, 0x20, 0x21);
|
||||
registerOutgoing(State.PLAY, 0x2B, 0x27);
|
||||
registerOutgoing(State.PLAY, 0x2C, 0x2B);
|
||||
registerOutgoing(State.PLAY, 0x30, 0x2D);
|
||||
registerOutgoing(State.PLAY, 0x31, 0x2E);
|
||||
registerOutgoing(State.PLAY, 0x33, 0x30);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x31);
|
||||
registerOutgoing(State.PLAY, 0x35, 0x32);
|
||||
registerOutgoing(State.PLAY, 0x36, 0x34);
|
||||
registerOutgoing(State.PLAY, 0x38, 0x36);
|
||||
registerOutgoing(State.PLAY, 0x39, 0x37);
|
||||
registerOutgoing(State.PLAY, 0x3B, 0x39);
|
||||
registerOutgoing(State.PLAY, 0x3C, 0x3A);
|
||||
registerOutgoing(State.PLAY, 0x3D, 0x3B);
|
||||
registerOutgoing(State.PLAY, 0x3E, 0x3C);
|
||||
registerOutgoing(State.PLAY, 0x3F, 0x3D);
|
||||
registerOutgoing(State.PLAY, 0x42, 0x3E);
|
||||
registerOutgoing(State.PLAY, 0x44, 0x40);
|
||||
registerOutgoing(State.PLAY, 0x45, 0x41);
|
||||
registerOutgoing(State.PLAY, 0x47, 0x43);
|
||||
registerOutgoing(State.PLAY, 0x48, 0x44);
|
||||
registerOutgoing(State.PLAY, 0x49, 0x45);
|
||||
registerOutgoing(State.PLAY, 0x4A, 0x46);
|
||||
registerOutgoing(State.PLAY, 0x4B, 0x47);
|
||||
registerOutgoing(State.PLAY, 0x4C, 0x48);
|
||||
registerOutgoing(State.PLAY, 0x4E, 0x4A);
|
||||
registerOutgoing(State.PLAY, 0x55, 0x4F);
|
||||
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_POSITION);
|
||||
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
|
||||
cancelOutgoing(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
|
||||
// Update View Position
|
||||
cancelOutgoing(State.PLAY, 0x40);
|
||||
|
||||
// Update View Distance
|
||||
cancelOutgoing(State.PLAY, 0x41);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x57, 0x51, new PacketRemapper() { // c
|
||||
registerOutgoing(ClientboundPackets1_14.ADVANCEMENTS, new PacketRemapper() { // c
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -124,13 +97,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(State.PLAY, 0x58, 0x52); // c
|
||||
registerOutgoing(State.PLAY, 0x59, 0x53); // c
|
||||
|
||||
// Tags
|
||||
registerOutgoing(State.PLAY, 0x5B, 0x55, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_14.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() { // c
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
@ -175,9 +144,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Light update
|
||||
out(State.PLAY, 0x24, -1, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_14.UPDATE_LIGHT, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -231,51 +198,6 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Incomming
|
||||
|
||||
//Unknown packet added in 19w11a - 0x02
|
||||
registerIncoming(State.PLAY, 0x03, 0x02); // r
|
||||
registerIncoming(State.PLAY, 0x04, 0x03); // r
|
||||
registerIncoming(State.PLAY, 0x05, 0x04); // r
|
||||
registerIncoming(State.PLAY, 0x06, 0x05); // r
|
||||
registerIncoming(State.PLAY, 0x07, 0x06); // r
|
||||
registerIncoming(State.PLAY, 0x08, 0x07); // r
|
||||
|
||||
registerIncoming(State.PLAY, 0x0A, 0x09); // r
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0A); // r
|
||||
|
||||
registerIncoming(State.PLAY, 0x0D, 0x0C); // r
|
||||
registerIncoming(State.PLAY, 0x0E, 0x0D); // r
|
||||
//Unknown packet added in 19w11a - 0x0F
|
||||
registerIncoming(State.PLAY, 0x0F, 0x0E); // r
|
||||
registerIncoming(State.PLAY, 0x11, 0x10); // r
|
||||
registerIncoming(State.PLAY, 0x12, 0x11); // r
|
||||
registerIncoming(State.PLAY, 0x13, 0x12); // r
|
||||
registerIncoming(State.PLAY, 0x14, 0x0F); // r
|
||||
registerIncoming(State.PLAY, 0x15, 0x13); // r
|
||||
registerIncoming(State.PLAY, 0x16, 0x14); // r
|
||||
registerIncoming(State.PLAY, 0x17, 0x15); // r
|
||||
registerIncoming(State.PLAY, 0x18, 0x16); // r
|
||||
registerIncoming(State.PLAY, 0x19, 0x17); // r
|
||||
|
||||
registerIncoming(State.PLAY, 0x1B, 0x19); // r
|
||||
registerIncoming(State.PLAY, 0x1C, 0x1A); // r
|
||||
|
||||
registerIncoming(State.PLAY, 0x1E, 0x1C); // r
|
||||
registerIncoming(State.PLAY, 0x1F, 0x1D); // r
|
||||
registerIncoming(State.PLAY, 0x20, 0x1E); // r
|
||||
registerIncoming(State.PLAY, 0x21, 0x1F); // r
|
||||
registerIncoming(State.PLAY, 0x22, 0x20); // r
|
||||
registerIncoming(State.PLAY, 0x23, 0x21); // r
|
||||
|
||||
registerIncoming(State.PLAY, 0x25, 0x23); // r
|
||||
|
||||
// registerIncoming(State.PLAY, 0x29, 0x27); // r
|
||||
registerIncoming(State.PLAY, 0x2A, 0x27); // r
|
||||
registerIncoming(State.PLAY, 0x2B, 0x28); // r
|
||||
registerIncoming(State.PLAY, 0x2D, 0x2A); // r
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
@ -297,22 +219,24 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
|
||||
return newId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class))
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
||||
if (!user.has(ChunkLightStorage.class))
|
||||
if (!user.has(ChunkLightStorage.class)) {
|
||||
user.put(new ChunkLightStorage(user));
|
||||
}
|
||||
}
|
||||
|
||||
public BlockItemPackets1_14 getBlockItemPackets() {
|
||||
|
@ -8,7 +8,7 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_14 extends RecipeRewriter {
|
||||
|
||||
public RecipeRewriter1_14(final ItemRewriterBase rewriter) {
|
||||
public RecipeRewriter1_14(ItemRewriterBase rewriter) {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,11 @@ import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
@ -54,18 +56,16 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Edit Book
|
||||
protocol.registerIncoming(State.PLAY, 0x0C, 0x0B, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
|
||||
// Open window
|
||||
protocol.registerOutgoing(State.PLAY, 0x2E, 0x14, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() { // c
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
@ -156,10 +156,10 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Horse window
|
||||
protocol.registerOutgoing(State.PLAY, 0x1F, 0x14, new PacketRemapper() {
|
||||
// Horse window -> Open Window
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.OPEN_HORSE_WINDOW, ClientboundPackets1_13.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() { // c
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
@ -176,17 +176,12 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13_2To1_14::getNewBlockStateId, Protocol1_13_2To1_14::getNewBlockId);
|
||||
|
||||
// Set cooldown
|
||||
itemRewriter.registerSetCooldown(0x17, 0x18, BlockItemPackets1_14::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN, BlockItemPackets1_14::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x14, 0x15);
|
||||
|
||||
// Set slot packet
|
||||
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x16, 0x17);
|
||||
|
||||
// Trade list
|
||||
protocol.out(State.PLAY, 0x27, 0x19, new PacketRemapper() {
|
||||
// Trade List -> Plugin Message
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -234,8 +229,8 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Book open
|
||||
protocol.registerOutgoing(State.PLAY, 0x2D, 0x19, new PacketRemapper() {
|
||||
// Open Book -> Plugin Message
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.OPEN_BOOK, ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -248,8 +243,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x42, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -286,8 +280,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Declare Recipes
|
||||
protocol.registerOutgoing(State.PLAY, 0x5A, 0x54, new PacketRemapper() { // c
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() { // c
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -334,18 +327,11 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
Incoming packets
|
||||
*/
|
||||
|
||||
// Click window packet
|
||||
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x08);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Creative Inventory Action
|
||||
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x24);
|
||||
|
||||
// Block break animation
|
||||
protocol.registerOutgoing(State.PLAY, 0x08, 0x08, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.BLOCK_BREAK_ANIMATION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -354,16 +340,14 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Update block entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
}
|
||||
});
|
||||
|
||||
// Block Action
|
||||
protocol.registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.BLOCK_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14, Type.POSITION); // Location
|
||||
@ -379,8 +363,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change
|
||||
protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
@ -396,11 +379,9 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change
|
||||
blockRewriter.registerMultiBlockChange(0xF, 0xF);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_14.MULTI_BLOCK_CHANGE);
|
||||
|
||||
//Explosion
|
||||
protocol.registerOutgoing(State.PLAY, 0x1C, 0x1E, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.EXPLOSION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLOAT); // X
|
||||
@ -423,8 +404,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
//Chunk
|
||||
protocol.registerOutgoing(State.PLAY, 0x21, 0x22, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -477,8 +457,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Unload chunk
|
||||
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.UNLOAD_CHUNK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -492,8 +471,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Effect packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x23, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Effect Id
|
||||
@ -514,12 +492,10 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn particle
|
||||
blockRewriter.registerSpawnParticle(Type.FLOAT, 0x23, 0x24, 3, 23, 32,
|
||||
EntityPackets1_14::getOldParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, 3, 23, 32,
|
||||
EntityPackets1_14::getOldParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
|
||||
|
||||
//Map Data
|
||||
protocol.registerOutgoing(State.PLAY, 0x26, 0x26, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -529,8 +505,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn position
|
||||
protocol.registerOutgoing(State.PLAY, 0x4D, 0x49, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_POSITION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
|
@ -27,7 +27,7 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14> {
|
||||
@ -55,8 +55,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
protected void registerPackets() {
|
||||
positionHandler = new EntityPositionHandler(this, EntityPositionStorage1_14.class, EntityPositionStorage1_14::new);
|
||||
|
||||
// Entity status
|
||||
protocol.registerOutgoing(State.PLAY, 0x1B, 0x1C, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.ENTITY_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@ -81,8 +80,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Entity teleport
|
||||
protocol.registerOutgoing(State.PLAY, 0x56, 0x50, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.ENTITY_TELEPORT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -93,7 +91,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Entity relative move + Entity look and relative move
|
||||
PacketRemapper relativeMoveHandler = new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -112,11 +109,10 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
});
|
||||
}
|
||||
};
|
||||
protocol.registerOutgoing(State.PLAY, 0x28, 0x28, relativeMoveHandler);
|
||||
protocol.registerOutgoing(State.PLAY, 0x29, 0x29, relativeMoveHandler);
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.ENTITY_POSITION, relativeMoveHandler);
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.ENTITY_POSITION_AND_ROTATION, relativeMoveHandler);
|
||||
|
||||
// Spawn Object
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -187,8 +183,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -232,8 +227,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
getProtocol().registerOutgoing(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||
getProtocol().registerOutgoing(ClientboundPackets1_14.SPAWN_EXPERIENCE_ORB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -244,8 +238,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Global Object
|
||||
getProtocol().registerOutgoing(State.PLAY, 0x02, 0x02, new PacketRemapper() {
|
||||
getProtocol().registerOutgoing(ClientboundPackets1_14.SPAWN_GLOBAL_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -257,8 +250,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn painting
|
||||
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PAINTING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -272,8 +264,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -290,14 +281,10 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
registerEntityDestroy(0x37, 0x35);
|
||||
registerEntityDestroy(ClientboundPackets1_14.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_14.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST);
|
||||
|
||||
// Entity Metadata packet
|
||||
registerMetadataRewriter(0x43, 0x3F, Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST);
|
||||
|
||||
// Join game
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
@ -319,8 +306,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Respawn
|
||||
protocol.registerOutgoing(State.PLAY, 0x3A, 0x38, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
@ -332,7 +318,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
int dimensionId = wrapper.get(Type.INT, 0);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 0); // todo - do we need to store it from difficulty packet?
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 0); // Difficulty
|
||||
wrapper.user().get(ChunkLightStorage.class).clear();
|
||||
}
|
||||
});
|
||||
|
@ -7,7 +7,8 @@ import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
|
||||
public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
|
||||
@ -17,8 +18,7 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Server Difficulty
|
||||
protocol.registerOutgoing(State.PLAY, 0x0D, 0x0D, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SERVER_DIFFICULTY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
@ -26,25 +26,20 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
}
|
||||
});
|
||||
|
||||
// Open Sign Editor
|
||||
protocol.registerOutgoing(State.PLAY, 0x2F, 0x2C, new PacketRemapper() { // c
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.OPEN_SIGN_EDITOR, new PacketRemapper() { // c
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
}
|
||||
});
|
||||
|
||||
// Query Block NBT
|
||||
protocol.registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.QUERY_BLOCK_NBT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
|
||||
// Player Digging
|
||||
protocol.registerIncoming(State.PLAY, 0x1A, 0x18, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.PLAYER_DIGGING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -53,8 +48,7 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
}
|
||||
});
|
||||
|
||||
// Recipe Book Data
|
||||
protocol.registerIncoming(State.PLAY, 0x1D, 0x1B, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.RECIPE_BOOK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -81,32 +75,26 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
}
|
||||
});
|
||||
|
||||
// Update Command Block
|
||||
protocol.registerIncoming(State.PLAY, 0x24, 0x22, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
protocol.registerIncoming(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
protocol.registerIncoming(ServerboundPackets1_13.UPDATE_SIGN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
|
||||
// Update Structure Block
|
||||
protocol.registerIncoming(State.PLAY, 0x28, 0x25, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
|
||||
// Update Sign
|
||||
protocol.registerIncoming(State.PLAY, 0x29, 0x26, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
|
||||
// Player Block Placement
|
||||
protocol.registerIncoming(State.PLAY, 0x2C, 0x29, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
|
@ -10,7 +10,7 @@ import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositio
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
|
||||
public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
|
||||
@ -22,12 +22,12 @@ public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
protected void registerPackets() {
|
||||
SoundRewriter soundRewriter = new SoundRewriter(protocol,
|
||||
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
|
||||
soundRewriter.registerSound(0x51, 0x4D);
|
||||
soundRewriter.registerNamedSound(0x19, 0x1A);
|
||||
soundRewriter.registerStopSound(0x52, 0x4C);
|
||||
soundRewriter.registerSound(ClientboundPackets1_14.SOUND);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_14.NAMED_SOUND);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_14.STOP_SOUND);
|
||||
|
||||
// Entity Sound Effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x50, -1, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.ENTITY_SOUND, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
|
@ -13,10 +13,15 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
||||
|
||||
public Protocol1_13To1_13_1() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
@ -25,16 +30,15 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
WorldPackets1_13_1.register(this);
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerChatMessage(0x0E, 0x0E);
|
||||
translatableRewriter.registerLegacyOpenWindow(0x14, 0x14);
|
||||
translatableRewriter.registerCombatEvent(0x2F, 0x2F);
|
||||
translatableRewriter.registerDisconnect(0x1B, 0x1B);
|
||||
translatableRewriter.registerPlayerList(0x4E, 0x4E);
|
||||
translatableRewriter.registerTitle(0x4B, 0x4B);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_WINDOW);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
//Tab complete
|
||||
registerIncoming(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -48,8 +52,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
//Edit Book
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLAT_ITEM);
|
||||
@ -64,8 +67,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Tab complete
|
||||
registerOutgoing(State.PLAY, 0x10, 0x10, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Transaction id
|
||||
@ -91,8 +93,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Boss bar
|
||||
registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_13.BOSSBAR, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UUID);
|
||||
@ -117,9 +118,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -161,8 +160,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Tags
|
||||
registerOutgoing(State.PLAY, 0x55, 0x55, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
|
@ -14,7 +14,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13_1> {
|
||||
|
||||
@ -24,8 +24,7 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Spawn Object
|
||||
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -62,14 +61,10 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
registerExtraTracker(0x01, Entity1_13Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, Entity1_13Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, Entity1_13Types.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
// Spawn Global Entity
|
||||
registerExtraTracker(0x02, Entity1_13Types.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
// Spawn Mob
|
||||
protocol.out(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -105,8 +100,7 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.out(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -122,20 +116,11 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Painting
|
||||
registerExtraTracker(0x04, Entity1_13Types.EntityType.PAINTING);
|
||||
|
||||
// Join Game
|
||||
registerJoinGame(0x25, 0x25, Entity1_13Types.EntityType.PLAYER);
|
||||
|
||||
// Respawn
|
||||
registerRespawn(0x38, 0x38);
|
||||
|
||||
// Destroy entities
|
||||
registerEntityDestroy(0x35);
|
||||
|
||||
// Entity Metadata packet
|
||||
registerMetadataRewriter(0x3F, 0x3F, Types1_13.METADATA_LIST);
|
||||
registerExtraTracker(ClientboundPackets1_13.SPAWN_PAINTING, Entity1_13Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_13.JOIN_GAME, Entity1_13Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_13.RESPAWN);
|
||||
registerEntityDestroy(ClientboundPackets1_13.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, Types1_13.METADATA_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,24 +7,19 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
|
||||
public class InventoryPackets1_13_1 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets1_13_1::toClient, InventoryPackets1_13_1::toServer);
|
||||
|
||||
// Set cooldown
|
||||
itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets1_13_1::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets1_13_1::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.FLAT_ITEM_ARRAY, 0x15, 0x15);
|
||||
|
||||
// Set slot packet
|
||||
itemRewriter.registerSetSlot(Type.FLAT_ITEM, 0x17, 0x17);
|
||||
|
||||
// Plugin Message
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -60,14 +55,9 @@ public class InventoryPackets1_13_1 {
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
itemRewriter.registerEntityEquipment(Type.FLAT_ITEM, 0x42, 0x42);
|
||||
|
||||
// Click window packet
|
||||
itemRewriter.registerClickWindow(Type.FLAT_ITEM, 0x08, 0x08);
|
||||
|
||||
// Creative Inventory Action
|
||||
itemRewriter.registerCreativeInvAction(Type.FLAT_ITEM, 0x24, 0x24);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_ITEM);
|
||||
}
|
||||
|
||||
public static void toClient(Item item) {
|
||||
|
@ -9,7 +9,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
@ -18,8 +18,7 @@ public class WorldPackets1_13_1 {
|
||||
public static void register(Protocol protocol) {
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13To1_13_1::getNewBlockStateId, Protocol1_13To1_13_1::getNewBlockId);
|
||||
|
||||
// Chunk
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -40,19 +39,10 @@ public class WorldPackets1_13_1 {
|
||||
}
|
||||
});
|
||||
|
||||
// Block Action
|
||||
blockRewriter.registerBlockAction(0x0A, 0x0A);
|
||||
|
||||
// Block Change
|
||||
blockRewriter.registerBlockChange(0xB, 0xB);
|
||||
|
||||
// Multi Block Change
|
||||
blockRewriter.registerMultiBlockChange(0xF, 0xF);
|
||||
|
||||
// Effect packet
|
||||
blockRewriter.registerEffect(0x23, 0x23, 1010, 2001, InventoryPackets1_13_1::getOldItemId);
|
||||
|
||||
// Spawn particle
|
||||
blockRewriter.registerSpawnParticle(Type.FLOAT, 0x24, 0x24, 3, 20, 27, InventoryPackets1_13_1::toClient, Type.FLAT_ITEM);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001, InventoryPackets1_13_1::getOldItemId);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27, InventoryPackets1_13_1::toClient, Type.FLAT_ITEM, Type.FLOAT);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,12 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_14_1to1_14_2;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
|
||||
public class Protocol1_14_1To1_14_2 extends BackwardsProtocol {
|
||||
public class Protocol1_14_1To1_14_2 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
public Protocol1_14_1To1_14_2() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,21 @@ package nl.matsv.viabackwards.protocol.protocol1_14_2to1_14_3;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
|
||||
public class Protocol1_14_2To1_14_3 extends BackwardsProtocol {
|
||||
public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_14_2To1_14_3() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Trade list
|
||||
registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -44,8 +47,7 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Declare recipes
|
||||
registerOutgoing(State.PLAY, 0x5A, 0x5A, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -66,30 +68,51 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol {
|
||||
wrapper.write(Type.STRING, fullType);
|
||||
wrapper.write(Type.STRING, id);
|
||||
|
||||
if (type.equals("crafting_shapeless")) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
}
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||
|
||||
break;
|
||||
}
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||
} else if (type.equals("crafting_shaped")) {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
case "crafting_shaped": {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
}
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||
|
||||
break;
|
||||
}
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||
} else if (type.equals("stonecutting")) {
|
||||
wrapper.passthrough(Type.STRING); // Group?
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); // Result
|
||||
} else if (type.equals("smelting") || type.equals("blasting") || type.equals("campfire_cooking") || type.equals("smoking")) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
case "stonecutting":
|
||||
wrapper.passthrough(Type.STRING); // Group?
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); // Result
|
||||
|
||||
break;
|
||||
case "smelting":
|
||||
case "blasting":
|
||||
case "campfire_cooking":
|
||||
case "smoking":
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,8 +122,4 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,22 @@ package nl.matsv.viabackwards.protocol.protocol1_14_3to1_14_4;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
|
||||
public class Protocol1_14_3To1_14_4 extends BackwardsProtocol {
|
||||
public class Protocol1_14_3To1_14_4 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_14_3To1_14_4() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Acknowledge Player Digging - added in pre4
|
||||
registerOutgoing(State.PLAY, 0x5C, 0x0B, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14);
|
||||
@ -21,13 +25,14 @@ public class Protocol1_14_3To1_14_4 extends BackwardsProtocol {
|
||||
handler(wrapper -> {
|
||||
int status = wrapper.read(Type.VAR_INT);
|
||||
boolean allGood = wrapper.read(Type.BOOLEAN);
|
||||
if (allGood && status == 0) wrapper.cancel();
|
||||
if (allGood && status == 0) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Trade list
|
||||
registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -54,8 +59,4 @@ public class Protocol1_14_3To1_14_4 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
}
|
||||
}
|
||||
|
@ -16,26 +16,33 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
private BlockItemPackets1_15 blockItemPackets;
|
||||
|
||||
public Protocol1_14_4To1_15() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_15To1_14_4.class, BackwardsMappings::init);
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(0x0D, 0x0C);
|
||||
translatableRewriter.registerChatMessage(0x0F, 0x0E);
|
||||
translatableRewriter.registerCombatEvent(0x33, 0x32);
|
||||
translatableRewriter.registerDisconnect(0x1B, 0x1A);
|
||||
translatableRewriter.registerOpenWindow(0x2F, 0x2E);
|
||||
translatableRewriter.registerPlayerList(0x54, 0x53);
|
||||
translatableRewriter.registerTitle(0x50, 0x4F);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_15.BOSSBAR);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_15.CHAT_MESSAGE);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_15.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_15.DISCONNECT);
|
||||
translatableRewriter.registerOpenWindow(ClientboundPackets1_15.OPEN_WINDOW);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_15.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_15.TITLE);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
(blockItemPackets = new BlockItemPackets1_15(this, translatableRewriter)).register();
|
||||
@ -43,13 +50,13 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this,
|
||||
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
|
||||
soundRewriter.registerSound(0x52, 0x51);
|
||||
soundRewriter.registerSound(0x51, 0x50);
|
||||
soundRewriter.registerNamedSound(0x1A, 0x19);
|
||||
soundRewriter.registerStopSound(0x53, 0x52);
|
||||
soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_15.NAMED_SOUND);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_15.STOP_SOUND);
|
||||
|
||||
// Explosion - manually send an explosion sound
|
||||
registerOutgoing(State.PLAY, 0x1D, 0x1C, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_15.EXPLOSION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLOAT); // x
|
||||
@ -73,8 +80,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x58, 0x57, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_15.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -113,8 +119,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Tags
|
||||
registerOutgoing(State.PLAY, 0x5C, 0x5B, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_15.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -158,58 +163,6 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(State.PLAY, 0x09, 0x08);
|
||||
registerOutgoing(State.PLAY, 0x0A, 0x09);
|
||||
registerOutgoing(State.PLAY, 0x0E, 0x0D);
|
||||
registerOutgoing(State.PLAY, 0x11, 0x10);
|
||||
registerOutgoing(State.PLAY, 0x12, 0x11);
|
||||
registerOutgoing(State.PLAY, 0x13, 0x12);
|
||||
registerOutgoing(State.PLAY, 0x14, 0x13);
|
||||
registerOutgoing(State.PLAY, 0x16, 0x15);
|
||||
registerOutgoing(State.PLAY, 0x19, 0x18);
|
||||
registerOutgoing(State.PLAY, 0x1C, 0x1B);
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x1D);
|
||||
registerOutgoing(State.PLAY, 0x20, 0x1F);
|
||||
registerOutgoing(State.PLAY, 0x21, 0x20);
|
||||
registerOutgoing(State.PLAY, 0x25, 0x24);
|
||||
registerOutgoing(State.PLAY, 0x27, 0x26);
|
||||
registerOutgoing(State.PLAY, 0x29, 0x28);
|
||||
registerOutgoing(State.PLAY, 0x2A, 0x29);
|
||||
registerOutgoing(State.PLAY, 0x2B, 0x2A);
|
||||
registerOutgoing(State.PLAY, 0x2C, 0x2B);
|
||||
registerOutgoing(State.PLAY, 0x2D, 0x2C);
|
||||
registerOutgoing(State.PLAY, 0x2E, 0x2D);
|
||||
registerOutgoing(State.PLAY, 0x30, 0x2F);
|
||||
registerOutgoing(State.PLAY, 0x31, 0x30);
|
||||
registerOutgoing(State.PLAY, 0x32, 0x31);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x33);
|
||||
registerOutgoing(State.PLAY, 0x35, 0x34);
|
||||
registerOutgoing(State.PLAY, 0x36, 0x35);
|
||||
registerOutgoing(State.PLAY, 0x37, 0x36);
|
||||
registerOutgoing(State.PLAY, 0x39, 0x38);
|
||||
registerOutgoing(State.PLAY, 0x3A, 0x39);
|
||||
registerOutgoing(State.PLAY, 0x3C, 0x3B);
|
||||
registerOutgoing(State.PLAY, 0x3D, 0x3C);
|
||||
registerOutgoing(State.PLAY, 0x3E, 0x3D);
|
||||
registerOutgoing(State.PLAY, 0x3F, 0x3E);
|
||||
registerOutgoing(State.PLAY, 0x40, 0x3F);
|
||||
registerOutgoing(State.PLAY, 0x41, 0x40);
|
||||
registerOutgoing(State.PLAY, 0x42, 0x41);
|
||||
registerOutgoing(State.PLAY, 0x43, 0x42);
|
||||
registerOutgoing(State.PLAY, 0x45, 0x44);
|
||||
registerOutgoing(State.PLAY, 0x46, 0x45);
|
||||
registerOutgoing(State.PLAY, 0x48, 0x47);
|
||||
registerOutgoing(State.PLAY, 0x4A, 0x49);
|
||||
registerOutgoing(State.PLAY, 0x4B, 0x4A);
|
||||
registerOutgoing(State.PLAY, 0x4C, 0x4B);
|
||||
registerOutgoing(State.PLAY, 0x4D, 0x4C);
|
||||
registerOutgoing(State.PLAY, 0x4E, 0x4D);
|
||||
registerOutgoing(State.PLAY, 0x4F, 0x4E);
|
||||
registerOutgoing(State.PLAY, 0x55, 0x54);
|
||||
registerOutgoing(State.PLAY, 0x56, 0x55);
|
||||
registerOutgoing(State.PLAY, 0x57, 0x56);
|
||||
registerOutgoing(State.PLAY, 0x5A, 0x59);
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
|
@ -8,7 +8,7 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_15 extends RecipeRewriter1_14 {
|
||||
|
||||
public RecipeRewriter1_15(final ItemRewriterBase rewriter) {
|
||||
public RecipeRewriter1_15(ItemRewriterBase rewriter) {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,9 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
@ -32,28 +33,20 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_14_4To1_15::getNewBlockStateId, Protocol1_14_4To1_15::getNewBlockId);
|
||||
|
||||
// Declare Recipes
|
||||
new RecipeRewriter1_15(this).registerDefaultHandler(0x5B, 0x5A);
|
||||
new RecipeRewriter1_15(this).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
|
||||
// Edit Book
|
||||
protocol.registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
|
||||
// Set cooldown
|
||||
itemRewriter.registerSetCooldown(0x18, 0x17, BlockItemPackets1_15::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN, BlockItemPackets1_15::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x14);
|
||||
|
||||
// Set slot packet
|
||||
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x17, 0x16);
|
||||
|
||||
// Trade list
|
||||
protocol.out(State.PLAY, 0x28, 0x27, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -92,29 +85,16 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x47, 0x46);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Click window packet
|
||||
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09);
|
||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
|
||||
|
||||
// Creative Inventory Action
|
||||
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x26);
|
||||
|
||||
// Acknowledge player digging
|
||||
blockRewriter.registerAcknowledgePlayerDigging(0x08, 0x5C);
|
||||
|
||||
// Block Action
|
||||
blockRewriter.registerBlockAction(0x0B, 0x0A);
|
||||
|
||||
// Block Change
|
||||
blockRewriter.registerBlockChange(0x0C, 0x0B);
|
||||
|
||||
// Multi Block Change
|
||||
blockRewriter.registerMultiBlockChange(0x10, 0x0F);
|
||||
|
||||
// Chunk
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x21, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -161,11 +141,9 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Effect packet
|
||||
blockRewriter.registerEffect(0x23, 0x22, 1010, 2001, BlockItemPackets1_15::getOldItemId);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001, BlockItemPackets1_15::getOldItemId);
|
||||
|
||||
// Spawn particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x23, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
|
@ -17,7 +17,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -29,8 +29,7 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Update health
|
||||
protocol.registerOutgoing(State.PLAY, 0x49, 0x48, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.UPDATE_HEALTH, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@ -46,8 +45,7 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
}
|
||||
});
|
||||
|
||||
// Change game state
|
||||
protocol.registerOutgoing(State.PLAY, 0x1F, 0x1E, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.GAME_EVENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
@ -60,11 +58,9 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Object
|
||||
registerSpawnTrackerWithData(0x00, 0x00, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_14_4To1_15::getNewBlockStateId);
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_14_4To1_15::getNewBlockStateId);
|
||||
|
||||
// Spawn mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -90,8 +86,7 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
}
|
||||
});
|
||||
|
||||
// Respawn
|
||||
protocol.registerOutgoing(State.PLAY, 0x3B, 0x3A, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
@ -100,8 +95,7 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
}
|
||||
});
|
||||
|
||||
// Join Game
|
||||
protocol.registerOutgoing(State.PLAY, 0x26, 0x25, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
@ -122,17 +116,11 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
registerExtraTracker(0x01, Entity1_15Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_15.SPAWN_EXPERIENCE_ORB, Entity1_15Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, Entity1_15Types.EntityType.LIGHTNING_BOLT);
|
||||
registerExtraTracker(ClientboundPackets1_15.SPAWN_PAINTING, Entity1_15Types.EntityType.PAINTING);
|
||||
|
||||
// Spawn Global Object
|
||||
registerExtraTracker(0x02, Entity1_15Types.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
// Spawn painting
|
||||
registerExtraTracker(0x04, Entity1_15Types.EntityType.PAINTING);
|
||||
|
||||
// Spawn player packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -148,14 +136,11 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
registerEntityDestroy(0x38, 0x37);
|
||||
|
||||
// Entity Metadata packet
|
||||
registerMetadataRewriter(0x44, 0x43, Types1_14.METADATA_LIST);
|
||||
registerEntityDestroy(ClientboundPackets1_15.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
|
||||
// Attributes (get rid of generic.flyingSpeed for the Bee remap)
|
||||
protocol.registerOutgoing(State.PLAY, 0x59, 0x58, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
|
@ -4,8 +4,15 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.packets.EntityPackets1_14_1;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
public class Protocol1_14To1_14_1 extends BackwardsProtocol {
|
||||
public class Protocol1_14To1_14_1 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_14To1_14_1() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
@ -15,8 +22,9 @@ public class Protocol1_14To1_14_1 extends BackwardsProtocol {
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
@ -10,7 +10,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
|
||||
public class EntityPackets1_14_1 extends LegacyEntityRewriter<Protocol1_14To1_14_1> {
|
||||
|
||||
@ -20,15 +20,14 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<Protocol1_14To1_14
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerExtraTracker(0x01, Entity1_14Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(0x02, Entity1_14Types.EntityType.LIGHTNING_BOLT);
|
||||
registerExtraTracker(0x04, Entity1_14Types.EntityType.PAINTING);
|
||||
registerExtraTracker(0x05, Entity1_14Types.EntityType.PLAYER);
|
||||
registerExtraTracker(0x25, Entity1_14Types.EntityType.PLAYER, Type.INT); // Join game
|
||||
registerEntityDestroy(0x37);
|
||||
registerExtraTracker(ClientboundPackets1_14.SPAWN_EXPERIENCE_ORB, Entity1_14Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_14.SPAWN_GLOBAL_ENTITY, Entity1_14Types.EntityType.LIGHTNING_BOLT);
|
||||
registerExtraTracker(ClientboundPackets1_14.SPAWN_PAINTING, Entity1_14Types.EntityType.PAINTING);
|
||||
registerExtraTracker(ClientboundPackets1_14.SPAWN_PLAYER, Entity1_14Types.EntityType.PLAYER);
|
||||
registerExtraTracker(ClientboundPackets1_14.JOIN_GAME, Entity1_14Types.EntityType.PLAYER, Type.INT);
|
||||
registerEntityDestroy(ClientboundPackets1_14.DESTROY_ENTITIES);
|
||||
|
||||
// Spawn Object
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -39,8 +38,7 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<Protocol1_14To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Mob
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -74,7 +72,7 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<Protocol1_14To1_14
|
||||
});
|
||||
|
||||
// Entity Metadata
|
||||
registerMetadataRewriter(0x43, 0x43, Types1_14.METADATA_LIST);
|
||||
registerMetadataRewriter(ClientboundPackets1_14.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,14 +2,12 @@ package nl.matsv.viabackwards.protocol.protocol1_15_1to1_15_2;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
public class Protocol1_15_1To1_15_2 extends BackwardsProtocol {
|
||||
public class Protocol1_15_1To1_15_2 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
public Protocol1_15_1To1_15_2() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
|
@ -14,35 +14,42 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.TagRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Protocol1_15_2To1_16 extends BackwardsProtocol {
|
||||
public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_16, ClientboundPackets1_15, ServerboundPackets1_16, ServerboundPackets1_14> {
|
||||
|
||||
private BlockItemPackets1_16 blockItemPackets;
|
||||
private TranslatableRewriter translatableRewriter;
|
||||
|
||||
public Protocol1_15_2To1_16() {
|
||||
super(ClientboundPackets1_16.class, ClientboundPackets1_15.class, ServerboundPackets1_16.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_16To1_15_2.class, BackwardsMappings::init);
|
||||
|
||||
translatableRewriter = new TranslatableRewriter1_16(this);
|
||||
translatableRewriter.registerBossBar(0x0C, 0x0D);
|
||||
translatableRewriter.registerCombatEvent(0x32, 0x33);
|
||||
translatableRewriter.registerDisconnect(0x1A, 0x1B);
|
||||
translatableRewriter.registerPlayerList(0x53, 0x54);
|
||||
translatableRewriter.registerTitle(0x4F, 0x50);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_16.BOSSBAR);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_16.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_16.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_16.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_16.TITLE);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
(blockItemPackets = new BlockItemPackets1_16(this, translatableRewriter)).register();
|
||||
EntityPackets1_16 entityPackets = new EntityPackets1_16(this);
|
||||
entityPackets.register();
|
||||
|
||||
// Chat Message
|
||||
registerOutgoing(State.PLAY, 0x0E, 0x0F, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_16.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING))));
|
||||
@ -51,8 +58,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Open Window
|
||||
registerOutgoing(State.PLAY, 0x2E, 0x2F, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_16.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Window Id
|
||||
@ -71,10 +77,10 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol {
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this,
|
||||
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
|
||||
soundRewriter.registerSound(0x50, 0x51);
|
||||
soundRewriter.registerSound(0x51, 0x52);
|
||||
soundRewriter.registerNamedSound(0x10, 0x1A);
|
||||
soundRewriter.registerStopSound(0x52, 0x53);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_16.NAMED_SOUND);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_16.STOP_SOUND);
|
||||
|
||||
// Login success
|
||||
registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
|
||||
@ -88,8 +94,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x57, 0x58, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_16.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@ -125,89 +130,12 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Tags
|
||||
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id -> {
|
||||
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||
return oldId != null ? oldId : -1;
|
||||
}, entityPackets::getOldEntityId).register(0x5B, 0x5C);
|
||||
}, entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x05, 0x06);
|
||||
registerOutgoing(State.PLAY, 0x06, 0x07);
|
||||
registerOutgoing(State.PLAY, 0x08, 0x09);
|
||||
registerOutgoing(State.PLAY, 0x09, 0x0A);
|
||||
registerOutgoing(State.PLAY, 0x0D, 0x0E);
|
||||
registerOutgoing(State.PLAY, 0x11, 0x12);
|
||||
registerOutgoing(State.PLAY, 0x12, 0x13);
|
||||
registerOutgoing(State.PLAY, 0x13, 0x14);
|
||||
registerOutgoing(State.PLAY, 0x18, 0x19);
|
||||
registerOutgoing(State.PLAY, 0x19, 0x1A);
|
||||
registerOutgoing(State.PLAY, 0x1B, 0x1C);
|
||||
registerOutgoing(State.PLAY, 0x1C, 0x1D);
|
||||
registerOutgoing(State.PLAY, 0x1D, 0x1E);
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x1F);
|
||||
registerOutgoing(State.PLAY, 0x1F, 0x20);
|
||||
registerOutgoing(State.PLAY, 0x20, 0x21);
|
||||
registerOutgoing(State.PLAY, 0x24, 0x25);
|
||||
registerOutgoing(State.PLAY, 0x26, 0x27);
|
||||
registerOutgoing(State.PLAY, 0x28, 0x29);
|
||||
registerOutgoing(State.PLAY, 0x29, 0x2A);
|
||||
registerOutgoing(State.PLAY, 0x2A, 0x2B);
|
||||
registerOutgoing(State.PLAY, 0x2B, 0x2C);
|
||||
registerOutgoing(State.PLAY, 0x2C, 0x2D);
|
||||
registerOutgoing(State.PLAY, 0x2D, 0x2E);
|
||||
registerOutgoing(State.PLAY, 0x2F, 0x30);
|
||||
registerOutgoing(State.PLAY, 0x30, 0x31);
|
||||
registerOutgoing(State.PLAY, 0x31, 0x32);
|
||||
registerOutgoing(State.PLAY, 0x33, 0x34);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x35);
|
||||
registerOutgoing(State.PLAY, 0x35, 0x36);
|
||||
registerOutgoing(State.PLAY, 0x36, 0x37);
|
||||
registerOutgoing(State.PLAY, 0x38, 0x39);
|
||||
registerOutgoing(State.PLAY, 0x39, 0x3A);
|
||||
registerOutgoing(State.PLAY, 0x3B, 0x3C);
|
||||
registerOutgoing(State.PLAY, 0x3C, 0x3D);
|
||||
registerOutgoing(State.PLAY, 0x3D, 0x3E);
|
||||
registerOutgoing(State.PLAY, 0x3E, 0x3F);
|
||||
registerOutgoing(State.PLAY, 0x3F, 0x40);
|
||||
registerOutgoing(State.PLAY, 0x40, 0x41);
|
||||
registerOutgoing(State.PLAY, 0x41, 0x42);
|
||||
registerOutgoing(State.PLAY, 0x42, 0x4E);
|
||||
registerOutgoing(State.PLAY, 0x4E, 0x4F);
|
||||
registerOutgoing(State.PLAY, 0x54, 0x55);
|
||||
registerOutgoing(State.PLAY, 0x55, 0x56);
|
||||
registerOutgoing(State.PLAY, 0x56, 0x57);
|
||||
registerOutgoing(State.PLAY, 0x59, 0x5A);
|
||||
|
||||
cancelIncoming(State.PLAY, 0x27); // Set jigsaw
|
||||
registerIncoming(State.PLAY, 0x10, 0x0F);
|
||||
registerIncoming(State.PLAY, 0x11, 0x10);
|
||||
registerIncoming(State.PLAY, 0x12, 0x11);
|
||||
registerIncoming(State.PLAY, 0x13, 0x12);
|
||||
registerIncoming(State.PLAY, 0x14, 0x13);
|
||||
registerIncoming(State.PLAY, 0x15, 0x14);
|
||||
registerIncoming(State.PLAY, 0x16, 0x15);
|
||||
registerIncoming(State.PLAY, 0x17, 0x16);
|
||||
registerIncoming(State.PLAY, 0x18, 0x17);
|
||||
registerIncoming(State.PLAY, 0x19, 0x18);
|
||||
registerIncoming(State.PLAY, 0x1A, 0x19);
|
||||
registerIncoming(State.PLAY, 0x1B, 0x1A);
|
||||
registerIncoming(State.PLAY, 0x1C, 0x1B);
|
||||
registerIncoming(State.PLAY, 0x1D, 0x1C);
|
||||
registerIncoming(State.PLAY, 0x1E, 0x1D);
|
||||
registerIncoming(State.PLAY, 0x1F, 0x1E);
|
||||
registerIncoming(State.PLAY, 0x20, 0x1F);
|
||||
registerIncoming(State.PLAY, 0x21, 0x20);
|
||||
registerIncoming(State.PLAY, 0x22, 0x21);
|
||||
registerIncoming(State.PLAY, 0x23, 0x22);
|
||||
registerIncoming(State.PLAY, 0x24, 0x23);
|
||||
registerIncoming(State.PLAY, 0x25, 0x24);
|
||||
registerIncoming(State.PLAY, 0x26, 0x25);
|
||||
registerIncoming(State.PLAY, 0x29, 0x28);
|
||||
registerIncoming(State.PLAY, 0x2A, 0x29);
|
||||
registerIncoming(State.PLAY, 0x2B, 0x2A);
|
||||
registerIncoming(State.PLAY, 0x2C, 0x2B);
|
||||
registerIncoming(State.PLAY, 0x2D, 0x2C);
|
||||
registerIncoming(State.PLAY, 0x2E, 0x2D);
|
||||
cancelIncoming(ServerboundPackets1_14.UPDATE_JIGSAW_BLOCK);
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
@ -230,10 +158,12 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol {
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
if (!user.has(ClientWorld.class))
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
if (!user.has(EntityTracker.class))
|
||||
}
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,9 @@ import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.RecipeRewriter1_15;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class RecipeRewriter1_16 extends RecipeRewriter1_15 {
|
||||
|
||||
@ -14,9 +14,9 @@ public class RecipeRewriter1_16 extends RecipeRewriter1_15 {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
public void register(int oldId, int newId) {
|
||||
public void register(ClientboundPacketType packetType) {
|
||||
// Remove new smithing type, only in this handler
|
||||
rewriter.getProtocol().registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
rewriter.getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
|
@ -3,7 +3,6 @@ package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.RecipeRewriter1_15;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.RecipeRewriter1_16;
|
||||
@ -15,8 +14,9 @@ import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
@ -43,20 +43,13 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_15_2To1_16::getNewBlockStateId, Protocol1_15_2To1_16::getNewBlockId);
|
||||
|
||||
// Declare Recipes
|
||||
new RecipeRewriter1_16(this).register(0x5A, 0x5B);
|
||||
new RecipeRewriter1_16(this).register(ClientboundPackets1_16.DECLARE_RECIPES);
|
||||
|
||||
// Set cooldown
|
||||
itemRewriter.registerSetCooldown(0x17, 0x18, BlockItemPackets1_16::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN, BlockItemPackets1_16::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x14, 0x15);
|
||||
|
||||
// Set slot packet
|
||||
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x16, 0x17);
|
||||
|
||||
// Trade list
|
||||
protocol.out(State.PLAY, 0x27, 0x28, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@ -92,23 +85,13 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x47, 0x47);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_16.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_16.MULTI_BLOCK_CHANGE);
|
||||
|
||||
// Acknowledge player digging
|
||||
blockRewriter.registerAcknowledgePlayerDigging(0x07, 0x08);
|
||||
|
||||
// Block Action
|
||||
blockRewriter.registerBlockAction(0x0A, 0x0B);
|
||||
|
||||
// Block Change
|
||||
blockRewriter.registerBlockChange(0x0B, 0x0C);
|
||||
|
||||
// Multi Block Change
|
||||
blockRewriter.registerMultiBlockChange(0x0F, 0x10);
|
||||
|
||||
// Chunk
|
||||
protocol.registerOutgoing(State.PLAY, 0x21, 0x22, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@ -177,15 +160,11 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Effect packet
|
||||
blockRewriter.registerEffect(0x22, 0x23, 1010, 2001, BlockItemPackets1_16::getOldItemId);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001, BlockItemPackets1_16::getOldItemId);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 32,
|
||||
BlockItemPackets1_16::getNewParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
|
||||
// Spawn particle
|
||||
blockRewriter.registerSpawnParticle(Type.DOUBLE, 0x23, 0x24, 3, 23, 32,
|
||||
BlockItemPackets1_16::getNewParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Window Property
|
||||
protocol.registerOutgoing(State.PLAY, 0x15, 0x16, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Window id
|
||||
@ -205,14 +184,10 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
// Click window packet
|
||||
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Creative Inventory Action
|
||||
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x27, 0x26);
|
||||
|
||||
// Edit Book
|
||||
protocol.registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
|
@ -17,7 +17,7 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
@ -43,14 +43,10 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Spawn Object
|
||||
registerSpawnTrackerWithData(0x00, 0x00, Entity1_16Types.EntityType.FALLING_BLOCK, Protocol1_15_2To1_16::getNewBlockStateId);
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16Types.EntityType.FALLING_BLOCK, Protocol1_15_2To1_16::getNewBlockStateId);
|
||||
registerSpawnTracker(ClientboundPackets1_16.SPAWN_MOB);
|
||||
|
||||
// Spawn mob packet
|
||||
registerSpawnTracker(0x02, 0x03);
|
||||
|
||||
// Respawn
|
||||
protocol.registerOutgoing(State.PLAY, 0x3A, 0x3B, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(dimensionTransformer); // Dimension Type
|
||||
@ -71,8 +67,7 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
}
|
||||
});
|
||||
|
||||
// Join Game
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x26, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Entity ID
|
||||
@ -102,25 +97,14 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
registerExtraTracker(0x01, Entity1_16Types.EntityType.EXPERIENCE_ORB);
|
||||
|
||||
registerExtraTracker(ClientboundPackets1_16.SPAWN_EXPERIENCE_ORB, Entity1_16Types.EntityType.EXPERIENCE_ORB);
|
||||
// F Spawn Global Object, it is no longer with us :(
|
||||
registerExtraTracker(ClientboundPackets1_16.SPAWN_PAINTING, Entity1_16Types.EntityType.PAINTING);
|
||||
registerExtraTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16Types.EntityType.PLAYER);
|
||||
registerEntityDestroy(ClientboundPackets1_16.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
|
||||
// Spawn painting
|
||||
registerExtraTracker(0x03, 0x04, Entity1_16Types.EntityType.PAINTING);
|
||||
|
||||
// Spawn player packet
|
||||
registerExtraTracker(0x04, 0x05, Entity1_16Types.EntityType.PLAYER);
|
||||
|
||||
// Destroy entities
|
||||
registerEntityDestroy(0x37, 0x38);
|
||||
|
||||
// Entity Metadata packet
|
||||
registerMetadataRewriter(0x44, 0x44, Types1_14.METADATA_LIST);
|
||||
|
||||
// Entity Properties
|
||||
protocol.out(State.PLAY, 0x58, 0x59, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
|
@ -2,14 +2,12 @@ package nl.matsv.viabackwards.protocol.protocol1_15to1_15_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
public class Protocol1_15To1_15_1 extends BackwardsProtocol {
|
||||
public class Protocol1_15To1_15_1 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
public Protocol1_15To1_15_1() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
|
@ -13,31 +13,48 @@ package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.ChangedPackets1_10;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets1_10;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.SoundPackets1_10;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_9_4To1_10 extends BackwardsProtocol {
|
||||
public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
private EntityPackets1_10 entityPackets; // Required for the item rewriter
|
||||
private BlockItemPackets1_10 blockItemPackets;
|
||||
|
||||
public Protocol1_9_4To1_10() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
protected void registerPackets() {
|
||||
new ChangedPackets1_10().register(this);
|
||||
new SoundPackets1_10(this).register();
|
||||
(entityPackets = new EntityPackets1_10(this)).register();
|
||||
(blockItemPackets = new BlockItemPackets1_10(this)).register();
|
||||
|
||||
registerIncoming(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING, Type.NOTHING); // 0 - Hash
|
||||
map(Type.VAR_INT); // 1 - Result
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class))
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
@ -21,8 +21,9 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<Protocol1_9_4To1_10> {
|
||||
@ -35,17 +36,13 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<Protocol1_9_4T
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
|
||||
// Set slot packet
|
||||
itemRewriter.registerSetSlot(Type.ITEM, 0x16, 0x16);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.ITEM_ARRAY, 0x14, 0x14);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
|
||||
// Entity Equipment Packet
|
||||
itemRewriter.registerEntityEquipment(Type.ITEM, 0x3C, 0x3C);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
@ -62,8 +59,9 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<Protocol1_9_4T
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem)
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
@ -75,70 +73,61 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<Protocol1_9_4T
|
||||
}
|
||||
});
|
||||
|
||||
// Click window packet
|
||||
itemRewriter.registerClickWindow(Type.ITEM, 0x07, 0x07);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
// Creative Inventory Action
|
||||
itemRewriter.registerCreativeInvAction(Type.ITEM, 0x18, 0x18);
|
||||
|
||||
|
||||
/* Block packets */
|
||||
// Chunk packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
}
|
||||
});
|
||||
handleChunk(chunk);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
});
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x10, 0x10, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Rewrite metadata items
|
||||
protocol.getEntityPackets().registerMetaHandler().handle(e -> {
|
||||
@ -151,7 +140,7 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<Protocol1_9_4T
|
||||
});
|
||||
|
||||
// Particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class ChangedPackets1_10 {
|
||||
|
||||
public void register(BackwardsProtocol protocol) {
|
||||
/* ServerBound packets */
|
||||
|
||||
// ResourcePack status
|
||||
protocol.registerIncoming(State.PLAY, 0x16, 0x16, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING, Type.NOTHING); // 0 - Hash
|
||||
map(Type.VAR_INT); // 1 - Result
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -39,8 +39,7 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<Protocol1_9_4To1_10>
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Spawn Object
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -78,14 +77,10 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<Protocol1_9_4To1_10>
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
registerExtraTracker(0x01, Entity1_10Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_10Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_10Types.EntityType.WEATHER);
|
||||
|
||||
// Spawn Global Entity
|
||||
registerExtraTracker(0x02, Entity1_10Types.EntityType.WEATHER);
|
||||
|
||||
// Spawn Mob
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -138,17 +133,11 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<Protocol1_9_4To1_10>
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Painting
|
||||
registerExtraTracker(0x04, Entity1_10Types.EntityType.PAINTING);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_10Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_10Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
// Join game
|
||||
registerJoinGame(0x23, 0x23, Entity1_10Types.EntityType.PLAYER);
|
||||
|
||||
// Respawn Packet
|
||||
registerRespawn(0x33, 0x33);
|
||||
|
||||
// Spawn Player
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -164,11 +153,8 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<Protocol1_9_4To1_10>
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
registerEntityDestroy(0x30);
|
||||
|
||||
// Metadata packet
|
||||
registerMetadataRewriter(0x39, 0x39, Types1_9.METADATA_LIST);
|
||||
registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
public class SoundPackets1_10 extends LegacySoundRewriter<Protocol1_9_4To1_10> {
|
||||
protected static ValueTransformer<Float, Short> toOldPitch = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) {
|
||||
@ -32,8 +32,7 @@ public class SoundPackets1_10 extends LegacySoundRewriter<Protocol1_9_4To1_10> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Named sound effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Sound name
|
||||
@ -46,8 +45,7 @@ public class SoundPackets1_10 extends LegacySoundRewriter<Protocol1_9_4To1_10> {
|
||||
}
|
||||
});
|
||||
|
||||
// Sound effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Sound name
|
||||
@ -63,13 +61,15 @@ public class SoundPackets1_10 extends LegacySoundRewriter<Protocol1_9_4To1_10> {
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int oldId = wrapper.get(Type.VAR_INT, 0);
|
||||
int newId = handleSounds(oldId);
|
||||
if (newId == -1)
|
||||
if (newId == -1) {
|
||||
wrapper.cancel();
|
||||
else {
|
||||
if (hasPitch(oldId))
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) Math.round(handlePitch(oldId) * 63.5F));
|
||||
wrapper.set(Type.VAR_INT, 0, newId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasPitch(oldId)) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) Math.round(handlePitch(oldId) * 63.5F));
|
||||
}
|
||||
wrapper.set(Type.VAR_INT, 0, newId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
8
pom.xml
8
pom.xml
@ -57,5 +57,13 @@
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JetBrains Annotations -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>19.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
Loading…
Reference in New Issue
Block a user