Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Merge branch 'refs/heads/dev' into preview
# Conflicts: # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13_1to1_13/metadata/MetadataRewriter1_13_1To1_13.java # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/metadata/MetadataRewriter1_16_2To1_16_1.java # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/metadata/MetadataRewriter1_16To1_15_2.java # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/EntityPackets.java # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java # common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java
Dieser Commit ist enthalten in:
Commit
27b5fdb4ff
@ -38,6 +38,7 @@ import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypeMap;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.rewriter.MappingDataListener;
|
||||
import com.viaversion.viaversion.api.rewriter.Rewriter;
|
||||
import com.viaversion.viaversion.exception.CancelException;
|
||||
import com.viaversion.viaversion.exception.InformativeException;
|
||||
@ -211,6 +212,7 @@ public abstract class AbstractProtocol<CU extends ClientboundPacketType, CM exte
|
||||
protected void onMappingDataLoaded() {
|
||||
callOnMappingDataLoaded(getEntityRewriter());
|
||||
callOnMappingDataLoaded(getItemRewriter());
|
||||
callOnMappingDataLoaded(getTagRewriter());
|
||||
}
|
||||
|
||||
private void callRegister(@Nullable Rewriter<?> rewriter) {
|
||||
@ -219,7 +221,7 @@ public abstract class AbstractProtocol<CU extends ClientboundPacketType, CM exte
|
||||
}
|
||||
}
|
||||
|
||||
private void callOnMappingDataLoaded(@Nullable Rewriter<?> rewriter) {
|
||||
private void callOnMappingDataLoaded(@Nullable MappingDataListener rewriter) {
|
||||
if (rewriter != null) {
|
||||
rewriter.onMappingDataLoaded();
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.Rewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.TagRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@ -350,6 +352,15 @@ public interface Protocol<CU extends ClientboundPacketType, CM extends Clientbou
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol's tag rewriter if present.
|
||||
*
|
||||
* @return tag rewriter
|
||||
*/
|
||||
default @Nullable TagRewriter getTagRewriter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this protocol is a base protocol.
|
||||
*
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* 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 com.viaversion.viaversion.api.rewriter;
|
||||
|
||||
public interface MappingDataListener {
|
||||
|
||||
default void onMappingDataLoaded() {
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ package com.viaversion.viaversion.api.rewriter;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
|
||||
public interface Rewriter<T extends Protocol> {
|
||||
public interface Rewriter<T extends Protocol> extends MappingDataListener {
|
||||
|
||||
/**
|
||||
* Registers any packet handlers or rewrites needed.
|
||||
@ -37,7 +37,4 @@ public interface Rewriter<T extends Protocol> {
|
||||
* @return protocol of the rewriter
|
||||
*/
|
||||
T protocol();
|
||||
|
||||
default void onMappingDataLoaded() {
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* 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 com.viaversion.viaversion.api.rewriter;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface TagRewriter extends MappingDataListener {
|
||||
|
||||
void removeTags(String registryKey);
|
||||
|
||||
void renameTag(RegistryType type, String registryKey, String renameTo);
|
||||
|
||||
/**
|
||||
* Adds an empty tag (since the client crashes if a checked tag is not registered).
|
||||
*
|
||||
* @param tagType registry tag type
|
||||
* @param tagId tag id
|
||||
*/
|
||||
void addEmptyTag(RegistryType tagType, String tagId);
|
||||
|
||||
void addEmptyTags(RegistryType tagType, String... tagIds);
|
||||
|
||||
/**
|
||||
* Adds an entity tag type to be filled with the given entity type ids.
|
||||
*
|
||||
* @param tagId registry tag type
|
||||
* @param entities mapped entity types
|
||||
*/
|
||||
void addEntityTag(String tagId, EntityType... entities);
|
||||
|
||||
/**
|
||||
* Adds a tag type to be filled with the given type ids after being mapped to new ids.
|
||||
*
|
||||
* @param tagType registry tag type
|
||||
* @param tagId tag id
|
||||
* @param unmappedIds unmapped type ids
|
||||
*/
|
||||
void addTag(RegistryType tagType, String tagId, int... unmappedIds);
|
||||
|
||||
/**
|
||||
* Adds a tag type to be filled with the given raw type ids.
|
||||
*
|
||||
* @param tagType registry tag type
|
||||
* @param tagId tag id
|
||||
* @param ids raw type ids
|
||||
*/
|
||||
void addTagRaw(RegistryType tagType, String tagId, int... ids);
|
||||
|
||||
@Nullable
|
||||
List<TagData> getNewTags(RegistryType tagType);
|
||||
|
||||
List<TagData> getOrComputeNewTags(RegistryType tagType);
|
||||
}
|
113
api/src/main/java/com/viaversion/viaversion/util/IdAndData.java
Normale Datei
113
api/src/main/java/com/viaversion/viaversion/util/IdAndData.java
Normale Datei
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* 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 com.viaversion.viaversion.util;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Objects;
|
||||
|
||||
public class IdAndData {
|
||||
|
||||
private int id;
|
||||
private byte data;
|
||||
|
||||
public IdAndData(final int id) {
|
||||
this.id = id;
|
||||
this.data = -1;
|
||||
}
|
||||
|
||||
public IdAndData(final int id, final int data) {
|
||||
Preconditions.checkArgument(data >= 0 && data <= 15, "Data has to be between 0 and 15: (id: " + id + " data: " + data + ")");
|
||||
this.id = id;
|
||||
this.data = (byte) data;
|
||||
}
|
||||
|
||||
public static int getId(final int rawData) {
|
||||
return rawData >> 4;
|
||||
}
|
||||
|
||||
public static int getData(final int rawData) {
|
||||
return rawData & 15;
|
||||
}
|
||||
|
||||
public static int toRawData(final int id) {
|
||||
return id << 4;
|
||||
}
|
||||
|
||||
public static int removeData(final int data) {
|
||||
return data & ~15;
|
||||
}
|
||||
|
||||
public static IdAndData fromRawData(final int rawData) {
|
||||
return new IdAndData(rawData >> 4, rawData & 15);
|
||||
}
|
||||
|
||||
public static int toRawData(final int id, final int data) {
|
||||
return (id << 4) | (data & 15);
|
||||
}
|
||||
|
||||
public int toRawData() {
|
||||
return toRawData(id, data);
|
||||
}
|
||||
|
||||
public IdAndData withData(final int data) {
|
||||
return new IdAndData(this.id, data);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(final int data) {
|
||||
this.data = (byte) data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
IdAndData idAndData = (IdAndData) o;
|
||||
return id == idAndData.id && data == idAndData.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IdAndData{" +
|
||||
"id=" + id +
|
||||
", data=" + data +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -100,11 +100,11 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
||||
registerClientbound(ClientboundPackets1_9_3.CHAT_MESSAGE, wrapper -> {
|
||||
if (!Via.getConfig().is1_12NBTArrayFix()) return;
|
||||
try {
|
||||
JsonElement obj = Protocol1_9To1_8.FIX_JSON.transform(null, wrapper.passthrough(Type.COMPONENT).toString());
|
||||
TranslateRewriter.toClient(obj);
|
||||
ChatItemRewriter.toClient(obj);
|
||||
final JsonElement element = wrapper.passthrough(Type.COMPONENT);
|
||||
TranslateRewriter.toClient(element);
|
||||
ChatItemRewriter.toClient(element);
|
||||
|
||||
wrapper.set(Type.COMPONENT, 0, obj);
|
||||
wrapper.set(Type.COMPONENT, 0, element);
|
||||
} catch (Exception e) {
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Error converting 1.11.2 -> 1.12 chat item", e);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.13", "1.13.2");
|
||||
private final MetadataRewriter1_13_1To1_13 entityRewriter = new MetadataRewriter1_13_1To1_13(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TagRewriter<ClientboundPackets1_13> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_13_1To1_13() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
|
||||
@ -128,7 +129,7 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter<>(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM);
|
||||
tagRewriter.register(ClientboundPackets1_13.TAGS, RegistryType.ITEM);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_13.STATISTICS);
|
||||
}
|
||||
|
||||
@ -154,4 +155,9 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_13> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class MetadataRewriter1_13_1To1_13 extends EntityRewriter<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
registerMetaTypeHandler(Types1_13.META_TYPES.itemType, Types1_13.META_TYPES.blockStateType, null, Types1_13.META_TYPES.particleType, null);
|
||||
registerMetaTypeHandler(Types1_13.META_TYPES.itemType, Types1_13.META_TYPES.blockStateType, Types1_13.META_TYPES.particleType);
|
||||
filter().type(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
|
@ -65,6 +65,7 @@ import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.util.ChatColorUtil;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -317,7 +318,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int newItem = MAPPINGS.getItemMappings().getNewId(item << 4 | i);
|
||||
int newItem = MAPPINGS.getItemMappings().getNewId(IdAndData.toRawData(item, i));
|
||||
if (newItem != -1) {
|
||||
PacketWrapper packet = wrapper.create(ClientboundPackets1_13.COOLDOWN);
|
||||
packet.write(Type.VAR_INT, newItem);
|
||||
@ -342,11 +343,11 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
wrapper.set(Type.INT, 1, getMappingData().getItemMappings().getNewId(data << 4));
|
||||
wrapper.set(Type.INT, 1, getMappingData().getItemMappings().getNewId(IdAndData.toRawData(data)));
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
int blockId = data & 0xFFF;
|
||||
int blockData = data >> 12;
|
||||
wrapper.set(Type.INT, 1, WorldPackets.toNewId(blockId << 4 | blockData));
|
||||
wrapper.set(Type.INT, 1, WorldPackets.toNewId(IdAndData.toRawData(blockId, blockData)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -839,6 +840,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
ConnectionData.init();
|
||||
RecipeData.init();
|
||||
BlockIdData.init();
|
||||
|
@ -40,7 +40,14 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<ClientboundPack
|
||||
protected void registerRewrites() {
|
||||
filter().mapMetaType(typeId -> Types1_13.META_TYPES.byId(typeId > 4 ? typeId + 1 : typeId));
|
||||
filter().metaType(Types1_13.META_TYPES.itemType).handler(((event, meta) -> protocol.getItemRewriter().handleItemToClient(meta.value())));
|
||||
filter().metaType(Types1_13.META_TYPES.blockStateType).handler(((event, meta) -> meta.setValue(WorldPackets.toNewId(meta.value()))));
|
||||
filter().metaType(Types1_13.META_TYPES.blockStateType).handler(((event, meta) -> {
|
||||
final int oldId = meta.value();
|
||||
if (oldId != 0) {
|
||||
final int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15));
|
||||
final int newId = WorldPackets.toNewId(combined);
|
||||
meta.setValue(newId);
|
||||
}
|
||||
}));
|
||||
|
||||
// Previously unused, now swimming
|
||||
filter().index(0).handler((event, meta) -> meta.setValue((byte) ((byte) meta.getValue() & ~0x10)));
|
||||
@ -53,14 +60,6 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<ClientboundPack
|
||||
}
|
||||
}));
|
||||
|
||||
filter().type(EntityTypes1_13.EntityType.ENDERMAN).index(12).handler((event, meta) -> {
|
||||
// Remap held block to match new format for remapping to flat block
|
||||
int stateId = meta.value();
|
||||
int id = stateId & 4095;
|
||||
int data = stateId >> 12 & 15;
|
||||
meta.setValue((id << 4) | (data & 0xF));
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_13.EntityType.WOLF).index(17).handler((event, meta) -> {
|
||||
// Handle new colors
|
||||
meta.setValue(15 - (int) meta.getValue());
|
||||
@ -69,9 +68,9 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<ClientboundPack
|
||||
filter().type(EntityTypes1_13.EntityType.ZOMBIE).addIndex(15); // Shaking
|
||||
|
||||
filter().type(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
|
||||
int oldId = meta.value();
|
||||
int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15));
|
||||
int newId = WorldPackets.toNewId(combined);
|
||||
final int oldId = meta.value();
|
||||
final int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15));
|
||||
final int newId = WorldPackets.toNewId(combined);
|
||||
meta.setValue(newId);
|
||||
});
|
||||
|
||||
@ -108,4 +107,4 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<ClientboundPack
|
||||
public EntityType objectTypeFromId(int type) {
|
||||
return EntityTypes1_13.getTypeFromId(type, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -39,6 +39,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SoundSource
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
@ -165,7 +166,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
channel = getNewPluginChannelId(channel);
|
||||
if (channel == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Ignoring outgoing plugin message with channel: " + old);
|
||||
Via.getPlatform().getLogger().warning("Ignoring clientbound plugin message with channel: " + old);
|
||||
}
|
||||
wrapper.cancel();
|
||||
return;
|
||||
@ -177,7 +178,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + s);
|
||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in clientbound " + Key.stripMinecraftNamespace(channel).toUpperCase(Locale.ROOT) + ": " + s);
|
||||
}
|
||||
}
|
||||
if (!rewrittenChannels.isEmpty()) {
|
||||
@ -229,7 +230,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
channel = getOldPluginChannelId(channel);
|
||||
if (channel == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Ignoring incoming plugin message with channel: " + old);
|
||||
Via.getPlatform().getLogger().warning("Ignoring serverbound plugin message with channel: " + old);
|
||||
}
|
||||
wrapper.cancel();
|
||||
return;
|
||||
@ -241,7 +242,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + s);
|
||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in serverbound " + channel + ": " + s);
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||
@ -270,7 +271,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
// Save original id
|
||||
int originalId = (item.identifier() << 16 | item.data() & 0xFFFF);
|
||||
|
||||
int rawId = (item.identifier() << 4 | item.data() & 0xF);
|
||||
int rawId = IdAndData.toRawData(item.identifier(), item.data());
|
||||
|
||||
// NBT Additions
|
||||
if (isDamageable(item.identifier())) {
|
||||
@ -458,9 +459,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
tag.put(nbtTagName(), new IntTag(originalId)); // Data will be lost, saving original id
|
||||
}
|
||||
if (item.identifier() == 31 && item.data() == 0) { // Shrub was removed
|
||||
rawId = 32 << 4; // Dead Bush
|
||||
} else if (Protocol1_13To1_12_2.MAPPINGS.getItemMappings().getNewId(rawId & ~0xF) != -1) {
|
||||
rawId &= ~0xF; // Remove data
|
||||
rawId = IdAndData.toRawData(32); // Dead Bush
|
||||
} else if (Protocol1_13To1_12_2.MAPPINGS.getItemMappings().getNewId(IdAndData.removeData(rawId)) != -1) {
|
||||
rawId = IdAndData.removeData(rawId);
|
||||
} else {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.identifier());
|
||||
@ -538,7 +539,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
tag.put("EntityTag", entityTag);
|
||||
}
|
||||
} else {
|
||||
rawId = (oldId >> 4) << 16 | oldId & 0xF;
|
||||
rawId = IdAndData.getId(oldId) << 16 | oldId & 0xF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.ParticleRew
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.PaintingProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
@ -569,7 +570,7 @@ public class WorldPackets {
|
||||
if (newId != -1) {
|
||||
return newId;
|
||||
}
|
||||
newId = Protocol1_13To1_12_2.MAPPINGS.getBlockMappings().getNewId(oldId & ~0xF); // Remove data
|
||||
newId = Protocol1_13To1_12_2.MAPPINGS.getBlockMappings().getNewId(IdAndData.removeData(oldId)); // Remove data
|
||||
if (newId != -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Missing block " + oldId);
|
||||
|
@ -140,6 +140,7 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
WorldPackets.air = MAPPINGS.getBlockStateMappings().getNewId(0);
|
||||
WorldPackets.voidAir = MAPPINGS.getBlockStateMappings().getNewId(8591);
|
||||
WorldPackets.caveAir = MAPPINGS.getBlockStateMappings().getNewId(8592);
|
||||
|
@ -45,7 +45,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().mapMetaType(Types1_14.META_TYPES::byId);
|
||||
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType, null);
|
||||
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, Types1_14.META_TYPES.particleType);
|
||||
|
||||
filter().type(EntityTypes1_14.ENTITY).addIndex(6);
|
||||
filter().type(EntityTypes1_14.LIVINGENTITY).addIndex(12);
|
||||
|
@ -40,7 +40,7 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.14", "1.15");
|
||||
private final MetadataRewriter1_15To1_14_4 metadataRewriter = new MetadataRewriter1_15To1_14_4(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private TagRewriter<ClientboundPackets1_14_4> tagRewriter;
|
||||
private final TagRewriter<ClientboundPackets1_14_4> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_15To1_14_4() {
|
||||
super(ClientboundPackets1_14_4.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
@ -61,12 +61,13 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> itemRewriter.handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
|
||||
|
||||
tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.register(ClientboundPackets1_14_4.TAGS, RegistryType.ENTITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
int[] shulkerBoxes = new int[17];
|
||||
int shulkerBoxOffset = 501;
|
||||
for (int i = 0; i < 17; i++) {
|
||||
@ -94,4 +95,9 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_14_4> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class MetadataRewriter1_15To1_14_4 extends EntityRewriter<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType, null);
|
||||
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, Types1_14.META_TYPES.particleType);
|
||||
filter().type(EntityTypes1_15.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
|
@ -39,7 +39,7 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
private final MetadataRewriter1_16_2To1_16_1 metadataRewriter = new MetadataRewriter1_16_2To1_16_1(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private TagRewriter<ClientboundPackets1_16> tagRewriter;
|
||||
private final TagRewriter<ClientboundPackets1_16> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_16_2To1_16_1() {
|
||||
super(ClientboundPackets1_16.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16.class, ServerboundPackets1_16_2.class);
|
||||
@ -52,7 +52,6 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
||||
EntityPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
|
||||
tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.register(ClientboundPackets1_16.TAGS, RegistryType.ENTITY);
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_16.STATISTICS);
|
||||
@ -85,19 +84,21 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
tagRewriter.addTag(RegistryType.ITEM, "minecraft:stone_crafting_materials", 14, 962);
|
||||
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:mushroom_grow_block");
|
||||
|
||||
// The client now wants ALL (previous) tags to be sent, sooooo :>
|
||||
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:soul_fire_base_blocks", "minecraft:furnace_materials", "minecraft:crimson_stems",
|
||||
"minecraft:gold_ores", "minecraft:piglin_loved", "minecraft:piglin_repellents", "minecraft:creeper_drop_music_discs",
|
||||
"minecraft:logs_that_burn", "minecraft:stone_tool_materials", "minecraft:warped_stems");
|
||||
"minecraft:gold_ores", "minecraft:piglin_loved", "minecraft:piglin_repellents", "minecraft:creeper_drop_music_discs",
|
||||
"minecraft:logs_that_burn", "minecraft:stone_tool_materials", "minecraft:warped_stems");
|
||||
tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:infiniburn_nether", "minecraft:crimson_stems",
|
||||
"minecraft:wither_summon_base_blocks", "minecraft:infiniburn_overworld", "minecraft:piglin_repellents",
|
||||
"minecraft:hoglin_repellents", "minecraft:prevent_mob_spawning_inside", "minecraft:wart_blocks",
|
||||
"minecraft:stone_pressure_plates", "minecraft:nylium", "minecraft:gold_ores", "minecraft:pressure_plates",
|
||||
"minecraft:logs_that_burn", "minecraft:strider_warm_blocks", "minecraft:warped_stems", "minecraft:infiniburn_end",
|
||||
"minecraft:base_stone_nether", "minecraft:base_stone_overworld");
|
||||
"minecraft:wither_summon_base_blocks", "minecraft:infiniburn_overworld", "minecraft:piglin_repellents",
|
||||
"minecraft:hoglin_repellents", "minecraft:prevent_mob_spawning_inside", "minecraft:wart_blocks",
|
||||
"minecraft:stone_pressure_plates", "minecraft:nylium", "minecraft:gold_ores", "minecraft:pressure_plates",
|
||||
"minecraft:logs_that_burn", "minecraft:strider_warm_blocks", "minecraft:warped_stems", "minecraft:infiniburn_end",
|
||||
"minecraft:base_stone_nether", "minecraft:base_stone_overworld");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,4 +120,9 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_16> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.particleType, null);
|
||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, Types1_16.META_TYPES.particleType);
|
||||
filter().type(EntityTypes1_16_2.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
|
@ -61,7 +61,7 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
private final MetadataRewriter1_16To1_15_2 metadataRewriter = new MetadataRewriter1_16To1_15_2(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TranslationMappings componentRewriter = new TranslationMappings(this);
|
||||
private TagRewriter<ClientboundPackets1_15> tagRewriter;
|
||||
private final TagRewriter<ClientboundPackets1_15> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_16To1_15_2() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_16.class, ServerboundPackets1_14.class, ServerboundPackets1_16.class);
|
||||
@ -74,7 +74,6 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
EntityPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
|
||||
tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.register(ClientboundPackets1_15.TAGS, RegistryType.ENTITY);
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS);
|
||||
@ -169,7 +168,7 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
final String namespacedChannel = Key.namespaced(channel);
|
||||
if (channel.length() > 32) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
Via.getPlatform().getLogger().warning("Ignoring incoming plugin channel, as it is longer than 32 characters: " + channel);
|
||||
Via.getPlatform().getLogger().warning("Ignoring serverbound plugin channel, as it is longer than 32 characters: " + channel);
|
||||
}
|
||||
wrapper.cancel();
|
||||
} else if (namespacedChannel.equals("minecraft:register") || namespacedChannel.equals("minecraft:unregister")) {
|
||||
@ -178,7 +177,7 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
for (String registeredChannel : channels) {
|
||||
if (registeredChannel.length() > 32) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
Via.getPlatform().getLogger().warning("Ignoring incoming plugin channel register of '"
|
||||
Via.getPlatform().getLogger().warning("Ignoring serverbound plugin channel register of '"
|
||||
+ registeredChannel + "', as it is longer than 32 characters");
|
||||
}
|
||||
continue;
|
||||
@ -213,6 +212,8 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
int[] wallPostOverrideTag = new int[47];
|
||||
int arrayIndex = 0;
|
||||
wallPostOverrideTag[arrayIndex++] = 140;
|
||||
@ -292,4 +293,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
public TranslationMappings getComponentRewriter() {
|
||||
return componentRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_15> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<ClientboundPack
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().mapMetaType(Types1_16.META_TYPES::byId);
|
||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.particleType, null);
|
||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, Types1_16.META_TYPES.particleType);
|
||||
filter().type(EntityTypes1_16.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
|
@ -188,7 +188,7 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
tagRewriter.loadFromMappingData(); // Load filled extra tags
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:candles", "minecraft:ignored_by_piglin_babies", "minecraft:piglin_food", "minecraft:freeze_immune_wearables",
|
||||
"minecraft:axolotl_tempt_items", "minecraft:occludes_vibration_signals", "minecraft:fox_food",
|
||||
@ -232,4 +232,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_16_2> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
||||
meta.setValue(pose + 1);
|
||||
}
|
||||
});
|
||||
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, null, Types1_17.META_TYPES.particleType, null);
|
||||
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, Types1_17.META_TYPES.particleType);
|
||||
|
||||
// Ticks frozen added with id 7
|
||||
filter().type(EntityTypes1_17.ENTITY).addIndex(7);
|
||||
|
@ -31,6 +31,7 @@ import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
|
||||
public final class Protocol1_18_2To1_18 extends AbstractProtocol<ClientboundPackets1_18, ClientboundPackets1_18, ServerboundPackets1_17, ServerboundPackets1_17> {
|
||||
|
||||
|
||||
public Protocol1_18_2To1_18() {
|
||||
super(ClientboundPackets1_18.class, ClientboundPackets1_18.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.17", "1.18");
|
||||
private final EntityPackets entityRewriter = new EntityPackets(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TagRewriter<ClientboundPackets1_17_1> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_18To1_17_1() {
|
||||
super(ClientboundPackets1_17_1.class, ClientboundPackets1_18.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
|
||||
@ -58,7 +59,6 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
soundRewriter.registerSound(ClientboundPackets1_17_1.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_17_1.ENTITY_SOUND);
|
||||
|
||||
final TagRewriter<ClientboundPackets1_17_1> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_17_1.TAGS);
|
||||
tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:lava_pool_stone_cannot_replace", "minecraft:big_dripleaf_placeable",
|
||||
"minecraft:wolves_spawnable_on", "minecraft:rabbits_spawnable_on", "minecraft:polar_bears_spawnable_on_in_frozen_ocean", "minecraft:parrots_spawnable_on",
|
||||
@ -85,6 +85,7 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
Types1_18.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
|
@ -94,7 +94,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
|
||||
}
|
||||
});
|
||||
|
||||
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null, null, null);
|
||||
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,6 +66,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
private static final byte[] EMPTY_BYTES = new byte[0];
|
||||
private final EntityPackets entityRewriter = new EntityPackets(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TagRewriter<ClientboundPackets1_19_1> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_19_3To1_19_1() {
|
||||
super(ClientboundPackets1_19_1.class, ClientboundPackets1_19_3.class, ServerboundPackets1_19_1.class, ServerboundPackets1_19_3.class);
|
||||
@ -73,8 +74,6 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
final TagRewriter<ClientboundPackets1_19_1> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
// Flint and steel was hardcoded before 1.19.3 to ignite a creeper; has been moved to a tag - adding this ensures offhand doesn't trigger as well
|
||||
tagRewriter.addTagRaw(RegistryType.ITEM, "minecraft:creeper_igniters", 733); // 733 = flint_and_steel 1.19.3
|
||||
|
||||
@ -377,4 +376,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_19_1> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().mapMetaType(typeId -> Types1_19_3.META_TYPES.byId(typeId >= 2 ? typeId + 1 : typeId)); // Long added
|
||||
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, null, Types1_19_3.META_TYPES.particleType, null);
|
||||
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, Types1_19_3.META_TYPES.particleType);
|
||||
|
||||
filter().type(EntityTypes1_19_3.ENTITY).index(6).handler((event, meta) -> {
|
||||
// Sitting pose added
|
||||
|
@ -45,6 +45,7 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
private final EntityPackets entityRewriter = new EntityPackets(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TagRewriter<ClientboundPackets1_19_3> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_19_4To1_19_3() {
|
||||
super(ClientboundPackets1_19_3.class, ClientboundPackets1_19_4.class, ServerboundPackets1_19_3.class, ServerboundPackets1_19_4.class);
|
||||
@ -54,7 +55,7 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
new TagRewriter<>(this).registerGeneric(ClientboundPackets1_19_3.TAGS);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_19_3.TAGS);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_19_3.STATISTICS);
|
||||
|
||||
final SoundRewriter<ClientboundPackets1_19_3> soundRewriter = new SoundRewriter<>(this);
|
||||
@ -127,4 +128,9 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_19_3> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
private final EntityPackets entityRewriter = new EntityPackets(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TagRewriter<ClientboundPackets1_18> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_19To1_18_2() {
|
||||
super(ClientboundPackets1_18.class, ClientboundPackets1_19.class, ServerboundPackets1_17.class, ServerboundPackets1_19.class);
|
||||
@ -74,7 +75,6 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
final TagRewriter<ClientboundPackets1_18> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS);
|
||||
|
||||
entityRewriter.register();
|
||||
@ -331,4 +331,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_18> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
||||
rewriteParticle(particle);
|
||||
});
|
||||
|
||||
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null, null, null);
|
||||
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null);
|
||||
|
||||
filter().type(EntityTypes1_19.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||
// Convert to new block id
|
||||
|
@ -62,6 +62,7 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.20", "1.20.2");
|
||||
private final EntityPacketRewriter1_20_2 entityPacketRewriter = new EntityPacketRewriter1_20_2(this);
|
||||
private final BlockItemPacketRewriter1_20_2 itemPacketRewriter = new BlockItemPacketRewriter1_20_2(this);
|
||||
private final TagRewriter<ClientboundPackets1_19_4> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_20_2To1_20() {
|
||||
super(ClientboundPackets1_19_4.class, ClientboundPackets1_20_2.class, ServerboundPackets1_19_4.class, ServerboundPackets1_20_2.class);
|
||||
@ -100,7 +101,6 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
||||
wrapper.user().put(new LastResourcePack(url, hash, required, prompt));
|
||||
});
|
||||
|
||||
final TagRewriter<ClientboundPackets1_19_4> tagRewriter = new TagRewriter<>(this);
|
||||
registerClientbound(ClientboundPackets1_19_4.TAGS, wrapper -> {
|
||||
tagRewriter.getGenericHandler().handle(wrapper);
|
||||
wrapper.resetReader();
|
||||
@ -354,4 +354,9 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
||||
public ItemRewriter<Protocol1_20_2To1_20> getItemRewriter() {
|
||||
return itemPacketRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_19_4> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.20.2", "1.20.3");
|
||||
private final BlockItemPacketRewriter1_20_3 itemRewriter = new BlockItemPacketRewriter1_20_3(this);
|
||||
private final EntityPacketRewriter1_20_3 entityRewriter = new EntityPacketRewriter1_20_3(this);
|
||||
private final TagRewriter<ClientboundPacket1_20_2> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_20_3To1_20_2() {
|
||||
super(ClientboundPacket1_20_2.class, ClientboundPacket1_20_3.class, ServerboundPacket1_20_2.class, ServerboundPacket1_20_3.class);
|
||||
@ -72,7 +73,6 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
cancelServerbound(ServerboundPackets1_20_3.CONTAINER_SLOT_STATE_CHANGED);
|
||||
|
||||
final TagRewriter<ClientboundPacket1_20_2> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_20_2.TAGS);
|
||||
|
||||
final SoundRewriter<ClientboundPacket1_20_2> soundRewriter = new SoundRewriter<>(this);
|
||||
@ -379,6 +379,11 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPacket1_20_2> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketTypesProvider<ClientboundPacket1_20_2, ClientboundPacket1_20_3, ServerboundPacket1_20_2, ServerboundPacket1_20_3> createPacketTypesProvider() {
|
||||
return new SimplePacketTypesProvider<>(
|
||||
|
@ -302,6 +302,11 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol<ClientboundPa
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPacket1_20_3> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketTypesProvider<ClientboundPacket1_20_3, ClientboundPacket1_20_5, ServerboundPacket1_20_3, ServerboundPacket1_20_5> createPacketTypesProvider() {
|
||||
return new SimplePacketTypesProvider<>(
|
||||
|
@ -39,6 +39,7 @@ public final class Protocol1_20To1_19_4 extends AbstractProtocol<ClientboundPack
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.19.4", "1.20");
|
||||
private final EntityPackets entityRewriter = new EntityPackets(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TagRewriter<ClientboundPackets1_19_4> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_20To1_19_4() {
|
||||
super(ClientboundPackets1_19_4.class, ClientboundPackets1_19_4.class, ServerboundPackets1_19_4.class, ServerboundPackets1_19_4.class);
|
||||
@ -48,7 +49,6 @@ public final class Protocol1_20To1_19_4 extends AbstractProtocol<ClientboundPack
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
final TagRewriter<ClientboundPackets1_19_4> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_19_4.TAGS);
|
||||
|
||||
final SoundRewriter<ClientboundPackets1_19_4> soundRewriter = new SoundRewriter<>(this);
|
||||
@ -101,4 +101,9 @@ public final class Protocol1_20To1_19_4 extends AbstractProtocol<ClientboundPack
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPackets1_19_4> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
@ -20,9 +20,10 @@ package com.viaversion.viaversion.protocols.protocol1_9to1_8;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.SerializerVersion;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import java.util.Collections;
|
||||
@ -227,24 +228,11 @@ public class ItemRewriter {
|
||||
}
|
||||
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
StringTag pageTag = pages.get(i);
|
||||
String value = pageTag.getValue();
|
||||
if (value.replaceAll(" ", "").isEmpty()) {
|
||||
value = "\"" + fixBookSpaceChars(value) + "\"";
|
||||
} else {
|
||||
value = fixBookSpaceChars(value);
|
||||
}
|
||||
pageTag.setValue(value);
|
||||
}
|
||||
}
|
||||
final StringTag pageTag = pages.get(i);
|
||||
final String value = pageTag.getValue();
|
||||
|
||||
private static String fixBookSpaceChars(String str) {
|
||||
if (!str.startsWith(" ")) {
|
||||
return str;
|
||||
pageTag.setValue(ComponentUtil.convertJson(value, SerializerVersion.V1_9, SerializerVersion.V1_8).toString());
|
||||
}
|
||||
// hacky but it works :)
|
||||
str = "§r" + str;
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void toClient(Item item) {
|
||||
@ -287,15 +275,15 @@ public class ItemRewriter {
|
||||
|
||||
ListTag<StringTag> pages = tag.getListTag("pages", StringTag.class);
|
||||
if (pages == null) {
|
||||
pages = new ListTag<>(Collections.singletonList(new StringTag(Protocol1_9To1_8.fixJson("").toString())));
|
||||
pages = new ListTag<>(Collections.singletonList(new StringTag(ComponentUtil.emptyJsonComponent().toString())));
|
||||
tag.put("pages", pages);
|
||||
item.setTag(tag);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
StringTag page = pages.get(i);
|
||||
page.setValue(Protocol1_9To1_8.fixJson(page.getValue()).toString());
|
||||
final StringTag page = pages.get(i);
|
||||
page.setValue(ComponentUtil.convertJson(page.getValue(), SerializerVersion.V1_8, SerializerVersion.V1_9).toString());
|
||||
}
|
||||
item.setTag(tag);
|
||||
}
|
||||
|
@ -202,6 +202,17 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
typeMappings = protocol.getMappingData().getEntityMappings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a metadata handler to rewrite, item, block, and particle ids stored in metadata.
|
||||
*
|
||||
* @param itemType item meta type if needed
|
||||
* @param blockStateType block state meta type if needed
|
||||
* @param particleType particle meta type if needed
|
||||
*/
|
||||
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockStateType, @Nullable MetaType particleType) {
|
||||
registerMetaTypeHandler(itemType, null, blockStateType, particleType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a metadata handler to rewrite, item, block, and particle ids stored in metadata.
|
||||
*
|
||||
|
@ -38,7 +38,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class TagRewriter<C extends ClientboundPacketType> {
|
||||
public class TagRewriter<C extends ClientboundPacketType> implements com.viaversion.viaversion.api.rewriter.TagRewriter {
|
||||
private static final int[] EMPTY_ARRAY = {};
|
||||
private final Protocol<C, ?, ?, ?> protocol;
|
||||
private final Map<RegistryType, List<TagData>> newTags = new EnumMap<>(RegistryType.class);
|
||||
@ -49,10 +49,12 @@ public class TagRewriter<C extends ClientboundPacketType> {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets new tags from the protocol's {@link MappingData} instance.
|
||||
*/
|
||||
public void loadFromMappingData() {
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
if (protocol.getMappingData() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (RegistryType type : RegistryType.getValues()) {
|
||||
List<TagData> tags = protocol.getMappingData().getTags(type);
|
||||
if (tags != null) {
|
||||
@ -61,24 +63,22 @@ public class TagRewriter<C extends ClientboundPacketType> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTags(final String registryKey) {
|
||||
toRemove.add(registryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renameTag(final RegistryType type, final String registryKey, final String renameTo) {
|
||||
toRename.computeIfAbsent(type, t -> new HashMap<>()).put(registryKey, renameTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an empty tag (since the client crashes if a checked tag is not registered).
|
||||
*
|
||||
* @param tagType registry tag type
|
||||
* @param tagId tag id
|
||||
*/
|
||||
@Override
|
||||
public void addEmptyTag(RegistryType tagType, String tagId) {
|
||||
getOrComputeNewTags(tagType).add(new TagData(tagId, EMPTY_ARRAY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEmptyTags(RegistryType tagType, String... tagIds) {
|
||||
List<TagData> tagList = getOrComputeNewTags(tagType);
|
||||
for (String id : tagIds) {
|
||||
@ -86,12 +86,7 @@ public class TagRewriter<C extends ClientboundPacketType> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an entity tag type to be filled with the given entity type ids.
|
||||
*
|
||||
* @param tagId registry tag type
|
||||
* @param entities mapped entity types
|
||||
*/
|
||||
@Override
|
||||
public void addEntityTag(String tagId, EntityType... entities) {
|
||||
int[] ids = new int[entities.length];
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
@ -100,13 +95,7 @@ public class TagRewriter<C extends ClientboundPacketType> {
|
||||
addTagRaw(RegistryType.ENTITY, tagId, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tag type to be filled with the given type ids after being mapped to new ids.
|
||||
*
|
||||
* @param tagType registry tag type
|
||||
* @param tagId tag id
|
||||
* @param unmappedIds unmapped type ids
|
||||
*/
|
||||
@Override
|
||||
public void addTag(RegistryType tagType, String tagId, int... unmappedIds) {
|
||||
List<TagData> newTags = getOrComputeNewTags(tagType);
|
||||
IdRewriteFunction rewriteFunction = getRewriter(tagType);
|
||||
@ -119,32 +108,15 @@ public class TagRewriter<C extends ClientboundPacketType> {
|
||||
newTags.add(new TagData(tagId, unmappedIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tag type to be filled with the given raw type ids.
|
||||
*
|
||||
* @param tagType registry tag type
|
||||
* @param tagId tag id
|
||||
* @param ids raw type ids
|
||||
*/
|
||||
@Override
|
||||
public void addTagRaw(RegistryType tagType, String tagId, int... ids) {
|
||||
getOrComputeNewTags(tagType).add(new TagData(tagId, ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre 1.17 reading of hardcoded registry types.
|
||||
*
|
||||
* @param packetType packet type
|
||||
* @param readUntilType read and process the types until (including) the given registry type
|
||||
*/
|
||||
public void register(C packetType, @Nullable RegistryType readUntilType) {
|
||||
protocol.registerClientbound(packetType, getHandler(readUntilType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.17+ reading of generic tag types.
|
||||
*
|
||||
* @param packetType packet type
|
||||
*/
|
||||
public void registerGeneric(C packetType) {
|
||||
protocol.registerClientbound(packetType, getGenericHandler());
|
||||
}
|
||||
@ -236,10 +208,12 @@ public class TagRewriter<C extends ClientboundPacketType> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<TagData> getNewTags(RegistryType tagType) {
|
||||
return newTags.get(tagType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagData> getOrComputeNewTags(RegistryType tagType) {
|
||||
return newTags.computeIfAbsent(tagType, type -> new ArrayList<>());
|
||||
}
|
||||
|
@ -21,9 +21,6 @@ import com.google.gson.JsonElement;
|
||||
import com.viaversion.viaversion.compatibility.YamlCompat;
|
||||
import com.viaversion.viaversion.compatibility.unsafe.Yaml1Compat;
|
||||
import com.viaversion.viaversion.compatibility.unsafe.Yaml2Compat;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@ -35,6 +32,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.logging.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
@SuppressWarnings("VulnerableCodeUsages")
|
||||
public abstract class Config {
|
||||
@ -148,7 +148,9 @@ public abstract class Config {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
this.configFile.getParentFile().mkdirs();
|
||||
if (this.configFile.getParentFile() != null) {
|
||||
this.configFile.getParentFile().mkdirs();
|
||||
}
|
||||
save(this.configFile, this.config);
|
||||
}
|
||||
|
||||
@ -157,7 +159,9 @@ public abstract class Config {
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.configFile.getParentFile().mkdirs();
|
||||
if (this.configFile.getParentFile() != null) {
|
||||
this.configFile.getParentFile().mkdirs();
|
||||
}
|
||||
this.config = new ConcurrentSkipListMap<>(loadConfig(this.configFile));
|
||||
}
|
||||
|
||||
@ -245,4 +249,4 @@ public abstract class Config {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -45,6 +45,7 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.98", "1.99");
|
||||
private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this);
|
||||
private final BlockItemPacketRewriter1_99 itemRewriter = new BlockItemPacketRewriter1_99(this);
|
||||
private final TagRewriter<ClientboundPacket1_20_5> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_99To_98() {
|
||||
// Passing the class types into the super constructor is needed for automatic packet type id remapping, but can otherwise be omitted
|
||||
@ -55,7 +56,6 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
final TagRewriter<ClientboundPacket1_20_5> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_20_5.TAGS);
|
||||
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_5.UPDATE_TAGS);
|
||||
|
||||
@ -109,7 +109,8 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
||||
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_20_5.PLAYER));
|
||||
}
|
||||
|
||||
// Overriding these three methods is important as they are relied on various rewriter classes
|
||||
// Overriding these four methods is important as they are relied on various rewriter classes
|
||||
// and have mapping load methods called in AbstractProtocol via the getters
|
||||
@Override
|
||||
public MappingData getMappingData() {
|
||||
return MAPPINGS;
|
||||
@ -124,4 +125,9 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
||||
public BlockItemPacketRewriter1_99 getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPacket1_20_5> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren