Skip to content

Commit caff2dc

Browse files
author
passplease
committed
Test AE and fix bug
1 parent a72ce67 commit caff2dc

26 files changed

+234
-76
lines changed

.github/workflows/publish.yml

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build
22

33
on:
44
workflow_dispatch:
5+
pull_request:
56
push:
67
branches:
78
- 1.20.1-6.0.0-forge
@@ -33,28 +34,62 @@ jobs:
3334
with:
3435
gradle-version: '8.11.1'
3536

36-
- name: Test Server
37-
run: gradle runGameTestServer
38-
continue-on-error: true
39-
4037
- name: Build with Gradle
4138
run: gradle build
4239

4340
- name: Create timestamp
4441
id: create_timestamp
45-
run: echo "timestamp=$(date '+%Y-%m-%d-%H')" >> $GITHUB_OUTPUT
42+
run: echo "timestamp=$(date '+%Y-%m-%d')" >> $GITHUB_OUTPUT
4643
shell: bash
4744

4845
- uses: Kir-Antipov/mc-publish@v3.3
4946
with:
5047
github-token: ${{ secrets.GITHUB_TOKEN }}
5148
github-tag: 1.20.1-6.0.0-Forge_NeoForge-${{ steps.create_timestamp.outputs.timestamp }}
5249
github-draft: false
53-
github-prerelease: false
50+
github-prerelease: true
51+
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: Build Artifact
55+
include-hidden-files: true
56+
path: |
57+
**/logs/
58+
**/crash-reports/
59+
build/libs
60+
retention-days: 1
61+
if: always()
62+
GameTest:
63+
strategy:
64+
max-parallel: 2
65+
fail-fast: false
66+
matrix:
67+
GameTestConfig: [ default, testAE ]
68+
permissions:
69+
contents: write
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Checkout repository
73+
uses: actions/checkout@v4
74+
75+
- name: Setup JDK 21
76+
uses: actions/setup-java@v4
77+
with:
78+
java-version: '21'
79+
distribution: 'temurin'
80+
81+
- name: Setup Gradle
82+
uses: gradle/actions/setup-gradle@v4
83+
with:
84+
gradle-version: '8.11.1'
85+
86+
- name: Test Server with ${{ matrix.GameTestConfig }}
87+
run: gradle runGameTestServer -PGameTestConfig=${{ matrix.GameTestConfig }}
88+
continue-on-error: true
5489

5590
- uses: actions/upload-artifact@v4
5691
with:
57-
overwrite: true
92+
name: Test Artifact of ${{ matrix.GameTestConfig }}
5893
include-hidden-files: true
5994
path: |
6095
**/logs/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you want to download code on your computer, please change gradle version in `
1414
* For Chinese, you can also find more links in [MCMODS](https://www.mcmod.cn/class/15306.html)
1515
## About Plans
1616
- [x] Support 1.21.1
17-
- [ ] Transplant all stuff to 1.20.1 and 1.21.1
17+
- [x] Transplant all stuff to 1.20.1 and 1.21.1
1818
## License
1919
[MIT_License](https://mit-license.org/)
2020
## Thanks

build.gradle

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ java {
2828
}
2929

3030
boolean ponderInWorkspace = rootProject.hasProperty('multiModWorkspace.ponder')
31+
def GameTestConfig = project.properties.get('GameTestConfig','default')
3132

3233
legacyForge {
3334
version = "$minecraft_version-$forge_version"
@@ -75,7 +76,9 @@ legacyForge {
7576
gameTestServer {
7677
type = "gameTestServer"
7778

78-
gameDirectory = project.file('run/gametest')
79+
if(GameTestConfig != 'default')
80+
gameDirectory = project.file("run/gametest/${GameTestConfig}")
81+
else gameDirectory = project.file('run/gametest')
7982
}
8083

8184
data {
@@ -178,6 +181,23 @@ tasks.named('jar', Jar).configure {
178181
finalizedBy 'reobfJar'
179182
}
180183

184+
tasks.register("prepareGameTestConfigs", Copy) {
185+
group = 'mod development'
186+
description = "Copy config files for GameTestServer"
187+
if(GameTestConfig != 'default') {
188+
def configFiles = project.file(GameTestConfigDir)
189+
if (!configFiles.exists() || !configFiles.isDirectory()) {
190+
throw new GradleException("config set directory '${configFiles}' does not exist for GameTestServer. ")
191+
}
192+
from fileTree("${configFiles}/${GameTestConfig}")
193+
into runGameTestServer.gameDirectory.file('config')
194+
}
195+
}
196+
197+
tasks.named('runGameTestServer', JavaExec){
198+
dependsOn prepareGameTestConfigs
199+
}
200+
181201
tasks.withType(JavaCompile).configureEach {
182202
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
183203
}

gradle.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mod_name=SmarterContraptionStorage
4343
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
4444
mod_license=MIT_License
4545
# The mod version. See https://semver.org/
46-
mod_version=1.20.1-6.0.0-beta-1.4.3
46+
mod_version=1.20.1-6.0.0-1.4.3
4747
# The group ID for the mod. It is only important when publishing as an artifact to Excludes.BuildNBTFile Maven repository.
4848
# This should match the base package used for the mod sources.
4949
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
@@ -55,4 +55,5 @@ mod_description=A mod to make Contraption's storage smarter
5555
registrate_version=MC1.20-1.3.3
5656
flywheel_version=0.6.10-7
5757
ponder_version=1.0.52
58-
ATFile=src/main/resources/META-INF/accesstransformer.cfg
58+
ATFile=src/main/resources/META-INF/accesstransformer.cfg
59+
GameTestConfigDir=src/test/resources/GameTest/Config

src/main/java/net/smartercontraptionstorage/AddStorage/ItemHandler/AE2BusBlockHelper.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import appeng.blockentity.misc.InterfaceBlockEntity;
1515
import appeng.blockentity.networking.*;
1616
import appeng.blockentity.spatial.SpatialIOPortBlockEntity;
17+
import appeng.core.definitions.AEBlocks;
1718
import appeng.core.definitions.AEItems;
1819
import appeng.items.tools.powered.WirelessCraftingTerminalItem;
1920
import appeng.me.GridNode;
@@ -35,6 +36,7 @@
3536
import org.jetbrains.annotations.Nullable;
3637

3738
import java.util.ArrayList;
39+
import java.util.function.Consumer;
3840

3941
public class AE2BusBlockHelper extends StorageHandlerHelper{
4042
@Override
@@ -50,7 +52,7 @@ public void addStorageToWorld(BlockEntity entity, ItemStackHandler handler) {}
5052
assert this.canCreateHandler(entity);
5153

5254
CableBusBlockEntity bus = (CableBusBlockEntity)entity;
53-
ICablePart center = (ICablePart)bus.getPart((Direction)null);
55+
ICablePart center = (ICablePart)bus.getPart(null);
5456
if (center != null && center.getCableConnectionType() == AECableType.COVERED) {
5557
IGridNode exportHost = null;
5658
IGridNode importHost = null;
@@ -66,7 +68,7 @@ public void addStorageToWorld(BlockEntity entity, ItemStackHandler handler) {}
6668
if (key != null) {
6769
ItemStack item = key.wrapForDisplayOrFilter();
6870
if (item.getItem() instanceof WirelessCraftingTerminalItem terminal) {
69-
if (!checkUpgrade(terminal.getUpgrades(item), AEItems.ENERGY_CARD.asItem(),3)) {
71+
if (!checkUpgrade(terminal.getUpgrades(item), AEItems.ENERGY_CARD.asItem())) {
7072
continue;
7173
}
7274

@@ -134,6 +136,11 @@ public boolean allowControl(Block block) {
134136
return false;
135137
}
136138

139+
@Override
140+
public void registerBlock(Consumer<Block> register) {
141+
register.accept(AEBlocks.CABLE_BUS.block());
142+
}
143+
137144
@Override
138145
public String getName() {
139146
return "AE2BusBlockHelper";
@@ -238,7 +245,7 @@ public boolean useEnergy(boolean extractOrImport,boolean simulate){
238245

239246
@Override
240247
public @NotNull ItemStack extractItem(int slot, int amount, boolean simulate) {
241-
if(canWork(true,simulate)) {
248+
if(canWork(true,simulate) && slot < extractKeys.size()) {
242249
MEStorage extractStorage = getStorage(true);
243250
if (extractStorage == null)
244251
return ItemStack.EMPTY;
@@ -276,7 +283,7 @@ public void refreshStack(@Nullable MEStorage extractStorage){// synchronize stor
276283
@Override
277284
public int getSlots() {
278285
refreshStack(getStorage(true));
279-
return extractKeys.size();
286+
return Math.max(extractKeys.size(),1);
280287
}
281288

282289
@Override
@@ -289,11 +296,7 @@ public void finallyDo() {
289296
boolean controller = false,energy = false;
290297
for(BlockEntity entity : StorageHandlerHelper.BlockEntityList) {
291298
if (entity instanceof InterfaceBlockEntity MEInterface) {
292-
IGridNode node = MEInterface.getInterfaceLogic().getActionableNode();
293-
if (node == null)
294-
continue;
295-
MEStorage storage = node.getGrid().getStorageService().getInventory();
296-
extractKeys.addAll(storage.getAvailableStacks().keySet());
299+
extractKeys.addAll(MEInterface.getInterfaceLogic().getConfig().getAvailableStacks().keySet());
297300
} else if (controller || entity instanceof ControllerBlockEntity)
298301
controller = true;
299302
else if(energy || entity instanceof EnergyCellBlockEntity || entity instanceof CreativeEnergyCellBlockEntity)

src/main/java/net/smartercontraptionstorage/AddStorage/ItemHandler/CobblestoneGenerator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import net.minecraftforge.lex.cfd.CobbleGenTile;
1212
import org.jetbrains.annotations.NotNull;
1313

14+
import java.util.function.Consumer;
15+
1416
public class CobblestoneGenerator extends StorageHandlerHelper{
1517
public static final ItemStackHandler cobblestoneGenerator = new ItemStackHandler(){
1618
@Override
@@ -50,6 +52,11 @@ public boolean allowControl(Block block) {
5052
return block == CobbleForDays.TIER5_BLOCK.get();
5153
}
5254

55+
@Override
56+
public void registerBlock(Consumer<Block> register) {
57+
register.accept(CobbleForDays.TIER5_BLOCK.get());
58+
}
59+
5360
@Override
5461
public String getName() {
5562
return "CobblestoneGenerator";

src/main/java/net/smartercontraptionstorage/AddStorage/ItemHandler/CompactingHandlerHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.jetbrains.annotations.NotNull;
2626

2727
import java.util.Objects;
28+
import java.util.function.Consumer;
2829

2930
public class CompactingHandlerHelper extends DrawersHandlerHelper{
3031
@Override
@@ -51,6 +52,8 @@ public boolean allowControl(Block block) {
5152
return block instanceof BlockCompDrawers;
5253
}
5354
@Override
55+
public void registerBlock(Consumer<Block> register) {}
56+
@Override
5457
public String getName() {
5558
return "CompactingHandlerHelper";
5659
}

src/main/java/net/smartercontraptionstorage/AddStorage/ItemHandler/DrawersHandlerHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.jaquadro.minecraft.storagedrawers.block.tile.BlockEntityDrawers;
77
import com.jaquadro.minecraft.storagedrawers.block.tile.BlockEntityDrawersStandard;
88
import com.jaquadro.minecraft.storagedrawers.block.tile.tiledata.UpgradeData;
9+
import com.jaquadro.minecraft.storagedrawers.core.ModBlocks;
910
import net.createmod.catnip.nbt.NBTHelper;
1011
import net.minecraft.nbt.CompoundTag;
1112
import net.minecraft.nbt.IntTag;
@@ -30,6 +31,7 @@
3031
import java.util.Arrays;
3132
import java.util.List;
3233
import java.util.Objects;
34+
import java.util.function.Consumer;
3335

3436
public class DrawersHandlerHelper extends StorageHandlerHelper {
3537
public static final String NAME = "DrawersHandlerHelper";
@@ -71,6 +73,10 @@ public boolean allowControl(Block block){
7173
return block instanceof BlockDrawers && !(block instanceof BlockCompDrawers);
7274
}
7375
@Override
76+
public void registerBlock(Consumer<Block> register) {
77+
ModBlocks.getDrawers().forEach(register);
78+
}
79+
@Override
7480
public String getName() {
7581
return NAME;
7682
}

src/main/java/net/smartercontraptionstorage/AddStorage/ItemHandler/FunctionalCompactingHandlerHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.ArrayList;
3030
import java.util.List;
3131
import java.util.Objects;
32+
import java.util.function.Consumer;
3233

3334
import static com.buuz135.functionalstorage.inventory.CompactingInventoryHandler.*;
3435

@@ -85,6 +86,9 @@ public boolean allowControl(Block block) {
8586
return block instanceof CompactingDrawerBlock || block instanceof SimpleCompactingDrawerBlock;
8687
}
8788

89+
@Override
90+
public void registerBlock(Consumer<Block> register) {}
91+
8892
@Override
8993
public String getName() {
9094
return NAME;

src/main/java/net/smartercontraptionstorage/AddStorage/ItemHandler/FunctionalDrawersHandlerHelper.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.smartercontraptionstorage.AddStorage.ItemHandler;
22

3+
import com.buuz135.functionalstorage.FunctionalStorage;
34
import com.buuz135.functionalstorage.block.DrawerBlock;
45
import com.buuz135.functionalstorage.block.tile.DrawerTile;
56
import com.buuz135.functionalstorage.inventory.BigInventoryHandler;
@@ -30,6 +31,7 @@
3031
import java.util.ArrayList;
3132
import java.util.List;
3233
import java.util.Objects;
34+
import java.util.function.Consumer;
3335

3436
import static com.buuz135.functionalstorage.inventory.BigInventoryHandler.*;
3537

@@ -78,6 +80,15 @@ public boolean allowControl(Block block) {
7880
return block instanceof DrawerBlock;
7981
}
8082

83+
@Override
84+
public void registerBlock(Consumer<Block> register) {
85+
FunctionalStorage.DRAWER_TYPES.forEach((type,list) -> {
86+
list.forEach(drawer -> {
87+
register.accept(drawer.getLeft().get());
88+
});
89+
});
90+
}
91+
8192
@Override
8293
public String getName() {
8394
return NAME;

0 commit comments

Comments
 (0)