Implement base methods for tags

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-09-27 08:28:45 +10:00
parent 0278929667
commit 060be9b96a

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 + '}';
}
}