Skip to content

Commit 834191b

Browse files
committed
细节调整,增加自动构建
1 parent 1f50e1a commit 834191b

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build mod
2+
3+
on: [ push, pull_request, workflow_dispatch ]
4+
5+
jobs:
6+
build:
7+
name: Build mod
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up JDK 1.8
13+
uses: actions/setup-java@v2
14+
with:
15+
distribution: 'adopt'
16+
java-version: '8'
17+
- name: Grant execute permission for gradlew
18+
run: chmod +x gradlew
19+
- name: Build with Gradle
20+
run: ./gradlew -Pnet.minecraftforge.gradle.disableUpdateChecker=true build
21+
- name: Upload artifacts
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: Random Complement
25+
path: build/libs

src/main/java/com/circulation/random_complement/common/network/RCActionButton.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)