@@ -465,27 +465,24 @@ public static class CompoundSession {
465465
466466 setIntM = lookup .findVirtual (nbtTag , "setInt" ,
467467 MethodType .methodType (void .class , String .class , int .class ));
468-
469468 getIntM = lookup .findVirtual (nbtTag , "getInt" ,
470469 MethodType .methodType (int .class , String .class ));
471470
472471 setShortM = lookup .findVirtual (nbtTag , "setShort" ,
473472 MethodType .methodType (void .class , String .class , short .class ));
474-
475473 getShortM = lookup .findVirtual (nbtTag , "getShort" ,
476474 MethodType .methodType (short .class , String .class ));
477475
478476 setByteM = lookup .findVirtual (nbtTag , "setByte" ,
479477 MethodType .methodType (void .class , String .class , byte .class ));
480-
481478 getByteM = lookup .findVirtual (nbtTag , "getByte" ,
482479 MethodType .methodType (byte .class , String .class ));
483480
484481 setStringM = lookup .findVirtual (nbtTag , "setString" ,
485482 MethodType .methodType (void .class , String .class , String .class ));
486483 getStringM = lookup .findVirtual (nbtTag , "getString" ,
487-
488484 MethodType .methodType (String .class , String .class ));
485+
489486 setBooleanM = lookup .findVirtual (nbtTag , "setBoolean" ,
490487 MethodType .methodType (void .class , String .class , boolean .class ));
491488 getBooleanM = lookup .findVirtual (nbtTag , "getBoolean" ,
@@ -567,6 +564,39 @@ public void remove(@Nonnull final String key) {
567564 }
568565 }
569566
567+ /**
568+ * Sets a int value in the underlying NBTTagCompound.
569+ *
570+ * @param key the key to set
571+ * @param value the int value to assign
572+ */
573+ public void setInt (@ Nonnull final String key , final int value ) {
574+ if (setInt == null ) return ;
575+
576+ try {
577+ setInt .invoke (handle , key , value );
578+ } catch (Throwable e ) {
579+ logger .logError (e , () -> "Failed to set int value from reflection" );
580+ }
581+ }
582+
583+ /**
584+ * Gets a int value from the underlying NBTTagCompound.
585+ *
586+ * @param key the key of the int value
587+ * @return the stored int value, or {@code -1} if unavailable
588+ */
589+ public int getInt (@ Nonnull final String key ) {
590+ if (getInt == null ) return -1 ;
591+
592+ try {
593+ return (int ) getInt .invoke (handle , key );
594+ } catch (Throwable e ) {
595+ logger .logError (e , () -> "Failed to retrieve int value from reflection" );
596+ }
597+ return -1 ;
598+ }
599+
570600 /**
571601 * Sets a String value in the underlying NBTTagCompound.
572602 *
@@ -666,6 +696,39 @@ public boolean getBoolean(@Nonnull final String key) {
666696 return false ;
667697 }
668698
699+ /**
700+ * Sets a short value in the underlying NBTTagCompound.
701+ *
702+ * @param key the key to set
703+ * @param value the short value to assign
704+ */
705+ public void setShort (@ Nonnull final String key , final short value ) {
706+ if (setShort == null ) return ;
707+
708+ try {
709+ setShort .invoke (handle , key , value );
710+ } catch (Throwable e ) {
711+ logger .logError (e , () -> "Failed to set short value from reflection" );
712+ }
713+ }
714+
715+ /**
716+ * Gets a short value from the underlying NBTTagCompound.
717+ *
718+ * @param key the key of the short value
719+ * @return the stored short value, or {@code -1} if unavailable
720+ */
721+ public short getShort (@ Nonnull final String key ) {
722+ if (getShort == null ) return -1 ;
723+
724+ try {
725+ return (short ) getShort .invoke (handle , key );
726+ } catch (Throwable e ) {
727+ logger .logError (e , () -> "Failed to retrieve short value from reflection" );
728+ }
729+ return -1 ;
730+ }
731+
669732 }
670733
671734 private static String getNbtTagPath () {
0 commit comments