Fix various equality/nullability issues with registry values

This commit is contained in:
booky committed 2026-01-20 09:23:38 +01:00
1 parent 195ee0446a
commit 58a1ada322
50 files changed
+200 -138

No files matched your search

@@ -31,13 +31,15 @@ import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
import static com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil.indexValueOrThrow;
@NullMarked
public interface ChatType extends MappedEntity, CopyableEntity<ChatType>, DeepComparableEntity {
@UnknownNullability("only nullable for 1.19")
@@ -21,11 +21,13 @@ package com.github.retrooper.packetevents.protocol.chat;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticChatType extends AbstractMappedEntity implements ChatType {
private final @UnknownNullability("only nullable for 1.19") ChatTypeDecoration chatDecoration;
@@ -100,10 +102,9 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticChatType)) return false;
if (!super.equals(obj)) return false;
StaticChatType that = (StaticChatType) obj;
if (!Objects.equals(this.chatDecoration, that.chatDecoration)) return false;
if (!Objects.equals(this.overlayDecoration, that.overlayDecoration)) return false;
@@ -113,7 +114,7 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.chatDecoration, this.overlayDecoration, this.narrationDecoration, this.narrationPriority);
return Objects.hash(this.chatDecoration, this.overlayDecoration, this.narrationDecoration, this.narrationPriority);
}
@Override
@@ -24,8 +24,8 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@@ -87,9 +87,8 @@ public class ConfirmationDialog extends AbstractMappedEntity implements Dialog {
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof ConfirmationDialog)) return false;
if (!super.equals(obj)) return false;
ConfirmationDialog that = (ConfirmationDialog) obj;
if (!this.common.equals(that.common)) return false;
if (!this.yesButton.equals(that.yesButton)) return false;
@@ -98,6 +97,6 @@ public class ConfirmationDialog extends AbstractMappedEntity implements Dialog {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.common, this.yesButton, this.noButton);
return Objects.hash(this.common, this.yesButton, this.noButton);
}
}
@@ -28,8 +28,8 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.dialog.DialogLike;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface Dialog extends MappedEntity, DeepComparableEntity, CopyableEntity<Dialog>, DialogLike {
@@ -27,8 +27,8 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@@ -120,9 +120,8 @@ public class DialogListDialog extends AbstractMappedEntity implements Dialog {
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof DialogListDialog)) return false;
if (!super.equals(obj)) return false;
DialogListDialog that = (DialogListDialog) obj;
if (this.columns != that.columns) return false;
if (this.buttonWidth != that.buttonWidth) return false;
@@ -133,6 +132,6 @@ public class DialogListDialog extends AbstractMappedEntity implements Dialog {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.common, this.dialogs, this.exitAction, this.columns, this.buttonWidth);
return Objects.hash(this.common, this.dialogs, this.exitAction, this.columns, this.buttonWidth);
}
}
@@ -25,8 +25,8 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.List;
import java.util.Objects;
@@ -68,7 +68,6 @@ public class MultiActionDialog extends AbstractMappedEntity implements Dialog {
List<ActionButton> actions = compound.getListOrThrow("actions", ActionButton::decode, wrapper);
ActionButton action = compound.getOrNull("exit_action", ActionButton::decode, wrapper);
int columns = compound.getNumberTagValueOrDefault("columns", 2).intValue();
int buttonWidth = compound.getNumberTagValueOrDefault("button_width", 150).intValue();
return new MultiActionDialog(null, common, actions, action, columns);
}
@@ -110,9 +109,8 @@ public class MultiActionDialog extends AbstractMappedEntity implements Dialog {
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof MultiActionDialog)) return false;
if (!super.equals(obj)) return false;
MultiActionDialog that = (MultiActionDialog) obj;
if (this.columns != that.columns) return false;
if (!this.common.equals(that.common)) return false;
@@ -122,6 +120,6 @@ public class MultiActionDialog extends AbstractMappedEntity implements Dialog {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.common, this.actions, this.exitAction, this.columns);
return Objects.hash(this.common, this.actions, this.exitAction, this.columns);
}
}
@@ -26,8 +26,8 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@@ -85,9 +85,8 @@ public class NoticeDialog extends AbstractMappedEntity implements Dialog {
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof NoticeDialog)) return false;
if (!super.equals(obj)) return false;
NoticeDialog that = (NoticeDialog) obj;
if (!this.common.equals(that.common)) return false;
return this.action.equals(that.action);
@@ -95,6 +94,6 @@ public class NoticeDialog extends AbstractMappedEntity implements Dialog {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.common, this.action);
return Objects.hash(this.common, this.action);
}
}
@@ -25,8 +25,8 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@@ -108,9 +108,8 @@ public class ServerLinksDialog extends AbstractMappedEntity implements Dialog {
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof ServerLinksDialog)) return false;
if (!super.equals(obj)) return false;
ServerLinksDialog that = (ServerLinksDialog) obj;
if (this.columns != that.columns) return false;
if (this.buttonWidth != that.buttonWidth) return false;
@@ -120,6 +119,6 @@ public class ServerLinksDialog extends AbstractMappedEntity implements Dialog {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.common, this.exitAction, this.columns, this.buttonWidth);
return Objects.hash(this.common, this.exitAction, this.columns, this.buttonWidth);
}
}
@@ -28,8 +28,10 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface CatVariant extends MappedEntity, CopyableEntity<CatVariant>, DeepComparableEntity {
ResourceLocation getAssetId();
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticCatVariant extends AbstractMappedEntity implements CatVariant {
private final ResourceLocation assetId;
@@ -51,15 +53,14 @@ public class StaticCatVariant extends AbstractMappedEntity implements CatVariant
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof StaticCatVariant)) return false;
if (!super.equals(obj)) return false;
StaticCatVariant that = (StaticCatVariant) obj;
return this.assetId.equals(that.assetId);
}
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.assetId);
return Objects.hash(this.assetId);
}
}
@@ -30,8 +30,10 @@ import com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface ChickenVariant extends MappedEntity, CopyableEntity<ChickenVariant>, DeepComparableEntity {
ModelType getModelType();
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticChickenVariant extends AbstractMappedEntity implements ChickenVariant {
private final ModelType modelType;
@@ -58,9 +60,8 @@ public class StaticChickenVariant extends AbstractMappedEntity implements Chicke
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof StaticChickenVariant)) return false;
if (!super.equals(obj)) return false;
StaticChickenVariant that = (StaticChickenVariant) obj;
if (!this.modelType.equals(that.modelType)) return false;
return this.assetId.equals(that.assetId);
@@ -68,6 +69,6 @@ public class StaticChickenVariant extends AbstractMappedEntity implements Chicke
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.modelType, this.assetId);
return Objects.hash(this.modelType, this.assetId);
}
}
@@ -30,8 +30,10 @@ import com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface CowVariant extends MappedEntity, CopyableEntity<CowVariant>, DeepComparableEntity {
ModelType getModelType();
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticCowVariant extends AbstractMappedEntity implements CowVariant {
private final ModelType modelType;
@@ -58,9 +60,8 @@ public class StaticCowVariant extends AbstractMappedEntity implements CowVariant
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof StaticCowVariant)) return false;
if (!super.equals(obj)) return false;
StaticCowVariant that = (StaticCowVariant) obj;
if (!this.modelType.equals(that.modelType)) return false;
return this.assetId.equals(that.assetId);
@@ -68,6 +69,6 @@ public class StaticCowVariant extends AbstractMappedEntity implements CowVariant
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.modelType, this.assetId);
return Objects.hash(this.modelType, this.assetId);
}
}
@@ -29,7 +29,9 @@ import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
@NullMarked
public interface FrogVariant extends MappedEntity, CopyableEntity<FrogVariant>, DeepComparableEntity {
ResourceLocation getAssetId();
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticFrogVariant extends AbstractMappedEntity implements FrogVariant {
private final ResourceLocation assetId;
@@ -51,15 +53,14 @@ public class StaticFrogVariant extends AbstractMappedEntity implements FrogVaria
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof StaticFrogVariant)) return false;
if (!super.equals(obj)) return false;
StaticFrogVariant that = (StaticFrogVariant) obj;
return this.assetId.equals(that.assetId);
}
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.assetId);
return Objects.hash(this.assetId);
}
}
@@ -63,9 +63,8 @@ public class StaticZombieNautilusVariant extends AbstractMappedEntity implements
}
@Override
public boolean deepEquals(Object obj) {
if (obj == null || getClass() != obj.getClass()) return false;
if (!super.equals(obj)) return false;
public boolean deepEquals(@Nullable Object obj) {
if (obj == null || this.getClass() != obj.getClass()) return false;
StaticZombieNautilusVariant that = (StaticZombieNautilusVariant) obj;
if (this.modelType != that.modelType) return false;
return this.assetId.equals(that.assetId);
@@ -73,6 +72,6 @@ public class StaticZombieNautilusVariant extends AbstractMappedEntity implements
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.modelType, this.assetId);
return Objects.hash(this.modelType, this.assetId);
}
}
@@ -30,8 +30,8 @@ import com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
* @versions 1.21.11+
@@ -30,8 +30,10 @@ import com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface PigVariant extends MappedEntity, CopyableEntity<PigVariant>, DeepComparableEntity {
ModelType getModelType();
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticPigVariant extends AbstractMappedEntity implements PigVariant {
private final ModelType modelType;
@@ -58,9 +60,8 @@ public class StaticPigVariant extends AbstractMappedEntity implements PigVariant
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof StaticPigVariant)) return false;
if (!super.equals(obj)) return false;
StaticPigVariant that = (StaticPigVariant) obj;
if (!this.modelType.equals(that.modelType)) return false;
return this.assetId.equals(that.assetId);
@@ -68,6 +69,6 @@ public class StaticPigVariant extends AbstractMappedEntity implements PigVariant
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.modelType, this.assetId);
return Objects.hash(this.modelType, this.assetId);
}
}
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.protocol.sound.Sound;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticWolfSoundVariant extends AbstractMappedEntity implements WolfSoundVariant {
private final Sound ambientSound;
@@ -93,9 +95,8 @@ public class StaticWolfSoundVariant extends AbstractMappedEntity implements Wolf
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (!(obj instanceof StaticWolfSoundVariant)) return false;
if (!super.equals(obj)) return false;
StaticWolfSoundVariant that = (StaticWolfSoundVariant) obj;
if (!this.ambientSound.equals(that.ambientSound)) return false;
if (!this.deathSound.equals(that.deathSound)) return false;
@@ -107,6 +108,6 @@ public class StaticWolfSoundVariant extends AbstractMappedEntity implements Wolf
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.ambientSound, this.deathSound, this.growlSound, this.hurtSound, this.pantSound, this.whineSound);
return Objects.hash(this.ambientSound, this.deathSound, this.growlSound, this.hurtSound, this.pantSound, this.whineSound);
}
}
@@ -24,10 +24,12 @@ import com.github.retrooper.packetevents.protocol.world.biome.Biome;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticWolfVariant extends AbstractMappedEntity implements WolfVariant {
private final ResourceLocation wildTexture;
@@ -98,10 +100,9 @@ public class StaticWolfVariant extends AbstractMappedEntity implements WolfVaria
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticWolfVariant)) return false;
if (!super.equals(obj)) return false;
StaticWolfVariant that = (StaticWolfVariant) obj;
if (!this.wildTexture.equals(that.wildTexture)) return false;
if (!this.tameTexture.equals(that.tameTexture)) return false;
@@ -111,7 +112,7 @@ public class StaticWolfVariant extends AbstractMappedEntity implements WolfVaria
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.wildTexture, this.tameTexture, this.angryTexture, this.biomes);
return Objects.hash(this.wildTexture, this.tameTexture, this.angryTexture, this.biomes);
}
@Override
@@ -27,8 +27,10 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.sound.Sound;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface WolfSoundVariant extends MappedEntity, CopyableEntity<WolfSoundVariant>, DeepComparableEntity {
Sound getAmbientSound();
@@ -33,8 +33,10 @@ import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface WolfVariant extends MappedEntity, CopyableEntity<WolfVariant>, DeepComparableEntity {
ResourceLocation getWildTexture();
@@ -28,8 +28,10 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface BannerPattern extends MappedEntity, CopyableEntity<BannerPattern>, DeepComparableEntity {
ResourceLocation getAssetId();
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticBannerPattern extends AbstractMappedEntity implements BannerPattern {
private final ResourceLocation assetId;
@@ -58,10 +60,9 @@ public class StaticBannerPattern extends AbstractMappedEntity implements BannerP
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticBannerPattern)) return false;
if (!super.equals(obj)) return false;
StaticBannerPattern that = (StaticBannerPattern) obj;
if (!this.assetId.equals(that.assetId)) return false;
return this.translationKey.equals(that.translationKey);
@@ -69,7 +70,7 @@ public class StaticBannerPattern extends AbstractMappedEntity implements BannerP
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.assetId, this.translationKey);
return Objects.hash(this.assetId, this.translationKey);
}
@Override
@@ -30,8 +30,8 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@@ -115,10 +115,9 @@ public class StaticEnchantmentType extends AbstractMappedEntity implements Encha
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticEnchantmentType)) return false;
if (!super.equals(obj)) return false;
StaticEnchantmentType that = (StaticEnchantmentType) obj;
if (!this.description.equals(that.description)) return false;
if (!this.definition.equals(that.definition)) return false;
@@ -128,7 +127,7 @@ public class StaticEnchantmentType extends AbstractMappedEntity implements Encha
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.description, this.definition, this.exclusiveSetRef, this.effects);
return Objects.hash(this.description, this.definition, this.exclusiveSetRef, this.effects);
}
@Override
@@ -32,7 +32,9 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
@NullMarked
public interface Instrument extends MappedEntity, CopyableEntity<Instrument>, DeepComparableEntity {
Sound getSound();
@@ -23,10 +23,12 @@ import com.github.retrooper.packetevents.protocol.sound.Sound;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticInstrument extends AbstractMappedEntity implements Instrument {
private final Sound sound;
@@ -78,10 +80,9 @@ public class StaticInstrument extends AbstractMappedEntity implements Instrument
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticInstrument)) return false;
if (!super.equals(obj)) return false;
StaticInstrument that = (StaticInstrument) obj;
if (this.useSeconds != that.useSeconds) return false;
if (Float.compare(that.range, this.range) != 0) return false;
@@ -91,6 +92,6 @@ public class StaticInstrument extends AbstractMappedEntity implements Instrument
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.sound, this.useSeconds, this.range, this.description);
return Objects.hash(this.sound, this.useSeconds, this.range, this.description);
}
}
@@ -31,7 +31,9 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
@NullMarked
public interface IJukeboxSong extends MappedEntity, CopyableEntity<IJukeboxSong>, DeepComparableEntity {
Sound getSound();
@@ -24,10 +24,12 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class JukeboxSong extends AbstractMappedEntity implements IJukeboxSong {
private Sound sound;
@@ -110,10 +112,9 @@ public class JukeboxSong extends AbstractMappedEntity implements IJukeboxSong {
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof JukeboxSong)) return false;
if (!super.equals(obj)) return false;
JukeboxSong that = (JukeboxSong) obj;
if (Float.compare(that.lengthInSeconds, this.lengthInSeconds) != 0) return false;
if (this.comparatorOutput != that.comparatorOutput) return false;
@@ -123,7 +124,7 @@ public class JukeboxSong extends AbstractMappedEntity implements IJukeboxSong {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.sound, this.description, this.lengthInSeconds, this.comparatorOutput);
return Objects.hash(this.sound, this.description, this.lengthInSeconds, this.comparatorOutput);
}
@Override
@@ -20,15 +20,18 @@ package com.github.retrooper.packetevents.protocol.item.trimmaterial;
import com.github.retrooper.packetevents.protocol.item.armormaterial.ArmorMaterial;
import com.github.retrooper.packetevents.protocol.item.type.ItemType;
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Map;
import java.util.Objects;
@NullMarked
public class StaticTrimMaterial extends AbstractMappedEntity implements TrimMaterial {
private final String assetName;
@@ -88,7 +91,7 @@ public class StaticTrimMaterial extends AbstractMappedEntity implements TrimMate
@ApiStatus.Obsolete
@Override
public ItemType getIngredient() {
return this.ingredient;
return this.ingredient != null ? this.ingredient : ItemTypes.AIR;
}
@Override
@@ -107,10 +110,9 @@ public class StaticTrimMaterial extends AbstractMappedEntity implements TrimMate
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticTrimMaterial)) return false;
if (!super.equals(obj)) return false;
StaticTrimMaterial that = (StaticTrimMaterial) obj;
if (Float.compare(that.itemModelIndex, this.itemModelIndex) != 0) return false;
if (!this.assetName.equals(that.assetName)) return false;
@@ -121,7 +123,7 @@ public class StaticTrimMaterial extends AbstractMappedEntity implements TrimMate
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.assetName, this.ingredient, this.itemModelIndex, this.overrideArmorMaterials, this.description);
return Objects.hash(this.assetName, this.ingredient, this.itemModelIndex, this.overrideArmorMaterials, this.description);
}
@Override
@@ -35,12 +35,14 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@NullMarked
public interface TrimMaterial extends MappedEntity, CopyableEntity<TrimMaterial>, DeepComparableEntity {
float FALLBACK_ITEM_MODEL_INDEX = 0f;
@@ -19,15 +19,18 @@
package com.github.retrooper.packetevents.protocol.item.trimpattern;
import com.github.retrooper.packetevents.protocol.item.type.ItemType;
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticTrimPattern extends AbstractMappedEntity implements TrimPattern {
private final ResourceLocation assetId;
@@ -69,7 +72,7 @@ public class StaticTrimPattern extends AbstractMappedEntity implements TrimPatte
@ApiStatus.Obsolete
@Override
public ItemType getTemplateItem() {
return this.templateItem;
return this.templateItem != null ? this.templateItem : ItemTypes.AIR;
}
@Override
@@ -83,10 +86,9 @@ public class StaticTrimPattern extends AbstractMappedEntity implements TrimPatte
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticTrimPattern)) return false;
if (!super.equals(obj)) return false;
StaticTrimPattern that = (StaticTrimPattern) obj;
if (this.decal != that.decal) return false;
if (!this.assetId.equals(that.assetId)) return false;
@@ -96,7 +98,7 @@ public class StaticTrimPattern extends AbstractMappedEntity implements TrimPatte
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.assetId, this.templateItem, this.description, this.decal);
return Objects.hash(this.assetId, this.templateItem, this.description, this.decal);
}
@Override
@@ -34,8 +34,10 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface TrimPattern extends MappedEntity, CopyableEntity<TrimPattern>, DeepComparableEntity {
ResourceLocation getAssetId();
@@ -62,11 +62,14 @@ public abstract class AbstractMappedEntity implements MappedEntity {
@Override
public boolean equals(Object obj) {
if (obj == null || this.getClass() != obj.getClass()) return false;
if (this == obj) return true;
if (!(obj instanceof AbstractMappedEntity)) return false;
AbstractMappedEntity that = (AbstractMappedEntity) obj;
if (this.data != null && that.data != null) {
return this.data.getName().equals(that.data.getName());
} else if (this instanceof DeepComparableEntity) {
return ((DeepComparableEntity) this).deepEquals(obj);
}
return false;
}
@@ -74,9 +77,11 @@ public abstract class AbstractMappedEntity implements MappedEntity {
@Override
public int hashCode() {
if (this.data != null) {
return Objects.hashCode(this.data.getName());
return Objects.hash(this.getClass(), this.data.getName());
} else if (this instanceof DeepComparableEntity) {
return ((DeepComparableEntity) this).deepHashCode();
}
return super.hashCode();
return System.identityHashCode(this);
}
@Override
@@ -19,8 +19,10 @@
package com.github.retrooper.packetevents.protocol.mapper;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface CopyableEntity<T extends MappedEntity> {
T copy(@Nullable TypesBuilderData newData);
@@ -18,9 +18,13 @@
package com.github.retrooper.packetevents.protocol.mapper;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface DeepComparableEntity {
boolean deepEquals(Object obj);
boolean deepEquals(@Nullable Object obj);
int deepHashCode();
}
@@ -18,6 +18,7 @@
package com.github.retrooper.packetevents.protocol.sound;
import com.github.retrooper.packetevents.protocol.mapper.DeepComparableEntity;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
import com.github.retrooper.packetevents.protocol.nbt.NBT;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
@@ -27,11 +28,11 @@ import com.github.retrooper.packetevents.protocol.util.NbtCodec;
import com.github.retrooper.packetevents.protocol.util.NbtCodecs;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface Sound extends MappedEntity {
public interface Sound extends MappedEntity, DeepComparableEntity {
NbtCodec<Sound> CODEC = new NbtCodec<Sound>() {
@Override
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticSound extends AbstractMappedEntity implements Sound {
private final ResourceLocation soundId;
@@ -53,19 +55,15 @@ public class StaticSound extends AbstractMappedEntity implements Sound {
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticSound)) return false;
public boolean deepEquals(@Nullable Object obj) {
if (obj == null || this.getClass() != obj.getClass()) return false;
StaticSound that = (StaticSound) obj;
if (this.isRegistered()) {
return super.equals(obj);
}
if (!this.soundId.equals(that.soundId)) return false;
return Objects.equals(this.range, that.range);
}
@Override
public int hashCode() {
return this.isRegistered() ? super.hashCode() : Objects.hash(this.soundId, this.range);
public int deepHashCode() {
return Objects.hash(this.soundId, this.range);
}
}
@@ -35,7 +35,7 @@ public class StaticEnvironmentAttribute<T> extends AbstractMappedEntity implemen
@ApiStatus.Internal
public StaticEnvironmentAttribute(
@org.jetbrains.annotations.Nullable TypesBuilderData data,
@Nullable TypesBuilderData data,
@Nullable AttributeType<T> attributeType, @Nullable T defaultValue
) {
super(data);
@@ -43,7 +43,7 @@ public class StaticTimeline extends AbstractMappedEntity implements Timeline {
@ApiStatus.Internal
public StaticTimeline(
@org.jetbrains.annotations.Nullable TypesBuilderData data,
@Nullable TypesBuilderData data,
@Nullable Integer periodTicks, Map<EnvironmentAttribute<?>, TimelineTrack<?, ?>> tracks
) {
super(data);
@@ -67,9 +67,8 @@ public class StaticTimeline extends AbstractMappedEntity implements Timeline {
}
@Override
public boolean deepEquals(Object obj) {
if (obj == null || getClass() != obj.getClass()) return false;
if (!super.equals(obj)) return false;
public boolean deepEquals(@Nullable Object obj) {
if (obj == null || this.getClass() != obj.getClass()) return false;
StaticTimeline that = (StaticTimeline) obj;
if (!Objects.equals(this.periodTicks, that.periodTicks)) return false;
return this.tracks.equals(that.tracks);
@@ -77,6 +76,6 @@ public class StaticTimeline extends AbstractMappedEntity implements Timeline {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.periodTicks, this.tracks);
return Objects.hash(this.periodTicks, this.tracks);
}
}
@@ -37,8 +37,8 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface Biome extends MappedEntity, CopyableEntity<Biome>, DeepComparableEntity {
@@ -22,8 +22,8 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.protocol.world.attributes.EnvironmentAttributeMap;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@@ -153,10 +153,9 @@ public class StaticBiome extends AbstractMappedEntity implements Biome {
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticBiome)) return false;
if (!super.equals(obj)) return false;
StaticBiome that = (StaticBiome) obj;
if (this.precipitation != that.precipitation) return false;
if (Float.compare(that.temperature, this.temperature) != 0) return false;
@@ -171,7 +170,7 @@ public class StaticBiome extends AbstractMappedEntity implements Biome {
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.precipitation, this.temperature, this.temperatureModifier,
return Objects.hash(this.precipitation, this.temperature, this.temperatureModifier,
this.downfall, this.category, this.depth, this.scale, this.effects, this.attributes);
}
@@ -28,13 +28,16 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTString;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Optional;
import static com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil.indexValueOrThrow;
@NullMarked
public interface DamageType extends MappedEntity, CopyableEntity<DamageType>, DeepComparableEntity {
String getMessageId();
DamageScaling getScaling();
@@ -21,10 +21,12 @@ package com.github.retrooper.packetevents.protocol.world.damagetype;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticDamageType extends AbstractMappedEntity implements DamageType {
private final String messageId;
@@ -78,10 +80,9 @@ public class StaticDamageType extends AbstractMappedEntity implements DamageType
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticDamageType)) return false;
if (!super.equals(obj)) return false;
StaticDamageType that = (StaticDamageType) obj;
if (Float.compare(that.exhaustion, this.exhaustion) != 0) return false;
if (!this.messageId.equals(that.messageId)) return false;
@@ -92,7 +93,7 @@ public class StaticDamageType extends AbstractMappedEntity implements DamageType
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.messageId, this.scaling, this.exhaustion, this.effects, this.deathMessageType);
return Objects.hash(this.messageId, this.scaling, this.exhaustion, this.effects, this.deathMessageType);
}
@Override
@@ -24,19 +24,17 @@ import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
import com.github.retrooper.packetevents.protocol.mapper.ResolvableEntity;
import com.github.retrooper.packetevents.protocol.nbt.NBT;
import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.world.attributes.EnvironmentAttributeMap;
import com.github.retrooper.packetevents.protocol.world.attributes.EnvironmentAttributes;
import com.github.retrooper.packetevents.protocol.world.attributes.timelines.Timeline;
import com.github.retrooper.packetevents.protocol.world.attributes.timelines.Timelines;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.resources.TagKey;
import com.github.retrooper.packetevents.util.mappings.IRegistry;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
import java.util.OptionalLong;
@@ -339,9 +337,8 @@ public class StaticDimensionType extends AbstractMappedEntity implements Dimensi
}
@Override
public boolean deepEquals(Object obj) {
if (obj == null || getClass() != obj.getClass()) return false;
if (!super.equals(obj)) return false;
public boolean deepEquals(@Nullable Object obj) {
if (obj == null || this.getClass() != obj.getClass()) return false;
StaticDimensionType that = (StaticDimensionType) obj;
if (this.hasFixedTime != that.hasFixedTime) return false;
if (this.natural != that.natural) return false;
@@ -367,6 +364,6 @@ public class StaticDimensionType extends AbstractMappedEntity implements Dimensi
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.hasFixedTime, this.skybox, this.cardinalLight, this.attributes, this.timelinesRef, this.fixedTime, this.natural, this.bedWorks, this.respawnAnchorWorks, this.effects, this.coordinateScale, this.minY, this.height, this.monsterSpawnLightLevel, this.monsterSpawnBlockLightLimit, this.hasSkylight, this.hasCeiling, this.logicalHeight, this.infiniburn, this.ambientLight);
return Objects.hash(this.hasFixedTime, this.skybox, this.cardinalLight, this.attributes, this.timelinesRef, this.fixedTime, this.natural, this.bedWorks, this.respawnAnchorWorks, this.effects, this.coordinateScale, this.minY, this.height, this.monsterSpawnLightLevel, this.monsterSpawnBlockLightLimit, this.hasSkylight, this.hasCeiling, this.logicalHeight, this.infiniburn, this.ambientLight);
}
}
@@ -30,8 +30,10 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public interface PaintingVariant extends MappedEntity, CopyableEntity<PaintingVariant>, DeepComparableEntity {
int getWidth();
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.util.Objects;
@NullMarked
public class StaticPaintingVariant extends AbstractMappedEntity implements PaintingVariant {
private final int width;
@@ -65,10 +67,9 @@ public class StaticPaintingVariant extends AbstractMappedEntity implements Paint
}
@Override
public boolean deepEquals(Object obj) {
public boolean deepEquals(@Nullable Object obj) {
if (this == obj) return true;
if (!(obj instanceof StaticPaintingVariant)) return false;
if (!super.equals(obj)) return false;
StaticPaintingVariant that = (StaticPaintingVariant) obj;
if (this.width != that.width) return false;
if (this.height != that.height) return false;
@@ -77,7 +78,7 @@ public class StaticPaintingVariant extends AbstractMappedEntity implements Paint
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.width, this.height, this.assetId);
return Objects.hash(this.width, this.height, this.assetId);
}
@Override
@@ -22,6 +22,8 @@ import com.github.retrooper.packetevents.protocol.attribute.Attributes;
import com.github.retrooper.packetevents.protocol.item.enchantment.type.EnchantmentTypes;
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.sound.Sounds;
import com.github.retrooper.packetevents.protocol.sound.StaticSound;
import com.github.retrooper.packetevents.protocol.world.biome.Biomes;
import com.github.retrooper.packetevents.protocol.world.dimension.DimensionType;
import com.github.retrooper.packetevents.protocol.world.dimension.DimensionTypes;
@@ -33,6 +35,7 @@ import com.github.retrooper.packetevents.protocol.world.states.enums.Orientation
import com.github.retrooper.packetevents.protocol.world.states.enums.South;
import com.github.retrooper.packetevents.protocol.world.states.enums.West;
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.test.base.BaseDummyAPITest;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jspecify.annotations.NullMarked;
@@ -40,6 +43,7 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@NullMarked
@@ -133,4 +137,17 @@ public class MappingIntegrityTest extends BaseDummyAPITest {
assertEquals("stone", StateTypes.STONE.createBlockState().toString());
assertEquals("acacia_log[axis=y]", StateTypes.ACACIA_LOG.createBlockState().toString());
}
@Test
@DisplayName("Test equality of registry values")
public void testEquality() {
// we check AbstractMappedEntity#equals works properly
// noinspection AssertBetweenInconvertibleTypes
assertNotEquals(ItemTypes.STONE, StateTypes.STONE.getMapped());
assertNotEquals(ItemTypes.STONE.hashCode(), StateTypes.STONE.getMapped().hashCode());
assertEquals(ItemTypes.STONE, ItemTypes.STONE);
assertEquals(DimensionTypes.THE_END, DimensionTypes.THE_END_PRE_1_21_9);
// check deep comparing works for static instances
assertEquals(Sounds.AMBIENT_CAVE, new StaticSound(ResourceLocation.minecraft("ambient.cave"), null));
}
}