Skip to content

Commit ec5749c

Browse files
committed
spotlessa
1 parent e6fa5f0 commit ec5749c

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/main/java/appeng/container/implementations/ContainerOptimizePatterns.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

src/main/java/appeng/core/sync/packets/PacketOptimizePatterns.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import it.unimi.dsi.fastutil.objects.Object2IntMap;
1414

1515
public 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

0 commit comments

Comments
 (0)