File tree Expand file tree Collapse file tree
container/implementations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,10 +97,11 @@ public void setResult(ICraftingJob result) {
9797 stack .setCountRequestableCrafts (entry .getValue ().requestedCrafts );
9898 long perCraft = entry .getValue ().getCraftAmountForItem (stack );
9999 long hash = entry .getKey ().hashCode ();
100- long multiplier =entry .getValue ().getMaxBitMultiplier ()&PacketOptimizePatterns .MULTIPLIER_BIT_MASK ;
101- // max multi is 62, that's 6 bits MAX!! + 1 bit to store sign of the hash
102- long highbits =((hash <<1 )|((hash < 0 )?1 :0 )) << PacketOptimizePatterns .MULTIPLIER_BITS ;
103- stack .setStackSize (highbits |multiplier );
100+ long multiplier = entry .getValue ().getMaxBitMultiplier ()
101+ & PacketOptimizePatterns .MULTIPLIER_BIT_MASK ;
102+ // max multi is 62, that's 6 bits MAX!! + 1 bit to store sign of the hash
103+ long highbits = ((hash << 1 ) | ((hash < 0 ) ? 1 : 0 )) << PacketOptimizePatterns .MULTIPLIER_BITS ;
104+ stack .setStackSize (highbits | multiplier );
104105 stack .setCountRequestable (perCraft );
105106 patternsUpdate .appendItem (stack );
106107 }
Original file line number Diff line number Diff line change 1313import it .unimi .dsi .fastutil .objects .Object2IntMap ;
1414
1515public class PacketOptimizePatterns extends AppEngPacket {
16- static public final int MULTIPLIER_BITS = 6 ; // multiplier <= (0b111110), take 6 bits
17- static public final long MULTIPLIER_BIT_MASK =( 1L << MULTIPLIER_BITS ) - 1 ;// low 6 bits = 1
18- static public final long HASH_SIGN_BIT_MASK = 1L << MULTIPLIER_BITS ;// 7th bit = 1
19-
20-
16+
17+ static public final int MULTIPLIER_BITS = 6 ;// multiplier <= (0b111110), take 6 bits
18+ static public final long MULTIPLIER_BIT_MASK = ( 1L << MULTIPLIER_BITS ) - 1 ;// low 6 bits = 1
19+ static public final long HASH_SIGN_BIT_MASK = 1L << MULTIPLIER_BITS ; // 7th bit = 1
20+
2121 HashMap <Integer , Integer > hashCodeToMultiplier = new HashMap <>();
2222
2323 // automatic
@@ -37,7 +37,7 @@ public PacketOptimizePatterns(Object2IntMap<IAEStack<?>> multipliersMap) {
3737 data .writeInt (multipliersMap .size ());
3838 for (var entry : multipliersMap .object2IntEntrySet ()) {
3939 long encoded = entry .getKey ().getStackSize ();
40- data .writeInt ((int ) (encoded >> (MULTIPLIER_BITS + 1 )) * ((encoded & HASH_SIGN_BIT_MASK ) == 0 ? 1 : -1 ));
40+ data .writeInt ((int ) (encoded >> (MULTIPLIER_BITS + 1 )) * ((encoded & HASH_SIGN_BIT_MASK ) == 0 ? 1 : -1 ));
4141 data .writeInt (entry .getIntValue ());
4242 }
4343
You can’t perform that action at this time.
0 commit comments