Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Add namespace to argument type mappings
Dieser Commit ist enthalten in:
Ursprung
365b3a8a38
Commit
a1ae7818a2
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 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.data;
|
||||
|
||||
public interface FullMappingData {
|
||||
|
||||
Mappings mappings();
|
||||
|
||||
/**
|
||||
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||
*
|
||||
* @param identifier unmapped string identifier
|
||||
* @return unmapped int id, or -1 if not found
|
||||
*/
|
||||
int id(String identifier);
|
||||
|
||||
/**
|
||||
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
|
||||
*
|
||||
* @param mappedIdentifier mapped string identifier
|
||||
* @return mapped int id, or -1 if not found
|
||||
*/
|
||||
int mappedId(String mappedIdentifier);
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 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.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
|
||||
public class FullMappingDataBase implements FullMappingData {
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final Mappings mappings;
|
||||
|
||||
public FullMappingDataBase(final JsonArray oldMappings, final JsonArray newMappings, final Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
stringToId = MappingDataLoader.arrayToMap(oldMappings);
|
||||
mappedStringToId = MappingDataLoader.arrayToMap(newMappings);
|
||||
stringToId.defaultReturnValue(-1);
|
||||
mappedStringToId.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings mappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id(final String identifier) {
|
||||
return stringToId.getInt(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedId(final String mappedIdentifier) {
|
||||
return mappedStringToId.getInt(mappedIdentifier);
|
||||
}
|
||||
}
|
@ -103,5 +103,5 @@ public interface MappingData {
|
||||
|
||||
@Nullable Mappings getStatisticsMappings();
|
||||
|
||||
@Nullable Mappings getArgumentTypeMappings();
|
||||
@Nullable FullMappingData getArgumentTypeMappings();
|
||||
}
|
||||
|
@ -44,13 +44,13 @@ public class MappingDataBase implements MappingData {
|
||||
protected final String newVersion;
|
||||
protected final boolean hasDiffFile;
|
||||
protected Int2IntBiMap itemMappings;
|
||||
protected FullMappingData argumentTypeMappings;
|
||||
protected ParticleMappings particleMappings;
|
||||
protected Mappings blockMappings;
|
||||
protected Mappings blockStateMappings;
|
||||
protected Mappings blockEntityMappings;
|
||||
protected Mappings soundMappings;
|
||||
protected Mappings statisticsMappings;
|
||||
protected Mappings argumentTypeMappings;
|
||||
protected Map<RegistryType, List<TagData>> tags;
|
||||
protected boolean loadItems = true;
|
||||
|
||||
@ -76,7 +76,12 @@ public class MappingDataBase implements MappingData {
|
||||
blockEntityMappings = loadFromArray(oldMappings, newMappings, diffmapping, "blockentities");
|
||||
soundMappings = loadFromArray(oldMappings, newMappings, diffmapping, "sounds");
|
||||
statisticsMappings = loadFromArray(oldMappings, newMappings, diffmapping, "statistics");
|
||||
argumentTypeMappings = loadFromArray(oldMappings, newMappings, diffmapping, "argumenttypes");
|
||||
|
||||
Mappings argumentTypeMappings = loadFromArray(oldMappings, newMappings, diffmapping, "argumenttypes");
|
||||
if (argumentTypeMappings != null) {
|
||||
this.argumentTypeMappings = new FullMappingDataBase(oldMappings.getAsJsonArray("argumenttypes"),
|
||||
newMappings.getAsJsonArray("argumenttypes"), argumentTypeMappings);
|
||||
}
|
||||
|
||||
Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
|
||||
if (particles != null) {
|
||||
@ -150,7 +155,7 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
@Override
|
||||
public int getNewParticleId(int id) {
|
||||
return checkValidity(id, particleMappings.getMappings().getNewId(id), "particles");
|
||||
return checkValidity(id, particleMappings.mappings().getNewId(id), "particles");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -194,7 +199,7 @@ public class MappingDataBase implements MappingData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getArgumentTypeMappings() {
|
||||
public @Nullable FullMappingData getArgumentTypeMappings() {
|
||||
return argumentTypeMappings;
|
||||
}
|
||||
|
||||
|
@ -25,51 +25,19 @@ package com.viaversion.viaversion.api.data;
|
||||
import com.google.gson.JsonArray;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
|
||||
public class ParticleMappings {
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final Mappings mappings;
|
||||
public class ParticleMappings extends FullMappingDataBase {
|
||||
private final IntList itemParticleIds = new IntArrayList(2);
|
||||
private final IntList blockParticleIds = new IntArrayList(4);
|
||||
|
||||
public ParticleMappings(JsonArray oldMappings, JsonArray newMappings, Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
stringToId = MappingDataLoader.arrayToMap(oldMappings);
|
||||
mappedStringToId = MappingDataLoader.arrayToMap(newMappings);
|
||||
stringToId.defaultReturnValue(-1);
|
||||
mappedStringToId.defaultReturnValue(-1);
|
||||
super(oldMappings, newMappings, mappings);
|
||||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
addItemParticle("item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||
*
|
||||
* @param identifier unmapped string identifier
|
||||
* @return unmapped int id, or -1 if not found
|
||||
*/
|
||||
public int id(String identifier) {
|
||||
return stringToId.getInt(identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
|
||||
*
|
||||
* @param mappedIdentifier mapped string identifier
|
||||
* @return mapped int id, or -1 if not found
|
||||
*/
|
||||
public int mappedId(String mappedIdentifier) {
|
||||
return mappedStringToId.getInt(mappedIdentifier);
|
||||
}
|
||||
|
||||
public Mappings getMappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public boolean addItemParticle(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
return id != -1 && itemParticleIds.add(id);
|
||||
|
@ -19,6 +19,8 @@ package com.viaversion.viaversion.protocols.protocol1_19to1_18_2;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
@ -30,7 +32,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.data.MappingData;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets.EntityPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets.InventoryPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets.WorldPackets;
|
||||
@ -41,7 +42,7 @@ import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
|
||||
public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPackets1_18, ClientboundPackets1_19, ServerboundPackets1_17, ServerboundPackets1_17> {
|
||||
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.18", "1.19");
|
||||
private final EntityPackets entityRewriter = new EntityPackets(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
|
||||
@ -52,10 +53,6 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
final TagRewriter tagRewriter = new TagRewriter(this);
|
||||
/*tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:fall_damage_resetting"); //TODO check if needed
|
||||
tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:fall_damage_resetting", "minecraft:sculk_replaceable",
|
||||
"minecraft:ancient_city_replaceables", "minecraft:deepslate_blocks", "minecraft:sculk_replaceable_world_gen", "minecraft:skip_occlude_vibration_when_above");
|
||||
tagRewriter.addEmptyTag(RegistryType.GAME_EVENT, "minecraft:warden_events_can_listen");*/
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS);
|
||||
|
||||
entityRewriter.register();
|
||||
@ -88,7 +85,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
if (nodeType == 2) { // Argument node
|
||||
final String argumentType = wrapper.read(Type.STRING);
|
||||
final int argumentTypeId = MAPPINGS.argumentTypeIds().getInt(argumentType.replace("minecraft:", ""));
|
||||
final int argumentTypeId = MAPPINGS.getArgumentTypeMappings().mappedId(argumentType);
|
||||
if (argumentTypeId == -1) {
|
||||
Via.getPlatform().getLogger().warning("Unknown command argument type: " + argumentType);
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_19to1_18_2.data;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class MappingData extends MappingDataBase {
|
||||
|
||||
private final Object2IntMap<String> argumentTypeIds = new Object2IntOpenHashMap<>();
|
||||
|
||||
public MappingData() {
|
||||
super("1.18", "1.19");
|
||||
argumentTypeIds.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtras(final JsonObject oldMappings, final JsonObject newMappings, @Nullable final JsonObject diffMappings) {
|
||||
int i = 0;
|
||||
for (final JsonElement element : newMappings.getAsJsonArray("argumenttypes")) {
|
||||
final String id = element.getAsString();
|
||||
argumentTypeIds.put(id, i++);
|
||||
}
|
||||
}
|
||||
|
||||
public Object2IntMap<String> argumentTypeIds() {
|
||||
return argumentTypeIds;
|
||||
}
|
||||
}
|
@ -23684,45 +23684,45 @@
|
||||
"brigadier:integer",
|
||||
"brigadier:long",
|
||||
"brigadier:string",
|
||||
"entity",
|
||||
"game_profile",
|
||||
"block_pos",
|
||||
"column_pos",
|
||||
"vec3",
|
||||
"vec2",
|
||||
"block_state",
|
||||
"block_predicate",
|
||||
"item_stack",
|
||||
"item_predicate",
|
||||
"color",
|
||||
"component",
|
||||
"message",
|
||||
"nbt_compound_tag",
|
||||
"nbt_tag",
|
||||
"nbt_path",
|
||||
"objective",
|
||||
"objective_criteria",
|
||||
"operation",
|
||||
"particle",
|
||||
"angle",
|
||||
"rotation",
|
||||
"scoreboard_slot",
|
||||
"score_holder",
|
||||
"swizzle",
|
||||
"team",
|
||||
"item_slot",
|
||||
"resource_location",
|
||||
"mob_effect",
|
||||
"function",
|
||||
"entity_anchor",
|
||||
"int_range",
|
||||
"float_range",
|
||||
"item_enchantment",
|
||||
"entity_summon",
|
||||
"dimension",
|
||||
"time",
|
||||
"uuid",
|
||||
"resource",
|
||||
"resource_or_tag"
|
||||
"minecraft:entity",
|
||||
"minecraft:game_profile",
|
||||
"minecraft:block_pos",
|
||||
"minecraft:column_pos",
|
||||
"minecraft:vec3",
|
||||
"minecraft:vec2",
|
||||
"minecraft:block_state",
|
||||
"minecraft:block_predicate",
|
||||
"minecraft:item_stack",
|
||||
"minecraft:item_predicate",
|
||||
"minecraft:color",
|
||||
"minecraft:component",
|
||||
"minecraft:message",
|
||||
"minecraft:nbt_compound_tag",
|
||||
"minecraft:nbt_tag",
|
||||
"minecraft:nbt_path",
|
||||
"minecraft:objective",
|
||||
"minecraft:objective_criteria",
|
||||
"minecraft:operation",
|
||||
"minecraft:particle",
|
||||
"minecraft:angle",
|
||||
"minecraft:rotation",
|
||||
"minecraft:scoreboard_slot",
|
||||
"minecraft:score_holder",
|
||||
"minecraft:swizzle",
|
||||
"minecraft:team",
|
||||
"minecraft:item_slot",
|
||||
"minecraft:resource_location",
|
||||
"minecraft:mob_effect",
|
||||
"minecraft:function",
|
||||
"minecraft:entity_anchor",
|
||||
"minecraft:int_range",
|
||||
"minecraft:float_range",
|
||||
"minecraft:item_enchantment",
|
||||
"minecraft:entity_summon",
|
||||
"minecraft:dimension",
|
||||
"minecraft:time",
|
||||
"minecraft:uuid",
|
||||
"minecraft:resource",
|
||||
"minecraft:resource_or_tag"
|
||||
]
|
||||
}
|
@ -24810,45 +24810,45 @@
|
||||
"brigadier:integer",
|
||||
"brigadier:long",
|
||||
"brigadier:string",
|
||||
"entity",
|
||||
"game_profile",
|
||||
"block_pos",
|
||||
"column_pos",
|
||||
"vec3",
|
||||
"vec2",
|
||||
"block_state",
|
||||
"block_predicate",
|
||||
"item_stack",
|
||||
"item_predicate",
|
||||
"color",
|
||||
"component",
|
||||
"message",
|
||||
"nbt_compound_tag",
|
||||
"nbt_tag",
|
||||
"nbt_path",
|
||||
"objective",
|
||||
"objective_criteria",
|
||||
"operation",
|
||||
"particle",
|
||||
"angle",
|
||||
"rotation",
|
||||
"scoreboard_slot",
|
||||
"score_holder",
|
||||
"swizzle",
|
||||
"team",
|
||||
"item_slot",
|
||||
"resource_location",
|
||||
"mob_effect",
|
||||
"function",
|
||||
"entity_anchor",
|
||||
"int_range",
|
||||
"float_range",
|
||||
"item_enchantment",
|
||||
"entity_summon",
|
||||
"dimension",
|
||||
"time",
|
||||
"resource_or_tag",
|
||||
"resource",
|
||||
"uuid"
|
||||
"minecraft:entity",
|
||||
"minecraft:game_profile",
|
||||
"minecraft:block_pos",
|
||||
"minecraft:column_pos",
|
||||
"minecraft:vec3",
|
||||
"minecraft:vec2",
|
||||
"minecraft:block_state",
|
||||
"minecraft:block_predicate",
|
||||
"minecraft:item_stack",
|
||||
"minecraft:item_predicate",
|
||||
"minecraft:color",
|
||||
"minecraft:component",
|
||||
"minecraft:message",
|
||||
"minecraft:nbt_compound_tag",
|
||||
"minecraft:nbt_tag",
|
||||
"minecraft:nbt_path",
|
||||
"minecraft:objective",
|
||||
"minecraft:objective_criteria",
|
||||
"minecraft:operation",
|
||||
"minecraft:particle",
|
||||
"minecraft:angle",
|
||||
"minecraft:rotation",
|
||||
"minecraft:scoreboard_slot",
|
||||
"minecraft:score_holder",
|
||||
"minecraft:swizzle",
|
||||
"minecraft:team",
|
||||
"minecraft:item_slot",
|
||||
"minecraft:resource_location",
|
||||
"minecraft:mob_effect",
|
||||
"minecraft:function",
|
||||
"minecraft:entity_anchor",
|
||||
"minecraft:int_range",
|
||||
"minecraft:float_range",
|
||||
"minecraft:item_enchantment",
|
||||
"minecraft:entity_summon",
|
||||
"minecraft:dimension",
|
||||
"minecraft:time",
|
||||
"minecraft:resource_or_tag",
|
||||
"minecraft:resource",
|
||||
"minecraft:uuid"
|
||||
]
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren