@@ -72,23 +72,22 @@ public IMessage onMessage(RCActionButton message, MessageContext ctx) {
7272 }
7373 for (NBTBase item : list ) {
7474 if (!(item instanceof NBTTagCompound nbt ) || !nbt .hasKey ("Count" )) continue ;
75- long oldSize = nbt .getLong ("Count" );
76- long newSize = r$quantityProcessing (oldSize , action );
77- if (!r$correctQuantity (oldSize , newSize , action )) {
75+ int oldSize = nbt .getInteger ("Count" );
76+ if (!r$correctQuantity (oldSize , action )) {
7877 success = false ;
7978 break ;
8079 }
8180 if (success ) {
82- nbt .setInteger ("Count" , (int ) newSize );
81+ int newSize = r$quantityProcessing (oldSize , action );
82+ nbt .setInteger ("Count" , newSize );
8383 if (nbt .hasKey ("Cnt" )) {
84- oldSize = nbt .getLong ("Cnt" );
85- newSize = r$quantityProcessing (oldSize , action );
86- if (!r$correctQuantity (oldSize , newSize , action )) {
84+ oldSize = nbt .getInteger ("Cnt" );
85+ if (!r$correctQuantity (oldSize , action )) {
8786 success = false ;
8887 break ;
8988 }
9089 if (success )
91- nbt .setInteger ("Cnt" , ( int ) newSize );
90+ nbt .setInteger ("Cnt" , r$quantityProcessing ( oldSize , action ) );
9291 }
9392 }
9493 }
@@ -107,23 +106,23 @@ public IMessage onMessage(RCActionButton message, MessageContext ctx) {
107106 }
108107
109108 @ Unique
110- private long r$quantityProcessing (long size , Action action ) {
109+ private int r$quantityProcessing (int size , Action action ) {
111110 return switch (action ) {
112- case MULTIPLY_2 -> size << 1 ;
111+ case MULTIPLY_2 -> size * 2 ;
113112 case MULTIPLY_3 -> size * 3 ;
114- case DIVIDE_2 -> size >> 1 ;
113+ case DIVIDE_2 -> size / 2 ;
115114 case DIVIDE_3 -> size / 3 ;
116115 default -> throw new RuntimeException ("Unreasonable calls" );
117116 };
118117 }
119118
120119 @ Unique
121- private boolean r$correctQuantity (long oldSize , long newSize , Action action ) {
120+ private boolean r$correctQuantity (int oldSize , Action action ) {
122121 return switch (action ) {
123- case MULTIPLY_2 -> newSize >> 1 == oldSize && newSize <= Integer .MAX_VALUE ;
124- case MULTIPLY_3 -> newSize / 3 == oldSize && newSize <= Integer .MAX_VALUE ;
125- case DIVIDE_2 -> newSize != 0 && newSize << 1 == oldSize ;
126- case DIVIDE_3 -> newSize != 0 && newSize * 3 == oldSize ;
122+ case MULTIPLY_2 -> oldSize <= ( Integer .MAX_VALUE / 2 ) ;
123+ case MULTIPLY_3 -> oldSize <= ( Integer .MAX_VALUE / 3 ) ;
124+ case DIVIDE_2 -> oldSize % 2 == 0 ;
125+ case DIVIDE_3 -> oldSize % 3 == 0 ;
127126 default -> throw new RuntimeException ("Unreasonable calls" );
128127 };
129128 }
0 commit comments