-
-
Notifications
You must be signed in to change notification settings - Fork 3
Instrument Open NBT (Capability)
StavWasPlayZ edited this page Jul 10, 2023
·
1 revision
This mod stores inside of the player's NBT whether their instrument's screen is open in the form of a boolean byte. It is located under instrument_caps.instrumentOpen
.
When the arm pose of a player holding an instrument is evaluated, it is first checked whether if the instrument is actually active - thus, if the screen is open. It is done like so (source):
@Override
public @Nullable ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack itemStack) {
if (!(entityLiving instanceof Player))
return null;
final Player player = (Player)entityLiving;
// Check if the instrument is actually open
final LazyOptional<InstrumentOpen> lazyOpen = player.getCapability(InstrumentOpenProvider.INSTRUMENT_OPEN);
if (!lazyOpen.isPresent() || !lazyOpen.resolve().get().isOpen())
return null;
return PLAYING_INSTRUMENT;
}