Remove 2. Constructor in VersionValueMap

This commit is contained in:
Bixilon 2020-12-14 20:05:04 +01:00
parent 16c5ff8c89
commit 1aecd27657
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
14 changed files with 27 additions and 26 deletions

View File

@ -37,11 +37,11 @@ public class ChangeableIdentifier extends VersionValueMap<String> {
} }
public ChangeableIdentifier(IdentifierSet... sets) { public ChangeableIdentifier(IdentifierSet... sets) {
super(sets, true); super(sets);
} }
public ChangeableIdentifier(String name) { public ChangeableIdentifier(String name) {
super(name); super(new MapSet<>(Versions.LOWEST_VERSION_SUPPORTED.getVersionId(), name));
} }
public boolean isValidName(String name, int versionId) { public boolean isValidName(String name, int versionId) {

View File

@ -13,8 +13,6 @@
package de.bixilon.minosoft.data; package de.bixilon.minosoft.data;
import de.bixilon.minosoft.data.mappings.versions.Versions;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -24,14 +22,14 @@ public class VersionValueMap<V> {
public VersionValueMap() { public VersionValueMap() {
} }
public VersionValueMap(MapSet<Integer, V>[] sets, boolean unused) { public VersionValueMap(MapSet<Integer, V>[] sets) {
for (MapSet<Integer, V> set : sets) { for (MapSet<Integer, V> set : sets) {
this.values.put(set.getKey(), set.getValue()); this.values.put(set.getKey(), set.getValue());
} }
} }
public VersionValueMap(V value) { public VersionValueMap(MapSet<Integer, V> set) {
this.values.put(Versions.LOWEST_VERSION_SUPPORTED.getVersionId(), value); this.values.put(set.getKey(), set.getValue());
} }
public V get(int versionId) { public V get(int versionId) {

View File

@ -19,6 +19,7 @@ import de.bixilon.minosoft.data.VersionValueMap;
import de.bixilon.minosoft.data.inventory.Slot; import de.bixilon.minosoft.data.inventory.Slot;
import de.bixilon.minosoft.data.mappings.blocks.Block; import de.bixilon.minosoft.data.mappings.blocks.Block;
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData; import de.bixilon.minosoft.data.mappings.particle.data.ParticleData;
import de.bixilon.minosoft.data.mappings.versions.Versions;
import de.bixilon.minosoft.data.text.ChatComponent; import de.bixilon.minosoft.data.text.ChatComponent;
import de.bixilon.minosoft.data.world.BlockPosition; import de.bixilon.minosoft.data.world.BlockPosition;
import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.logging.Log;
@ -118,14 +119,14 @@ public class EntityMetaData {
OPT_VAR_INT(new MapSet[]{new MapSet<>(459, 17)}), OPT_VAR_INT(new MapSet[]{new MapSet<>(459, 17)}),
POSE(new MapSet[]{new MapSet<>(461, 18)}); POSE(new MapSet[]{new MapSet<>(461, 18)});
final VersionValueMap<Integer> valueMap; private final VersionValueMap<Integer> valueMap;
EntityMetaDataValueTypes(MapSet<Integer, Integer>[] values) { EntityMetaDataValueTypes(MapSet<Integer, Integer>[] values) {
this.valueMap = new VersionValueMap<>(values, true); this.valueMap = new VersionValueMap<>(values);
} }
EntityMetaDataValueTypes(int id) { EntityMetaDataValueTypes(int id) {
this.valueMap = new VersionValueMap<>(id); this.valueMap = new VersionValueMap<>(new MapSet<>(Versions.LOWEST_VERSION_SUPPORTED.getVersionId(), id));
} }
public static EntityMetaDataValueTypes byId(int id, int versionId) { public static EntityMetaDataValueTypes byId(int id, int versionId) {

View File

@ -40,7 +40,7 @@ data class VillagerData(val type: VillagerTypes, val profession: VillagerProfess
ZOMBIE(arrayOf(MapSet(204, -1), MapSet(315, -100))); ZOMBIE(arrayOf(MapSet(204, -1), MapSet(315, -100)));
// used earlier (ZombieVillagerMeta) // used earlier (ZombieVillagerMeta)
private val valueMap = VersionValueMap(values as Array<out MapSet<Int, Int>>, true) private val valueMap = VersionValueMap(values as Array<out MapSet<Int, Int>>)
fun getId(versionId: Int): Int { fun getId(versionId: Int): Int {

View File

@ -15,6 +15,7 @@ package de.bixilon.minosoft.data.inventory;
import de.bixilon.minosoft.data.MapSet; import de.bixilon.minosoft.data.MapSet;
import de.bixilon.minosoft.data.VersionValueMap; import de.bixilon.minosoft.data.VersionValueMap;
import de.bixilon.minosoft.data.mappings.versions.Versions;
public class InventorySlots { public class InventorySlots {
public enum PlayerInventorySlots implements InventoryInterface { public enum PlayerInventorySlots implements InventoryInterface {
@ -94,11 +95,11 @@ public class InventorySlots {
final VersionValueMap<Integer> valueMap; final VersionValueMap<Integer> valueMap;
EntityInventorySlots(MapSet<Integer, Integer>[] values) { EntityInventorySlots(MapSet<Integer, Integer>[] values) {
this.valueMap = new VersionValueMap<>(values, true); this.valueMap = new VersionValueMap<>(values);
} }
EntityInventorySlots(int id) { EntityInventorySlots(int id) {
this.valueMap = new VersionValueMap<>(id); this.valueMap = new VersionValueMap<>(new MapSet<>(Versions.LOWEST_VERSION_SUPPORTED.getVersionId(), id));
} }
public static EntityInventorySlots byId(int id, int versionId) { public static EntityInventorySlots byId(int id, int versionId) {

View File

@ -84,7 +84,7 @@ public class PacketBlockEntityMetadata implements ClientboundPacket {
final VersionValueMap<Integer> valueMap; final VersionValueMap<Integer> valueMap;
BlockEntityActions(MapSet<Integer, Integer>[] values) { BlockEntityActions(MapSet<Integer, Integer>[] values) {
this.valueMap = new VersionValueMap<>(values, true); this.valueMap = new VersionValueMap<>(values);
} }
public static BlockEntityActions byId(int id, int versionId) { public static BlockEntityActions byId(int id, int versionId) {

View File

@ -70,7 +70,7 @@ public class PacketChangeGameState implements ClientboundPacket {
final VersionValueMap<Integer> valueMap; final VersionValueMap<Integer> valueMap;
Reason(MapSet<Integer, Integer>[] values) { Reason(MapSet<Integer, Integer>[] values) {
this.valueMap = new VersionValueMap<>(values, true); this.valueMap = new VersionValueMap<>(values);
} }
public static Reason byId(int id, int versionId) { public static Reason byId(int id, int versionId) {

View File

@ -150,7 +150,7 @@ public class PacketEffect implements ClientboundPacket {
final VersionValueMap<Integer> valueMap; final VersionValueMap<Integer> valueMap;
EffectEffects(MapSet<Integer, Integer>[] values) { EffectEffects(MapSet<Integer, Integer>[] values) {
this.valueMap = new VersionValueMap<>(values, true); this.valueMap = new VersionValueMap<>(values);
} }
public static EffectEffects byId(int id, int versionId) { public static EffectEffects byId(int id, int versionId) {

View File

@ -57,7 +57,7 @@ public class PacketEntityAnimation implements ClientboundPacket {
final VersionValueMap<Integer> valueMap; final VersionValueMap<Integer> valueMap;
EntityAnimations(MapSet<Integer, Integer>[] values) { EntityAnimations(MapSet<Integer, Integer>[] values) {
this.valueMap = new VersionValueMap<>(values, true); this.valueMap = new VersionValueMap<>(values);
} }
public static EntityAnimations byId(int id, int versionId) { public static EntityAnimations byId(int id, int versionId) {

View File

@ -15,6 +15,7 @@ package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.data.MapSet; import de.bixilon.minosoft.data.MapSet;
import de.bixilon.minosoft.data.VersionValueMap; import de.bixilon.minosoft.data.VersionValueMap;
import de.bixilon.minosoft.data.mappings.versions.Versions;
import de.bixilon.minosoft.data.text.ChatComponent; import de.bixilon.minosoft.data.text.ChatComponent;
import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
@ -93,14 +94,14 @@ public class PacketTitle implements ClientboundPacket {
HIDE(new MapSet[]{new MapSet<>(18, 3), new MapSet<>(302, 4)}), HIDE(new MapSet[]{new MapSet<>(18, 3), new MapSet<>(302, 4)}),
RESET(new MapSet[]{new MapSet<>(18, 4), new MapSet<>(302, 5)}); RESET(new MapSet[]{new MapSet<>(18, 4), new MapSet<>(302, 5)});
final VersionValueMap<Integer> valueMap; private final VersionValueMap<Integer> valueMap;
TitleActions(MapSet<Integer, Integer>[] values) { TitleActions(MapSet<Integer, Integer>[] values) {
this.valueMap = new VersionValueMap<>(values, true); this.valueMap = new VersionValueMap<>(values);
} }
TitleActions(int id) { TitleActions(int id) {
this.valueMap = new VersionValueMap<>(id); this.valueMap = new VersionValueMap<>(new MapSet<>(Versions.LOWEST_VERSION_SUPPORTED.getVersionId(), id));
} }
public static TitleActions byId(int id, int versionId) { public static TitleActions byId(int id, int versionId) {

View File

@ -71,7 +71,7 @@ public class PacketEntityAction implements ServerboundPacket {
final VersionValueMap<Integer> valueMap; final VersionValueMap<Integer> valueMap;
EntityActions(MapSet<Integer, Integer>[] values) { EntityActions(MapSet<Integer, Integer>[] values) {
this.valueMap = new VersionValueMap<>(values, true); this.valueMap = new VersionValueMap<>(values);
} }
public static EntityActions byId(int id, int versionId) { public static EntityActions byId(int id, int versionId) {

View File

@ -248,7 +248,7 @@ public class InByteBuffer {
throw new IllegalArgumentException("Bad nbt"); throw new IllegalArgumentException("Bad nbt");
} }
} }
TagTypes type = TagTypes.byId(readByte()); TagTypes type = TagTypes.byId(readUnsignedByte());
if (type == TagTypes.COMPOUND) { if (type == TagTypes.COMPOUND) {
// shouldn't be a subtag // shouldn't be a subtag
return new CompoundTag(false, this); return new CompoundTag(false, this);

View File

@ -25,7 +25,7 @@ public final class BitByte {
public static byte getBitCount(int input) { public static byte getBitCount(int input) {
byte ret = 0; byte ret = 0;
for (byte i = 0; i < Short.BYTES * 8; i++) { // bytes to bits for (byte i = 0; i < Short.SIZE; i++) {
if (isBitSet(input, i)) { if (isBitSet(input, i)) {
ret++; ret++;
} }

View File

@ -20,8 +20,8 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
public class ListTag extends NBTTag { public class ListTag extends NBTTag {
final TagTypes type; private final TagTypes type;
final ArrayList<NBTTag> list; private final ArrayList<NBTTag> list;
public ListTag(TagTypes type, ArrayList<NBTTag> list) { public ListTag(TagTypes type, ArrayList<NBTTag> list) {
this.type = type; this.type = type;
@ -30,7 +30,7 @@ public class ListTag extends NBTTag {
public ListTag(TagTypes type, NBTTag[] list) { public ListTag(TagTypes type, NBTTag[] list) {
this.type = type; this.type = type;
this.list = (ArrayList<NBTTag>) Arrays.asList(list); this.list = new ArrayList<>(Arrays.asList(list));
} }
public ListTag(InByteBuffer buffer) { public ListTag(InByteBuffer buffer) {