Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 16:12:43 +01:00
Move to proper FU usage
Dieser Commit ist enthalten in:
Ursprung
79708fe952
Commit
6de1ba9f30
@ -4,8 +4,8 @@ import nl.matsv.viabackwards.ViaBackwards;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntObjectMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import us.myles.viaversion.libs.gson.JsonElement;
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class VBItemMappings {
|
public class VBItemMappings {
|
||||||
|
|
||||||
private final IntObjectMap<MappedItem> itemMapping;
|
private final Int2ObjectMap<MappedItem> itemMapping;
|
||||||
|
|
||||||
public VBItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
|
public VBItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
|
||||||
Map<Integer, MappedItem> itemMapping = new HashMap<>();
|
Map<Integer, MappedItem> itemMapping = new HashMap<>();
|
||||||
@ -46,7 +46,7 @@ public class VBItemMappings {
|
|||||||
itemMapping.put(id, new MappedItem(mappedId, name));
|
itemMapping.put(id, new MappedItem(mappedId, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.itemMapping = CollectionUtil.createIntObjectMap(itemMapping);
|
this.itemMapping = new Int2ObjectOpenHashMap<>(itemMapping, 1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -23,8 +23,8 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.exception.CancelException;
|
import us.myles.ViaVersion.exception.CancelException;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -45,7 +45,7 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
|||||||
private final List<MetaHandlerSettings> metaHandlers = new ArrayList<>();
|
private final List<MetaHandlerSettings> metaHandlers = new ArrayList<>();
|
||||||
private final MetaType displayNameMetaType;
|
private final MetaType displayNameMetaType;
|
||||||
private final int displayNameIndex;
|
private final int displayNameIndex;
|
||||||
protected IntMap typeMapping;
|
protected Int2IntMap typeMapping;
|
||||||
|
|
||||||
EntityRewriterBase(T protocol) {
|
EntityRewriterBase(T protocol) {
|
||||||
this(protocol, MetaType1_9.String, 2);
|
this(protocol, MetaType1_9.String, 2);
|
||||||
@ -101,7 +101,10 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
|||||||
* @param <T> new type class
|
* @param <T> new type class
|
||||||
*/
|
*/
|
||||||
public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) {
|
public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) {
|
||||||
if (typeMapping == null) typeMapping = CollectionUtil.createIntMap(oldTypes.length);
|
if (typeMapping == null) {
|
||||||
|
typeMapping = new Int2IntOpenHashMap(oldTypes.length, 1F);
|
||||||
|
typeMapping.defaultReturnValue(-1);
|
||||||
|
}
|
||||||
for (EntityType oldType : oldTypes) {
|
for (EntityType oldType : oldTypes) {
|
||||||
try {
|
try {
|
||||||
T newType = Enum.valueOf(newTypeClass, oldType.name());
|
T newType = Enum.valueOf(newTypeClass, oldType.name());
|
||||||
@ -124,7 +127,10 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mapEntityDirect(int oldType, int newType) {
|
private void mapEntityDirect(int oldType, int newType) {
|
||||||
if (typeMapping == null) typeMapping = CollectionUtil.createIntMap();
|
if (typeMapping == null) {
|
||||||
|
typeMapping = new Int2IntOpenHashMap();
|
||||||
|
typeMapping.defaultReturnValue(-1);
|
||||||
|
}
|
||||||
typeMapping.put(oldType, newType);
|
typeMapping.put(oldType, newType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
|||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntObjectMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import us.myles.viaversion.libs.gson.JsonElement;
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||||
@ -37,13 +37,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> extends ItemRewriterBase<T> {
|
public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> extends ItemRewriterBase<T> {
|
||||||
|
|
||||||
private static final Map<String, IntObjectMap<MappedLegacyBlockItem>> LEGACY_MAPPINGS = new HashMap<>();
|
private static final Map<String, Int2ObjectMap<MappedLegacyBlockItem>> LEGACY_MAPPINGS = new HashMap<>();
|
||||||
protected final IntObjectMap<MappedLegacyBlockItem> replacementData;
|
protected final Int2ObjectMap<MappedLegacyBlockItem> replacementData;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
JsonObject jsonObject = VBMappingDataLoader.loadFromDataDir("legacy-mappings.json");
|
JsonObject jsonObject = VBMappingDataLoader.loadFromDataDir("legacy-mappings.json");
|
||||||
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||||
IntObjectMap<MappedLegacyBlockItem> mappings = CollectionUtil.createIntObjectMap(8);
|
Int2ObjectMap<MappedLegacyBlockItem> mappings = new Int2ObjectOpenHashMap<>(8);
|
||||||
LEGACY_MAPPINGS.put(entry.getKey(), mappings);
|
LEGACY_MAPPINGS.put(entry.getKey(), mappings);
|
||||||
for (Map.Entry<String, JsonElement> dataEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
for (Map.Entry<String, JsonElement> dataEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
||||||
JsonObject object = dataEntry.getValue().getAsJsonObject();
|
JsonObject object = dataEntry.getValue().getAsJsonObject();
|
||||||
|
@ -11,13 +11,11 @@
|
|||||||
package nl.matsv.viabackwards.api.rewriters;
|
package nl.matsv.viabackwards.api.rewriters;
|
||||||
|
|
||||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntObjectMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class LegacySoundRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
|
public abstract class LegacySoundRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
|
||||||
protected final IntObjectMap<SoundData> soundRewrites = CollectionUtil.createIntObjectMap(64);
|
protected final Int2ObjectMap<SoundData> soundRewrites = new Int2ObjectOpenHashMap<>(64);
|
||||||
|
|
||||||
protected LegacySoundRewriter(T protocol) {
|
protected LegacySoundRewriter(T protocol) {
|
||||||
super(protocol);
|
super(protocol);
|
||||||
@ -44,8 +42,8 @@ public abstract class LegacySoundRewriter<T extends BackwardsProtocol> extends R
|
|||||||
SoundData data = soundRewrites.get(soundId);
|
SoundData data = soundRewrites.get(soundId);
|
||||||
if (data != null) return data.getReplacementSound();
|
if (data != null) return data.getReplacementSound();
|
||||||
|
|
||||||
for (Map.Entry<Integer, SoundData> entry : soundRewrites.getMap().entrySet()) {
|
for (Int2ObjectMap.Entry<SoundData> entry : soundRewrites.int2ObjectEntrySet()) {
|
||||||
if (soundId > entry.getKey()) {
|
if (soundId > entry.getIntKey()) {
|
||||||
if (entry.getValue().isAdded()) {
|
if (entry.getValue().isAdded()) {
|
||||||
newSoundId--;
|
newSoundId--;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package nl.matsv.viabackwards.protocol.protocol1_10to1_11;
|
package nl.matsv.viabackwards.protocol.protocol1_10to1_11;
|
||||||
|
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
|
||||||
public class PotionSplashHandler {
|
public class PotionSplashHandler {
|
||||||
|
|
||||||
private static final IntMap DATA = CollectionUtil.createIntMap(14);
|
private static final Int2IntMap DATA = new Int2IntOpenHashMap(14, 1F);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
DATA.defaultReturnValue(-1);
|
||||||
DATA.put(2039713, 5); // night vision
|
DATA.put(2039713, 5); // night vision
|
||||||
DATA.put(8356754, 7); // invisibility
|
DATA.put(8356754, 7); // invisibility
|
||||||
DATA.put(2293580, 9); // jump boost
|
DATA.put(2293580, 9); // jump boost
|
||||||
|
@ -339,7 +339,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
|||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
// Handle spawner block entity (map to itself with custom handler)
|
// Handle spawner block entity (map to itself with custom handler)
|
||||||
MappedLegacyBlockItem data = replacementData.getMap().computeIfAbsent(52, s -> new MappedLegacyBlockItem(52, (short) -1, null, false));
|
MappedLegacyBlockItem data = replacementData.computeIfAbsent(52, s -> new MappedLegacyBlockItem(52, (short) -1, null, false));
|
||||||
data.setBlockEntityHandler((b, tag) -> {
|
data.setBlockEntityHandler((b, tag) -> {
|
||||||
EntityIdRewriter.toClientSpawner(tag, true);
|
EntityIdRewriter.toClientSpawner(tag, true);
|
||||||
return tag;
|
return tag;
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||||
|
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
|
||||||
public class MapColorMapping {
|
public class MapColorMapping {
|
||||||
private static final IntMap MAPPING = CollectionUtil.createIntMap(64);
|
private static final Int2IntMap MAPPING = new Int2IntOpenHashMap(64, 1F);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
MAPPING.defaultReturnValue(-1);
|
||||||
MAPPING.put(144, 59); // (148, 124, 114) -> (148, 124, 114)
|
MAPPING.put(144, 59); // (148, 124, 114) -> (148, 124, 114)
|
||||||
MAPPING.put(145, 56); // (180, 153, 139) -> (180, 153, 139)
|
MAPPING.put(145, 56); // (180, 153, 139) -> (180, 153, 139)
|
||||||
MAPPING.put(146, 56); // (209, 177, 161) -> (209, 177, 161)
|
MAPPING.put(146, 56); // (209, 177, 161) -> (209, 177, 161)
|
||||||
|
@ -13,15 +13,15 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handler
|
|||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
import us.myles.ViaVersion.api.Pair;
|
import us.myles.ViaVersion.api.Pair;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntObjectMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
|
|
||||||
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||||
|
|
||||||
private static final IntObjectMap<Pair<String, Byte>> FLOWERS = CollectionUtil.createIntObjectMap(22);
|
private static final Int2ObjectMap<Pair<String, Byte>> FLOWERS = new Int2ObjectOpenHashMap<>(22, 1F);
|
||||||
private static final Pair<String, Byte> AIR = new Pair<>("minecraft:air", (byte) 0);
|
private static final Pair<String, Byte> AIR = new Pair<>("minecraft:air", (byte) 0);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class EntityTypeMapping {
|
public class EntityTypeMapping {
|
||||||
private static final IntMap TYPES = CollectionUtil.createIntMap();
|
private static final Int2IntMap TYPES = new Int2IntOpenHashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
TYPES.defaultReturnValue(-1);
|
||||||
try {
|
try {
|
||||||
Field field = EntityTypeRewriter.class.getDeclaredField("ENTITY_TYPES");
|
Field field = EntityTypeRewriter.class.getDeclaredField("ENTITY_TYPES");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
IntMap entityTypes = (IntMap) field.get(null);
|
Int2IntMap entityTypes = (Int2IntMap) field.get(null);
|
||||||
entityTypes.getMap().forEach((type1_12, type1_13) -> EntityTypeMapping.TYPES.put(type1_13, type1_12));
|
for (Int2IntMap.Entry entry : entityTypes.int2IntEntrySet()) {
|
||||||
|
EntityTypeMapping.TYPES.put(entry.getIntValue(), entry.getIntKey());
|
||||||
|
}
|
||||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,8 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int itemId = wrapper.read(Type.VAR_INT);
|
int itemId = wrapper.read(Type.VAR_INT);
|
||||||
Integer oldId = MappingData.oldToNewItems.inverse().get(itemId);
|
int oldId = MappingData.oldToNewItems.inverse().get(itemId);
|
||||||
if (oldId != null) {
|
if (oldId != -1) {
|
||||||
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
|
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
|
||||||
if (eggEntityId.isPresent()) {
|
if (eggEntityId.isPresent()) {
|
||||||
itemId = 383 << 16;
|
itemId = 383 << 16;
|
||||||
@ -413,12 +413,12 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
int id = wrapper.get(Type.INT, 0);
|
int id = wrapper.get(Type.INT, 0);
|
||||||
int data = wrapper.get(Type.INT, 1);
|
int data = wrapper.get(Type.INT, 1);
|
||||||
if (id == 1010) { // Play record
|
if (id == 1010) { // Play record
|
||||||
wrapper.set(Type.INT, 1, data = MappingData.oldToNewItems.inverse().get(data) >> 4);
|
wrapper.set(Type.INT, 1, MappingData.oldToNewItems.inverse().get(data) >> 4);
|
||||||
} else if (id == 2001) { // Block break + block break sound
|
} else if (id == 2001) { // Block break + block break sound
|
||||||
data = toOldId(data);
|
data = toOldId(data);
|
||||||
int blockId = data >> 4;
|
int blockId = data >> 4;
|
||||||
int blockData = data & 0xF;
|
int blockData = data & 0xF;
|
||||||
wrapper.set(Type.INT, 1, data = (blockId & 0xFFF) | (blockData << 12));
|
wrapper.set(Type.INT, 1, (blockId & 0xFFF) | (blockData << 12));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -543,8 +543,8 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
|
|
||||||
// No custom mapping found, look at VV mappings
|
// No custom mapping found, look at VV mappings
|
||||||
if (item.getIdentifier() == originalId) {
|
if (item.getIdentifier() == originalId) {
|
||||||
Integer oldId = MappingData.oldToNewItems.inverse().get(item.getIdentifier());
|
int oldId = MappingData.oldToNewItems.inverse().get(item.getIdentifier());
|
||||||
if (oldId != null) {
|
if (oldId != -1) {
|
||||||
rawId = itemIdToRaw(oldId, item, tag);
|
rawId = itemIdToRaw(oldId, item, tag);
|
||||||
} else if (item.getIdentifier() == 362) { // base/colorless shulker box
|
} else if (item.getIdentifier() == 362) { // base/colorless shulker box
|
||||||
rawId = 0xe50000; // purple shulker box
|
rawId = 0xe50000; // purple shulker box
|
||||||
|
@ -13,16 +13,15 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
|||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
import us.myles.ViaVersion.util.fastutil.CollectionUtil;
|
import us.myles.viaversion.libs.fastutil.ints.IntOpenHashSet;
|
||||||
import us.myles.ViaVersion.util.fastutil.IntSet;
|
import us.myles.viaversion.libs.fastutil.ints.IntSet;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class BackwardsBlockStorage extends StoredObject {
|
public class BackwardsBlockStorage extends StoredObject {
|
||||||
// This BlockStorage is very exclusive (;
|
// This BlockStorage is very exclusive (;
|
||||||
private static final IntSet WHITELIST = CollectionUtil.createIntSet(779);
|
private static final IntSet WHITELIST = new IntOpenHashSet(779);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Flower pots
|
// Flower pots
|
||||||
|
@ -122,8 +122,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
for (int j = 0; j < itemIds.length; j++) {
|
for (int j = 0; j < itemIds.length; j++) {
|
||||||
int itemId = itemIds[j];
|
int itemId = itemIds[j];
|
||||||
// Ignore new itemtags
|
// Ignore new itemtags
|
||||||
Integer oldId = MappingData.oldToNewItems.inverse().get(itemId);
|
int oldId = MappingData.oldToNewItems.inverse().get(itemId);
|
||||||
itemIds[j] = oldId != null ? oldId : -1;
|
itemIds[j] = oldId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,8 +586,8 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
|
|
||||||
|
|
||||||
public static int getNewItemId(int id) {
|
public static int getNewItemId(int id) {
|
||||||
Integer newId = MappingData.oldToNewItems.get(id);
|
int newId = MappingData.oldToNewItems.get(id);
|
||||||
if (newId == null) {
|
if (newId == -1) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 item for 1.13.2 item " + id);
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 item for 1.13.2 item " + id);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -595,8 +595,8 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getOldItemId(int id) {
|
public static int getOldItemId(int id) {
|
||||||
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
|
int oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||||
if (oldId == null) {
|
if (oldId == -1) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 item for 1.14 item " + id);
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 item for 1.14 item " + id);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,8 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
wrapper.passthrough(Type.STRING);
|
wrapper.passthrough(Type.STRING);
|
||||||
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||||
for (int j = 0; j < itemIds.length; j++) {
|
for (int j = 0; j < itemIds.length; j++) {
|
||||||
Integer oldId = MappingData.oldToNewItems.inverse().get(itemIds[j]);
|
int oldId = MappingData.oldToNewItems.inverse().get(itemIds[j]);
|
||||||
itemIds[j] = oldId != null ? oldId : -1;
|
itemIds[j] = oldId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,8 +179,8 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getNewItemId(int id) {
|
public static int getNewItemId(int id) {
|
||||||
Integer newId = MappingData.oldToNewItems.get(id);
|
int newId = MappingData.oldToNewItems.get(id);
|
||||||
if (newId == null) {
|
if (newId == -1) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 item for 1.14.4 item " + id);
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 item for 1.14.4 item " + id);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -189,8 +189,8 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
|
|
||||||
|
|
||||||
public static int getOldItemId(int id) {
|
public static int getOldItemId(int id) {
|
||||||
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
|
int oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||||
if (oldId == null) {
|
if (oldId == -1) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14.4 item for 1.15 item " + id);
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14.4 item for 1.15 item " + id);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -159,10 +159,8 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id -> {
|
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
|
||||||
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
|
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
|
||||||
return oldId != null ? oldId : -1;
|
|
||||||
}, entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
|
|
||||||
|
|
||||||
cancelIncoming(ServerboundPackets1_14.UPDATE_JIGSAW_BLOCK);
|
cancelIncoming(ServerboundPackets1_14.UPDATE_JIGSAW_BLOCK);
|
||||||
}
|
}
|
||||||
|
@ -274,8 +274,8 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getNewItemId(int id) {
|
public static int getNewItemId(int id) {
|
||||||
Integer newId = MappingData.oldToNewItems.get(id);
|
int newId = MappingData.oldToNewItems.get(id);
|
||||||
if (newId == null) {
|
if (newId == -1) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 item for 1.15 item " + id);
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 item for 1.15 item " + id);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -283,8 +283,8 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getOldItemId(int id) {
|
public static int getOldItemId(int id) {
|
||||||
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
|
int oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||||
if (oldId == null) {
|
if (oldId == -1) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 item for 1.16 item " + id);
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 item for 1.16 item " + id);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren