Use Key#namespaced in entity type enums (#3858)

This commit is contained in:
EnZaXD 2024-05-17 21:04:54 +02:00 committed by GitHub
parent 0427aec4ab
commit f92d241028
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 21 additions and 11 deletions

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_14 implements EntityType { public enum EntityTypes1_14 implements EntityType {
@ -211,7 +212,7 @@ public enum EntityTypes1_14 implements EntityType {
EntityTypes1_14(final EntityType parent) { EntityTypes1_14(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_14(final EntityType parent, @Nullable final String identifier) { EntityTypes1_14(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_15 implements EntityType { public enum EntityTypes1_15 implements EntityType {
@ -212,7 +213,7 @@ public enum EntityTypes1_15 implements EntityType {
EntityTypes1_15(final EntityType parent) { EntityTypes1_15(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_15(final EntityType parent, @Nullable final String identifier) { EntityTypes1_15(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_16 implements EntityType { public enum EntityTypes1_16 implements EntityType {
@ -216,7 +217,7 @@ public enum EntityTypes1_16 implements EntityType {
EntityTypes1_16(final EntityType parent) { EntityTypes1_16(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_16(final EntityType parent, @Nullable final String identifier) { EntityTypes1_16(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_16_2 implements EntityType { public enum EntityTypes1_16_2 implements EntityType {
@ -219,7 +220,7 @@ public enum EntityTypes1_16_2 implements EntityType {
EntityTypes1_16_2(final EntityType parent) { EntityTypes1_16_2(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_16_2(final EntityType parent, @Nullable final String identifier) { EntityTypes1_16_2(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_17 implements EntityType { public enum EntityTypes1_17 implements EntityType {
@ -225,7 +226,7 @@ public enum EntityTypes1_17 implements EntityType {
EntityTypes1_17(final EntityType parent) { EntityTypes1_17(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_17(final EntityType parent, @Nullable final String identifier) { EntityTypes1_17(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_19 implements EntityType { public enum EntityTypes1_19 implements EntityType {
@ -230,7 +231,7 @@ public enum EntityTypes1_19 implements EntityType {
EntityTypes1_19(final EntityType parent) { EntityTypes1_19(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_19(final EntityType parent, @Nullable final String identifier) { EntityTypes1_19(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_19_3 implements EntityType { public enum EntityTypes1_19_3 implements EntityType {
@ -231,7 +232,7 @@ public enum EntityTypes1_19_3 implements EntityType {
EntityTypes1_19_3(final EntityType parent) { EntityTypes1_19_3(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_19_3(final EntityType parent, @Nullable final String identifier) { EntityTypes1_19_3(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_19_4 implements EntityType { public enum EntityTypes1_19_4 implements EntityType {
@ -238,7 +239,7 @@ public enum EntityTypes1_19_4 implements EntityType {
EntityTypes1_19_4(final EntityType parent) { EntityTypes1_19_4(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_19_4(final EntityType parent, @Nullable final String identifier) { EntityTypes1_19_4(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_20_3 implements EntityType { public enum EntityTypes1_20_3 implements EntityType {
@ -240,7 +241,7 @@ public enum EntityTypes1_20_3 implements EntityType {
EntityTypes1_20_3(final EntityType parent) { EntityTypes1_20_3(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_20_3(final EntityType parent, @Nullable final String identifier) { EntityTypes1_20_3(final EntityType parent, @Nullable final String identifier) {

View File

@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil; import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale; import java.util.Locale;
import com.viaversion.viaversion.util.Key;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_20_5 implements EntityType { public enum EntityTypes1_20_5 implements EntityType {
@ -246,7 +247,7 @@ public enum EntityTypes1_20_5 implements EntityType {
EntityTypes1_20_5(final EntityType parent) { EntityTypes1_20_5(final EntityType parent) {
this.parent = parent; this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
} }
EntityTypes1_20_5(final EntityType parent, @Nullable final String identifier) { EntityTypes1_20_5(final EntityType parent, @Nullable final String identifier) {

View File

@ -1202,7 +1202,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
if (Key.stripMinecraftNamespace(id).equals("sweeping")) { if (Key.stripMinecraftNamespace(id).equals("sweeping")) {
// Renamed // Renamed
id = "minecraft:sweeping_edge"; id = Key.namespaced("sweeping_edge");
} }
final int intId = Enchantments1_20_5.keyToId(id); final int intId = Enchantments1_20_5.keyToId(id);