From 188cc5019f91b2805661dbd85cbc12aaa39a57b0 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Sat, 21 Apr 2018 11:11:12 -0300 Subject: [PATCH] Maybe better performance? --- .../packets/WorldPackets.java | 21 ++++++++++--------- .../storage/BlockStorage.java | 6 +++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/WorldPackets.java index 1afdfc422..e75f2df0f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/WorldPackets.java @@ -248,17 +248,18 @@ public class WorldPackets { } public static int toNewId(int oldId) { - if (MappingData.oldToNewBlocks.containsKey(oldId)) { - return MappingData.oldToNewBlocks.get(oldId); - } else { - if (MappingData.oldToNewBlocks.containsKey((oldId >> 4) << 4)) { - System.out.println("Missing block " + oldId); - return MappingData.oldToNewBlocks.get((oldId >> 4) << 4); - } - System.out.println("Missing block completely " + oldId); - // Default stone - return 1; + Integer newId = MappingData.oldToNewBlocks.get(oldId); + if (newId != null) { + return newId; } + newId = MappingData.oldToNewBlocks.get(oldId & ~0xF); // Remove data + if (newId != null) { + System.out.println("Missing block " + oldId); + return newId; + } + System.out.println("Missing block completely " + oldId); + // Default stone + return 1; } private static int checkStorage(UserConnection user, Position position, int newId) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/storage/BlockStorage.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/storage/BlockStorage.java index 6e3f0de25..862351655 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/storage/BlockStorage.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/storage/BlockStorage.java @@ -1,19 +1,19 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage; +import com.google.common.collect.Sets; import lombok.AllArgsConstructor; import lombok.Data; import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.Position; -import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; public class BlockStorage extends StoredObject { // This BlockStorage is very exclusive (; - private static final List whitelist = new CopyOnWriteArrayList<>(); + private static final Set whitelist = Sets.newConcurrentHashSet(); static { // Flower pots