some more methods for entities
This commit is contained in:
parent
24b2a96d11
commit
a6070ef5cc
2 changed files with 61 additions and 0 deletions
|
@ -11,6 +11,7 @@ import me.tofaa.entitylib.TrackedEntity;
|
|||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||
import me.tofaa.entitylib.tick.Tickable;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -158,6 +159,14 @@ public class WrapperEntity implements Tickable, TrackedEntity {
|
|||
}
|
||||
}
|
||||
|
||||
public void sendMessageToViewers(Component message) {
|
||||
sendPacketToViewers(new WrapperPlayServerSystemChatMessage(false, message));
|
||||
}
|
||||
|
||||
public void sendActionbarToViewers(Component message) {
|
||||
sendPacketToViewers(new WrapperPlayServerSystemChatMessage(true, message));
|
||||
}
|
||||
|
||||
protected WrapperPlayServerSpawnEntity createSpawnPacket() {
|
||||
return new WrapperPlayServerSpawnEntity(
|
||||
entityId,
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package me.tofaa.entitylib.wrapper;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.HumanoidArm;
|
||||
import com.github.retrooper.packetevents.protocol.potion.PotionType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityAnimation;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityEffect;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.types.LivingEntityMeta;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -23,6 +27,54 @@ public class WrapperLivingEntity extends WrapperEntity{
|
|||
equipment.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a potion effect to the entity.
|
||||
* EntityLib will not keep track of the potions you give or what you do with them,
|
||||
* this simply sends the packet to the viewers of the entity.
|
||||
* @param type The type of the potion effect {@link com.github.retrooper.packetevents.protocol.potion.PotionTypes}
|
||||
* @param amplifier The amplifier of the potion effect. The notchian client displays the number as (amplifier + 1)
|
||||
* @param duration The duration of the potion effect in ticks, if set to -1 the client will display the effect as infinite
|
||||
* @param flags The bit flags of the potion effect see: https://wiki.vg/Protocol#Entity_Effect
|
||||
* @param hasFactorData Whether the potion effect has factor data
|
||||
* @param factorData The factor data of the potion effect, if hasFactorData is false this will be ignored
|
||||
*/
|
||||
public void addPotionEffect(
|
||||
PotionType type,
|
||||
int amplifier,
|
||||
int duration,
|
||||
byte flags,
|
||||
boolean hasFactorData,
|
||||
@Nullable NBTCompound factorData
|
||||
) {
|
||||
sendPacketToViewers(
|
||||
new WrapperPlayServerEntityEffect(
|
||||
getEntityId(),
|
||||
type,
|
||||
amplifier,
|
||||
duration,
|
||||
flags
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a potion effect to the entity.
|
||||
* EntityLib will not keep track of the potions you give or what you do with them,
|
||||
* this simply sends the packet to the viewers of the entity.
|
||||
* @param type The type of the potion effect {@link com.github.retrooper.packetevents.protocol.potion.PotionTypes}
|
||||
* @param amplifier The amplifier of the potion effect. The notchian client displays the number as (amplifier + 1)
|
||||
* @param duration The duration of the potion effect in ticks, if set to -1 the client will display the effect as infinite
|
||||
* @param flags The bit flags of the potion effect see: https://wiki.vg/Protocol#Entity_Effect
|
||||
*/
|
||||
public void addPotionEffect(
|
||||
PotionType type,
|
||||
int amplifier,
|
||||
int duration,
|
||||
byte flags
|
||||
) {
|
||||
addPotionEffect(type, amplifier, duration, flags, false, null);
|
||||
}
|
||||
|
||||
public void playCriticalHitAnimation() {
|
||||
sendAnimation(WrapperPlayServerEntityAnimation.EntityAnimationType.CRITICAL_HIT);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue