Skip to content

Commit

Permalink
feat: introduce EffectInstance.saveNBT()
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jun 27, 2024
1 parent 4c886a9 commit 4fa2e40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.allaymc.api.entity.effect;

import org.cloudburstmc.nbt.NbtMap;

/**
* Allay Project 2023/10/27
*
Expand All @@ -20,4 +22,6 @@ public interface EffectInstance {
int getDuration();

void setDuration(int duration);

NbtMap saveNBT();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.cloudburstmc.nbt.NbtMap;

/**
* Allay Project 2023/10/27
Expand All @@ -17,4 +18,17 @@ public final class SimpleEffectInstance implements EffectInstance {
private int amplifier;
private int duration;
private boolean visible;

@Override
public NbtMap saveNBT() {
return NbtMap.builder()
.putByte("Id", (byte) type.getId())
.putByte("Amplifier", (byte) amplifier)
// TODO: DurationEasy, DurationNormal, DurationHard
.putInt("Duration", duration)
// TODO: Ambient
// TODO: DisplayOnScreenTextureAnimation
.putBoolean("ShowParticles", visible)
.build();
}
}

0 comments on commit 4fa2e40

Please sign in to comment.