Implement base methods for tags

This commit is contained in:
md_5 2024-09-27 08:28:45 +10:00
parent 30fbdbaaf7
commit 5529a1769e
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.tag;
import java.util.Objects;
import net.minecraft.core.HolderSet;
import net.minecraft.core.IRegistry;
import net.minecraft.tags.TagKey;
@ -29,4 +30,30 @@ public abstract class CraftTag<N, B extends Keyed> implements Tag<B> {
public NamespacedKey getKey() {
return CraftNamespacedKey.fromMinecraft(tag.location());
}
@Override
public int hashCode() {
int hash = 3;
hash = 59 * hash + Objects.hashCode(this.registry);
hash = 59 * hash + Objects.hashCode(this.tag);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof CraftTag<?, ?> other)) {
return false;
}
return Objects.equals(this.registry, other.registry) && Objects.equals(this.tag, other.tag);
}
@Override
public String toString() {
return "CraftTag{" + this.tag + '}';
}
}