mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-03 05:51:42 +01:00
STOP_USE_ITEM not supported
This commit is contained in:
parent
838aa3019b
commit
d11fd91d4a
@ -526,7 +526,13 @@ public class EventListen implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlayerAnimation.STOP_USE_ITEM.play(player);
|
||||
if (SUPPORT_STOP_USE_ITEM) {
|
||||
try {
|
||||
PlayerAnimation.STOP_USE_ITEM.play(player);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
SUPPORT_STOP_USE_ITEM = false;
|
||||
}
|
||||
}
|
||||
if (npc.hasTrait(CommandTrait.class)) {
|
||||
npc.getTraitNullable(CommandTrait.class).dispatch(player, CommandTrait.Hand.RIGHT);
|
||||
}
|
||||
@ -764,4 +770,6 @@ public class EventListen implements Listener {
|
||||
}
|
||||
return npc.spawn(spawn, SpawnReason.CHUNK_LOAD);
|
||||
}
|
||||
|
||||
private static boolean SUPPORT_STOP_USE_ITEM = true;
|
||||
}
|
@ -121,6 +121,16 @@ public class ArmorStandTrait extends Trait {
|
||||
entity.setMarker(marker);
|
||||
}
|
||||
|
||||
public void setAsHelperEntity(NPC parent) {
|
||||
npc.addTrait(new ClickRedirectTrait(npc));
|
||||
setAsPointEntity();
|
||||
}
|
||||
|
||||
public void setAsHelperEntityWithName(NPC parent) {
|
||||
npc.addTrait(new ClickRedirectTrait(npc));
|
||||
setAsPointEntityWithName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the entity as an invisible point entity, e.g. for mounting NPCs on top, nameplates, etc.
|
||||
*/
|
||||
|
@ -86,8 +86,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));
|
||||
hologramNPC.getOrAddTrait(ArmorStandTrait.class).setAsPointEntityWithName();
|
||||
hologramNPC.getOrAddTrait(ArmorStandTrait.class).setAsHelperEntityWithName(npc);
|
||||
hologramNPC.spawn(currentLoc.clone().add(0,
|
||||
getEntityHeight()
|
||||
+ (direction == HologramDirection.BOTTOM_UP ? heightOffset : getMaxHeight() - heightOffset),
|
||||
|
@ -38,15 +38,17 @@ public class SitTrait extends Trait {
|
||||
if (!npc.isSpawned() || !sitting) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder == null) {
|
||||
NPCRegistry registry = CitizensAPI.getNamedNPCRegistry("PlayerAnimationImpl");
|
||||
if (registry == null) {
|
||||
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
|
||||
}
|
||||
holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
|
||||
holder.getOrAddTrait(ArmorStandTrait.class).setAsHelperEntity(npc);
|
||||
holder.spawn(npc.getStoredLocation());
|
||||
}
|
||||
|
||||
if (holder.getEntity() != null && !NMS.getPassengers(holder.getEntity()).contains(npc.getEntity())) {
|
||||
NMS.mount(holder.getEntity(), npc.getEntity());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user