make FishingHookMeta implement ObjectDataProvider

This commit is contained in:
KrystilizeNevaDies 2021-04-06 04:39:47 +10:00
parent 88765dd703
commit b1cfa3d9b2

View File

@ -1,14 +1,17 @@
package net.minestom.server.entity.metadata.other; package net.minestom.server.entity.metadata.other;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Metadata; import net.minestom.server.entity.Metadata;
import net.minestom.server.entity.metadata.EntityMeta; import net.minestom.server.entity.metadata.EntityMeta;
import org.jetbrains.annotations.NotNull; import net.minestom.server.entity.metadata.ObjectDataProvider;
import org.jetbrains.annotations.Nullable;
public class FishingHookMeta extends EntityMeta { public class FishingHookMeta extends EntityMeta implements ObjectDataProvider {
private Entity hooked; private Entity hooked;
private Entity owner;
public FishingHookMeta(@NotNull Entity entity, @NotNull Metadata metadata) { public FishingHookMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
super(entity, metadata); super(entity, metadata);
@ -24,6 +27,14 @@ public class FishingHookMeta extends EntityMeta {
int entityID = value == null ? 0 : value.getEntityId() + 1; int entityID = value == null ? 0 : value.getEntityId() + 1;
super.metadata.setIndex((byte) 7, Metadata.VarInt(entityID)); super.metadata.setIndex((byte) 7, Metadata.VarInt(entityID));
} }
@Nullable
public Entity getOwnerEntity() {
return owner;
}
public void setOwnerEntity(@Nullable Entity value) {
this.owner = value;
}
public boolean isCatchable() { public boolean isCatchable() {
return super.metadata.getIndex((byte) 8, false); return super.metadata.getIndex((byte) 8, false);
@ -33,4 +44,13 @@ public class FishingHookMeta extends EntityMeta {
super.metadata.setIndex((byte) 8, Metadata.Boolean(value)); super.metadata.setIndex((byte) 8, Metadata.Boolean(value));
} }
@Override
public int getObjectData() {
return owner.getEntityId();
}
@Override
public boolean requiresVelocityPacketAtSpawn() {
return false;
}
} }