mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Change EAT_FOOD to LEAVE_BED in 1.18/17
This commit is contained in:
parent
2a5b62aae0
commit
b0f1290b58
@ -3,6 +3,7 @@ package net.citizensnpcs.trait;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
@ -120,6 +121,20 @@ public class ArmorStandTrait extends Trait {
|
||||
entity.setMarker(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the entity as an invisible point entity, e.g. for mounting NPCs on top, nameplates, etc.
|
||||
*/
|
||||
public void setAsPointEntity() {
|
||||
setGravity(false);
|
||||
setHasArms(false);
|
||||
setHasBaseplate(false);
|
||||
setSmall(true);
|
||||
setMarker(true);
|
||||
setVisible(false);
|
||||
npc.setProtected(true);
|
||||
npc.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ArmorStand#setGravity(boolean)
|
||||
*/
|
||||
|
@ -73,13 +73,7 @@ public class HologramTrait extends Trait {
|
||||
private NPC createHologram(String line, double heightOffset) {
|
||||
NPC hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line);
|
||||
hologramNPC.addTrait(new ClickRedirectTrait(npc));
|
||||
ArmorStandTrait trait = hologramNPC.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setVisible(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
hologramNPC.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
hologramNPC.spawn(currentLoc.clone().add(0,
|
||||
getEntityHeight()
|
||||
+ (direction == HologramDirection.BOTTOM_UP ? heightOffset : getMaxHeight() - heightOffset),
|
||||
|
@ -41,7 +41,7 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable
|
||||
@Persist
|
||||
private int randomLookDelay = Setting.DEFAULT_RANDOM_LOOK_DELAY.asInt();
|
||||
@Persist
|
||||
private float[] randomPitchRange = { -10, 0 };
|
||||
private float[] randomPitchRange = { 0, 0 };
|
||||
@Persist
|
||||
private float[] randomYawRange = { 0, 360 };
|
||||
private double range = Setting.DEFAULT_LOOK_CLOSE_RANGE.asDouble();
|
||||
|
@ -8,6 +8,7 @@ public enum PlayerAnimation {
|
||||
CRIT,
|
||||
EAT_FOOD,
|
||||
HURT,
|
||||
LEAVE_BED,
|
||||
MAGIC_CRIT,
|
||||
SIT,
|
||||
SLEEP,
|
||||
|
@ -42,17 +42,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
@ -42,17 +42,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
@ -42,16 +42,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
@ -42,16 +42,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
@ -42,16 +42,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
@ -42,16 +42,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
@ -42,16 +42,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_17_R1.util;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.util.EnumMap;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -23,7 +22,6 @@ import net.minecraft.network.protocol.game.ClientboundAnimatePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
|
||||
public class PlayerAnimationImpl {
|
||||
@ -42,16 +40,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
@ -78,11 +68,7 @@ public class PlayerAnimationImpl {
|
||||
}.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
|
||||
break;
|
||||
case SLEEP:
|
||||
try {
|
||||
ENTITY_SETPOSE_METHOD.invoke(player, Pose.SLEEPING);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
player.setPose(Pose.SLEEPING);
|
||||
break;
|
||||
case SNEAK:
|
||||
player.getBukkitEntity().setSneaking(true);
|
||||
@ -108,11 +94,7 @@ public class PlayerAnimationImpl {
|
||||
NMS.mount(player.getBukkitEntity(), null);
|
||||
break;
|
||||
case STOP_SLEEPING:
|
||||
try {
|
||||
ENTITY_SETPOSE_METHOD.invoke(player, Pose.STANDING);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
player.setPose(Pose.STANDING);
|
||||
break;
|
||||
case STOP_SNEAKING:
|
||||
player.getBukkitEntity().setSneaking(false);
|
||||
@ -139,12 +121,10 @@ public class PlayerAnimationImpl {
|
||||
}
|
||||
|
||||
private static EnumMap<PlayerAnimation, Integer> DEFAULTS = Maps.newEnumMap(PlayerAnimation.class);
|
||||
private static final MethodHandle ENTITY_SETPOSE_METHOD = NMS.getMethodHandle(Entity.class, "setPose", true,
|
||||
Pose.class);
|
||||
static {
|
||||
DEFAULTS.put(PlayerAnimation.ARM_SWING, 0);
|
||||
DEFAULTS.put(PlayerAnimation.HURT, 1);
|
||||
DEFAULTS.put(PlayerAnimation.EAT_FOOD, 2);
|
||||
DEFAULTS.put(PlayerAnimation.LEAVE_BED, 2);
|
||||
DEFAULTS.put(PlayerAnimation.ARM_SWING_OFFHAND, 3);
|
||||
DEFAULTS.put(PlayerAnimation.CRIT, 4);
|
||||
DEFAULTS.put(PlayerAnimation.MAGIC_CRIT, 5);
|
||||
|
@ -275,6 +275,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
// the entity is a player. there is no client so make this happen
|
||||
// manually.
|
||||
boolean damaged = super.hurt(damagesource, f);
|
||||
|
||||
if (damaged && hurtMarked) {
|
||||
hurtMarked = false;
|
||||
Bukkit.getScheduler().runTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
|
@ -40,16 +40,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
@ -132,7 +124,7 @@ public class PlayerAnimationImpl {
|
||||
static {
|
||||
DEFAULTS.put(PlayerAnimation.ARM_SWING, 0);
|
||||
DEFAULTS.put(PlayerAnimation.HURT, 1);
|
||||
DEFAULTS.put(PlayerAnimation.EAT_FOOD, 2);
|
||||
DEFAULTS.put(PlayerAnimation.LEAVE_BED, 2);
|
||||
DEFAULTS.put(PlayerAnimation.ARM_SWING_OFFHAND, 3);
|
||||
DEFAULTS.put(PlayerAnimation.CRIT, 4);
|
||||
DEFAULTS.put(PlayerAnimation.MAGIC_CRIT, 5);
|
||||
|
@ -41,16 +41,8 @@ public class PlayerAnimationImpl {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
Loading…
Reference in New Issue
Block a user