Guardian target fix (#791)

This commit is contained in:
Bloepiloepi 2022-03-20 22:07:30 +01:00 committed by GitHub
parent 71b6e8df90
commit 81b4c3158d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ package net.minestom.server.entity.metadata.monster;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Metadata;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class GuardianMeta extends MonsterMeta {
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
@ -26,9 +27,9 @@ public class GuardianMeta extends MonsterMeta {
return this.target;
}
public void setTarget(@NotNull Entity target) {
public void setTarget(@Nullable Entity target) {
this.target = target;
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(target.getEntityId()));
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(target == null ? 0 : target.getEntityId()));
}
}