Skip to content

Commit

Permalink
Using powah for the energy detector test to prevent a crashing NPE wi…
Browse files Browse the repository at this point in the history
…th mekanism

Fixed the me transfer test
  • Loading branch information
SirEndii committed Sep 10, 2024
1 parent 2b9d612 commit 099279e
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.logging.level=info
# Minecraft related
mod_id=advancedperipherals
minecraft_version=1.19.2
forge_version=43.4.0
forge_version=43.4.2
loader_version=43
mod_version=0.8r
release_type=release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public final MethodResult importItem(IComputerAccess computer, IArguments argume
String side = arguments.getString(1);
IItemHandler inventory;

if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) {
if (Direction.byName(side) != null || ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) != null) {
inventory = InventoryUtil.getHandlerFromDirection(arguments.getString(1), owner);
} else {
inventory = InventoryUtil.getHandlerFromName(computer, arguments.getString(1));
Expand All @@ -280,7 +280,7 @@ public final MethodResult exportItem(IComputerAccess computer, @NotNull IArgumen
String side = arguments.getString(1);
IItemHandler inventory;

if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) {
if (Direction.byName(side) != null || ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) != null) {
inventory = InventoryUtil.getHandlerFromDirection(arguments.getString(1), owner);
} else {
inventory = InventoryUtil.getHandlerFromName(computer, arguments.getString(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ class PeripheralTest {

// The ME System needs to boot up, so we use a sleep() in the specific lua script
// We set the timeoutTicks to 300 so the test does not fail
@GameTest(timeoutTicks = 300)
@GameTest(timeoutTicks = 600)
fun meCrafting(context: GameTestHelper) = context.sequence {
thenComputerOk();
}

@GameTest(timeoutTicks = 300)
@GameTest(timeoutTicks = 600)
fun meStorage(context: GameTestHelper) = context.sequence {
thenComputerOk();
}

@GameTest(timeoutTicks = 300)
@GameTest(timeoutTicks = 600)
fun meTransfer(context: GameTestHelper) = context.sequence {
thenComputerOk();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sleep(0.5)
test.eq(100, det.getTransferRate(), "Transfer Rate should be 100")
test.eq(100, det.getTransferRateLimit(), "Transfer Rate Limit should be 100")

det.setTransferRateLimit(100000)
det.setTransferRateLimit(4000000)
sleep(0.5)
test.eq(3200, det.getTransferRate(), "Transfer Rate should be 3200") -- Rate limit from the cables
test.eq(100000, det.getTransferRateLimit(), "Transfer Rate Limit should be 100000")
test.eq(100000, det.getTransferRate(), "Transfer Rate should be 100000") -- Rate limit from the cables
test.eq(4000000, det.getTransferRateLimit(), "Transfer Rate Limit should be 4000000")
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ stickCount = bridge.getItem(stickFilter).amount
test.assert(stickCount == 8, "We should have 8 sticks")

-- There is no getFluid function, so we need to do it like this
waterCount = bridge.listCraftableFluid()[1].amount
waterCount = bridge.listCraftableFluids()[1].amount
test.assert(waterCount == 0, "We should not have water")

craftingSuccessful = bridge.craftFluid(waterFilter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---

sleep(4)
bridge = peripheral.wrap("me_bridge_3")
bridge = peripheral.wrap("me_bridge_20")
chest = peripheral.wrap("minecraft:chest_2")
test.assert(bridge, "Peripheral not found")
test.assert(chest, "Chest not found")
Expand All @@ -19,8 +19,8 @@ test.assert(energyUsage > 17, tostring(energyUsage) .. " Consumption does not se
planksFilter = {name="minecraft:oak_planks", count=5}
logFilter = {name="minecraft:oak_log", count=8}

exported, err = bridge.exportItemToPeripheral(planksFilter, peripheral.getName(chest))
test.assert(exported == 5, "Export failed ".. (err or ""))
exported, err = bridge.exportItem(planksFilter, peripheral.getName(chest))
test.assert(exported == 5, "Export failed 5 planks to chest ".. (err or ""))

planksItem = bridge.getItem(planksFilter)
test.assert(planksItem.amount == 251, "We should have 251 planks")
Expand All @@ -36,7 +36,7 @@ test.assert(chestPlanks, "Planks not found in chest")
test.assert(chestPlanks.count == 5, "We should have 5 planks in the chest")

exported, err = bridge.exportItem(planksFilter, "front")
test.assert(exported == 5, "Export failed ".. (err or ""))
test.assert(exported == 5, "Export failed 5 planks to front:".. (err or ""))

planksItem = bridge.getItem(planksFilter)
test.assert(planksItem.amount == 246, "We should have 246 planks")
Expand All @@ -50,8 +50,8 @@ end
test.assert(chestPlanks, "Planks not found in chest")
test.assert(chestPlanks.count == 10, "We should have 5 planks in the chest")

imported, err = bridge.importItemFromPeripheral(logFilter, peripheral.getName(chest))
test.assert(imported == 8, "import failed ".. (err or ""))
imported, err = bridge.importItem(logFilter, peripheral.getName(chest))
test.assert(imported == 8, "import failed 8 logs to chest".. (err or ""))

logsItem = bridge.getItem(logFilter)
test.assert(logsItem.amount == 264, "We should have 264 logs")
Expand All @@ -67,7 +67,7 @@ test.assert(chestLogs, "Logs not found in chest")
test.assert(chestLogs.count == 56, "We should have 56 logs in the chest")

imported, err = bridge.importItem(logFilter, "south")
test.assert(imported == 8, "import failed ".. (err or ""))
test.assert(imported == 8, "import failed 8 logs from south".. (err or ""))

logsItem = bridge.getItem(logFilter)
test.assert(logsItem.amount == 272, "We should have 272 logs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@
{pos: [0, 1, 2], state: "minecraft:air"},
{pos: [0, 1, 3], state: "minecraft:air"},
{pos: [0, 1, 4], state: "minecraft:air"},
{pos: [1, 1, 0], state: "mekanism:creative_energy_cube{facing:north,fluid_logged:empty}", nbt: {EnergyContainers: [], ForgeCaps: {}, Items: [], componentConfig: {config0: {side0: 1, side1: 1, side2: 1, side3: 1, side4: 1, side5: 1}, config6: {side0: 4, side1: 1, side2: 1, side3: 1, side4: 1, side5: 1}, eject0: 1b, eject6: 0b}, componentEjector: {color0: -1, color1: -1, color2: -1, color3: -1, color4: -1, color5: -1, strictInput: 0b}, componentFrequency: {Security: {name: "Security", owner: [I; 940439953, -167562164, -1601161573, -1389718966], publicFreq: 1b}}, componentSecurity: {owner: [I; 940439953, -167562164, -1601161573, -1389718966], securityMode: 0}, controlType: 0, currentRedstone: 0, id: "mekanism:creative_energy_cube", redstone: 0b}},
{pos: [1, 1, 1], state: "mekanism:basic_universal_cable{fluid_logged:empty}", nbt: {ForgeCaps: {}, connection0: 0, connection1: 0, connection2: 0, connection3: 0, connection4: 0, connection5: 0, id: "mekanism:basic_universal_cable", redstone: 0b}},
{pos: [1, 1, 2], state: "advancedperipherals:energy_detector{orientation:south_up}", nbt: {ForgeCaps: {}, ForgeData: {CustomName: "[Energy Detector]"}, Items: [], id: "advancedperipherals:energy_detector", rateLimit: 0}},
{pos: [1, 1, 3], state: "mekanism:basic_universal_cable{fluid_logged:empty}", nbt: {ForgeCaps: {}, connection0: 0, connection1: 0, connection2: 0, connection3: 0, connection4: 0, connection5: 0, energy: "8000", id: "mekanism:basic_universal_cable", redstone: 0b}},
{pos: [1, 1, 4], state: "mekanism:creative_energy_cube{facing:west,fluid_logged:empty}", nbt: {EnergyContainers: [{Container: 0b, stored: "18446744073709551615.9999"}], ForgeCaps: {}, Items: [], componentConfig: {config0: {side0: 4, side1: 4, side2: 4, side3: 4, side4: 4, side5: 4}, config6: {side0: 4, side1: 1, side2: 1, side3: 1, side4: 1, side5: 1}, eject0: 1b, eject6: 0b}, componentEjector: {color0: -1, color1: -1, color2: -1, color3: -1, color4: -1, color5: -1, strictInput: 0b}, componentFrequency: {Security: {name: "Security", owner: [I; 940439953, -167562164, -1601161573, -1389718966], publicFreq: 1b}}, componentSecurity: {owner: [I; 940439953, -167562164, -1601161573, -1389718966], securityMode: 0}, controlType: 0, currentRedstone: 15, id: "mekanism:creative_energy_cube", redstone: 0b}},
{pos: [1, 1, 0], state: "powah:energy_cell_niotic{waterlogged:false}", nbt: {ForgeCaps: {}, Items: [], Size: 2, energy_stored_main_energy: 16400L, id: "powah:energy_cell", redstone_mode: 0, side_transfer_type: [I; 0, 0, 0, 0, 0, 0], variant: 4}},
{pos: [1, 1, 1], state: "powah:energy_cable_nitro{down:false,east:false,north:false,south:false,up:false,waterlogged:false,west:false}", nbt: {ForgeCaps: {}, cs: 12b, energy_capacity_main_energy: 0L, energy_stored_main_energy: 0L, id: "powah:energy_cable", redstone_mode: 0, side_transfer_type: [I; 0, 0, 1, 2, 0, 0], variant: 6}},
{pos: [1, 1, 2], state: "advancedperipherals:energy_detector{orientation:south_up}", nbt: {ForgeCaps: {}, ForgeData: {CustomName: "[Energy Detector]"}, Items: [], id: "advancedperipherals:energy_detector", rateLimit: 100}},
{pos: [1, 1, 3], state: "powah:energy_cable_nitro{down:false,east:false,north:false,south:false,up:false,waterlogged:false,west:false}", nbt: {ForgeCaps: {}, cs: 12b, energy_capacity_main_energy: 0L, energy_stored_main_energy: 0L, id: "powah:energy_cable", redstone_mode: 0, side_transfer_type: [I; 0, 0, 1, 2, 0, 0], variant: 6}},
{pos: [1, 1, 4], state: "powah:energy_cell_creative{waterlogged:false}", nbt: {ForgeCaps: {}, Items: [], Size: 2, energy_capacity_main_energy: 9000000000000000000L, energy_stored_main_energy: 9000000000000000000L, id: "powah:energy_cell", redstone_mode: 0, side_transfer_type: [I; 1, 1, 1, 1, 1, 1], variant: 7}},
{pos: [2, 1, 0], state: "minecraft:air"},
{pos: [2, 1, 1], state: "minecraft:air"},
{pos: [2, 1, 2], state: "computercraft:computer_advanced{facing:north,state:blinking}", nbt: {ComputerId: 0, ForgeCaps: {}, Label: "peripheraltest.energydet", On: 1b, id: "computercraft:computer_advanced"}},
{pos: [2, 1, 3], state: "minecraft:air"},
{pos: [2, 1, 4], state: "minecraft:air"},
{pos: [3, 1, 0], state: "mekanism:creative_energy_cube{facing:east,fluid_logged:empty}", nbt: {EnergyContainers: [{Container: 0b, stored: "18446744073709551615.9999"}], ForgeCaps: {}, Items: [], componentConfig: {config0: {side0: 4, side1: 4, side2: 4, side3: 4, side4: 4, side5: 4}, config6: {side0: 4, side1: 1, side2: 1, side3: 1, side4: 1, side5: 1}, eject0: 1b, eject6: 0b}, componentEjector: {color0: -1, color1: -1, color2: -1, color3: -1, color4: -1, color5: -1, strictInput: 0b}, componentFrequency: {Security: {name: "Security", owner: [I; 940439953, -167562164, -1601161573, -1389718966], publicFreq: 1b}}, componentSecurity: {owner: [I; 940439953, -167562164, -1601161573, -1389718966], securityMode: 0}, controlType: 0, currentRedstone: 15, id: "mekanism:creative_energy_cube", redstone: 0b}},
{pos: [3, 1, 1], state: "mekanism:basic_universal_cable{fluid_logged:empty}", nbt: {ForgeCaps: {}, connection0: 0, connection1: 0, connection2: 0, connection3: 0, connection4: 0, connection5: 0, energy: "8000", id: "mekanism:basic_universal_cable", redstone: 0b}},
{pos: [3, 1, 2], state: "advancedperipherals:energy_detector{orientation:north_up}", nbt: {ForgeCaps: {}, ForgeData: {CustomName: "[Energy Detector]"}, Items: [], id: "advancedperipherals:energy_detector", rateLimit: 0}},
{pos: [3, 1, 3], state: "mekanism:basic_universal_cable{fluid_logged:empty}", nbt: {ForgeCaps: {}, connection0: 0, connection1: 0, connection2: 0, connection3: 0, connection4: 0, connection5: 0, id: "mekanism:basic_universal_cable", redstone: 0b}},
{pos: [3, 1, 4], state: "mekanism:basic_energy_cube{facing:west,fluid_logged:empty}", nbt: {EnergyContainers: [{Container: 0b, stored: "4000000"}], ForgeCaps: {}, Items: [], componentConfig: {config0: {side0: 4, side1: 1, side2: 1, side3: 1, side4: 1, side5: 1}, config6: {side0: 4, side1: 1, side2: 1, side3: 1, side4: 1, side5: 1}, eject0: 1b, eject6: 0b}, componentEjector: {color0: -1, color1: -1, color2: -1, color3: -1, color4: -1, color5: -1, strictInput: 0b}, componentFrequency: {Security: {name: "Security", owner: [I; 940439953, -167562164, -1601161573, -1389718966], publicFreq: 1b}}, componentSecurity: {owner: [I; 940439953, -167562164, -1601161573, -1389718966], securityMode: 0}, controlType: 0, currentRedstone: 15, id: "mekanism:basic_energy_cube", redstone: 0b}},
{pos: [3, 1, 0], state: "minecraft:air"},
{pos: [3, 1, 1], state: "minecraft:air"},
{pos: [3, 1, 2], state: "minecraft:air"},
{pos: [3, 1, 3], state: "minecraft:air"},
{pos: [3, 1, 4], state: "minecraft:air"},
{pos: [4, 1, 0], state: "minecraft:air"},
{pos: [4, 1, 1], state: "minecraft:air"},
{pos: [4, 1, 2], state: "minecraft:air"},
Expand Down Expand Up @@ -132,13 +132,10 @@
palette: [
"minecraft:polished_andesite",
"minecraft:air",
"mekanism:creative_energy_cube{facing:north,fluid_logged:empty}",
"mekanism:basic_universal_cable{fluid_logged:empty}",
"powah:energy_cell_niotic{waterlogged:false}",
"powah:energy_cable_nitro{down:false,east:false,north:false,south:false,up:false,waterlogged:false,west:false}",
"advancedperipherals:energy_detector{orientation:south_up}",
"mekanism:creative_energy_cube{facing:west,fluid_logged:empty}",
"computercraft:computer_advanced{facing:north,state:blinking}",
"mekanism:creative_energy_cube{facing:east,fluid_logged:empty}",
"advancedperipherals:energy_detector{orientation:north_up}",
"mekanism:basic_energy_cube{facing:west,fluid_logged:empty}"
"powah:energy_cell_creative{waterlogged:false}",
"computercraft:computer_advanced{facing:north,state:blinking}"
]
}
Loading

0 comments on commit 099279e

Please sign in to comment.