Skip to content

Commit 55c394b

Browse files
committed
Refactor our filter arguments to fix compatibility with the latest CC version
[#748] Do not supply data components when there was an issue with the registries, mainly to fix some edge cases Bump gradle dependencies
1 parent 614ab67 commit 55c394b

24 files changed

Lines changed: 259 additions & 156 deletions

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ dependencies {
222222
compileOnly "org.jetbrains:annotations:${jb_annotations}"
223223
implementation "net.neoforged:neoforge:${neo_version}"
224224
implementation "cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cc_version}"
225+
compileOnly "cc.tweaked:cc-tweaked-${minecraft_version}-core:${cc_version}"
226+
225227
// Minimal requirements end
226228

227229
compileOnly("com.refinedmods.refinedstorage:refinedstorage-neoforge:${refinedstorage_version}")

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod_id=advancedperipherals
1010
mod_version=0.7.51b
1111
minecraft_version=1.21.1
1212
mod_artifact_suffix=
13-
neo_version=21.1.174
13+
neo_version=21.1.186
1414
parchment_minecraft_version=1.21.1
1515
parchment_mappings_version=2024.11.17
1616
loader_version=4
@@ -25,14 +25,14 @@ kotlinx_coroutines_version=1.6.0-RC3
2525
ttoolkit_version=0.1.3
2626

2727
# Mod dependencies
28-
cc_version=1.115.1
28+
cc_version=1.116.0
2929

3030
ae2things_version=5637783
3131
appliedenergistics_version=19.2.10
3232
appliedmekanistics_version=5978711
3333
refinedstorage_version=2.0.0-beta.2
3434
refinedstorage_mekanism_version=1.0.0
35-
minecolonies_version=1.1.978-1.21.1-snapshot
35+
minecolonies_version=1.1.1020-1.21.1-snapshot
3636
patchouli_version=1.21-88
3737
mekanism_version=1.21.1-10.7.9.72
3838
powah_version=6143661
@@ -42,7 +42,7 @@ powah_version=6143661
4242
structurize_version=1.0.775-1.21.1-snapshot
4343
multipiston_version=1.2.51-1.21.1-snapshot
4444
blockui_version=1.0.199-1.21.1-snapshot
45-
domumornamentum_version=1.0.204-1.21.1-snapshot
45+
domumornamentum_version=1.0.216-snapshot
4646
# refined storage mek integration
4747
emiVersion=1.1.11+1.21
4848
# powah

src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
1313
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
1414

15-
@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
15+
@EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT)
1616
public class ClientRegistry {
1717

1818
@SubscribeEvent

src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AEMekanismApi.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dan200.computercraft.api.lua.IArguments;
55
import dan200.computercraft.api.lua.LuaException;
66
import dan200.computercraft.api.lua.MethodResult;
7+
import dan200.computercraft.api.lua.ObjectLuaTable;
78
import dan200.computercraft.api.peripheral.IComputerAccess;
89
import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MEBridgePeripheral;
910
import de.srendi.advancedperipherals.common.blocks.blockentities.MEBridgeEntity;
@@ -30,7 +31,7 @@ public class AEMekanismApi {
3031
public static MethodResult importToME(@NotNull IArguments arguments, IComputerAccess computer, MEBridgePeripheral peripheral) throws LuaException {
3132
MEBridgeEntity bridge = peripheral.getBridge();
3233
MEStorage monitor = AEApi.getMonitor(bridge.getActionableNode());
33-
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(arguments.getTable(0));
34+
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
3435

3536
if (filter.rightPresent())
3637
return MethodResult.of(0, filter.getRight());
@@ -61,7 +62,7 @@ public static MethodResult importToME(@NotNull IArguments arguments, IComputerAc
6162
public static MethodResult exportToTank(@NotNull IArguments arguments, IComputerAccess computer, MEBridgePeripheral peripheral) throws LuaException {
6263
MEBridgeEntity bridge = peripheral.getBridge();
6364
MEStorage monitor = AEApi.getMonitor(bridge.getActionableNode());
64-
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(arguments.getTable(0));
65+
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
6566

6667
if (filter.rightPresent())
6768
return MethodResult.of(0, filter.getRight());

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java

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

33
import dan200.computercraft.api.lua.LuaException;
44
import dan200.computercraft.api.lua.LuaFunction;
5+
import dan200.computercraft.api.lua.LuaTable;
56
import dan200.computercraft.api.lua.MethodResult;
67
import de.srendi.advancedperipherals.AdvancedPeripherals;
78
import de.srendi.advancedperipherals.common.addons.computercraft.owner.BlockEntityPeripheralOwner;
@@ -54,7 +55,7 @@ public final String getOwner() throws LuaException {
5455
//The item is specified the same as with the RS/ME bridge:
5556
//{name="minecraft:enchanted_book", count=1, nbt="ae70053c97f877de546b0248b9ddf525"}
5657
@LuaFunction(mainThread = true)
57-
public final MethodResult addItemToPlayer(String invDirection, Map<?, ?> item) throws LuaException {
58+
public final MethodResult addItemToPlayer(String invDirection, LuaTable<?, ?> item) throws LuaException {
5859
Pair<ItemFilter, String> filter = ItemFilter.parse(item);
5960
if (filter.rightPresent())
6061
return MethodResult.of(0, filter.getRight());
@@ -79,7 +80,7 @@ private MethodResult addItemCommon(String invDirection, ItemFilter filter) throw
7980
}
8081

8182
@LuaFunction(mainThread = true)
82-
public final MethodResult removeItemFromPlayer(String invDirection, Map<?, ?> item) throws LuaException {
83+
public final MethodResult removeItemFromPlayer(String invDirection, LuaTable<?, ?> item) throws LuaException {
8384
Pair<ItemFilter, String> filter = ItemFilter.parse(item);
8485
if (filter.rightPresent())
8586
return MethodResult.of(0, filter.getRight());

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MEBridgePeripheral.java

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
import dan200.computercraft.api.lua.IArguments;
1313
import dan200.computercraft.api.lua.LuaException;
1414
import dan200.computercraft.api.lua.LuaFunction;
15+
import dan200.computercraft.api.lua.LuaTable;
1516
import dan200.computercraft.api.lua.MethodResult;
17+
import dan200.computercraft.api.lua.ObjectLuaTable;
1618
import dan200.computercraft.api.peripheral.IComputerAccess;
17-
import dan200.computercraft.core.apis.TableHelper;
1819
import de.srendi.advancedperipherals.common.addons.APAddon;
1920
import de.srendi.advancedperipherals.common.addons.appliedenergistics.AEApi;
2021
import de.srendi.advancedperipherals.common.addons.appliedenergistics.AECraftJob;
@@ -24,6 +25,7 @@
2425
import de.srendi.advancedperipherals.common.addons.computercraft.owner.BlockEntityPeripheralOwner;
2526
import de.srendi.advancedperipherals.common.blocks.blockentities.MEBridgeEntity;
2627
import de.srendi.advancedperipherals.common.configuration.APConfig;
28+
import de.srendi.advancedperipherals.common.util.EmptyLuaTable;
2729
import de.srendi.advancedperipherals.common.util.Pair;
2830
import de.srendi.advancedperipherals.common.util.StatusConstants;
2931
import de.srendi.advancedperipherals.common.util.inventory.ChemicalFilter;
@@ -44,6 +46,7 @@
4446
import java.util.Collections;
4547
import java.util.List;
4648
import java.util.Map;
49+
import java.util.Optional;
4750

4851
public class MEBridgePeripheral extends BasePeripheral<BlockEntityPeripheralOwner<MEBridgeEntity>> implements IStorageSystemPeripheral {
4952

@@ -85,7 +88,7 @@ public MEBridgeEntity getBridge() {
8588
protected MethodResult exportToChest(@NotNull IArguments arguments, IItemHandler targetInventory) throws LuaException {
8689
MEStorage monitor = AEApi.getMonitor(node);
8790
MEItemHandler itemHandler = new MEItemHandler(monitor, bridge);
88-
Pair<ItemFilter, String> filter = ItemFilter.parse(arguments.getTable(0));
91+
Pair<ItemFilter, String> filter = ItemFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
8992

9093
if (filter.rightPresent())
9194
return MethodResult.of(0, filter.getRight());
@@ -103,7 +106,7 @@ protected MethodResult exportToChest(@NotNull IArguments arguments, IItemHandler
103106
protected MethodResult exportToTank(@NotNull IArguments arguments, IFluidHandler targetTank) throws LuaException {
104107
MEStorage monitor = AEApi.getMonitor(node);
105108
MEFluidHandler fluidHandler = new MEFluidHandler(monitor, bridge);
106-
Pair<FluidFilter, String> filter = FluidFilter.parse(arguments.getTable(0));
109+
Pair<FluidFilter, String> filter = FluidFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
107110

108111
if (filter.rightPresent())
109112
return MethodResult.of(0, filter.getRight());
@@ -122,7 +125,7 @@ protected MethodResult exportToTank(@NotNull IArguments arguments, IFluidHandler
122125
protected MethodResult importToME(@NotNull IArguments arguments, IItemHandler targetInventory) throws LuaException {
123126
MEStorage monitor = AEApi.getMonitor(node);
124127
MEItemHandler itemHandler = new MEItemHandler(monitor, bridge);
125-
Pair<ItemFilter, String> filter = ItemFilter.parse(arguments.getTable(0));
128+
Pair<ItemFilter, String> filter = ItemFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
126129

127130
if (filter.rightPresent())
128131
return MethodResult.of(0, filter.getRight());
@@ -140,7 +143,7 @@ protected MethodResult importToME(@NotNull IArguments arguments, IItemHandler ta
140143
protected MethodResult importToME(@NotNull IArguments arguments, IFluidHandler targetTank) throws LuaException {
141144
MEStorage monitor = AEApi.getMonitor(node);
142145
MEFluidHandler fluidHandler = new MEFluidHandler(monitor, bridge);
143-
Pair<FluidFilter, String> filter = FluidFilter.parse(arguments.getTable(0));
146+
Pair<FluidFilter, String> filter = FluidFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
144147

145148
if (filter.rightPresent())
146149
return MethodResult.of(0, filter.getRight());
@@ -175,7 +178,7 @@ public final MethodResult getItem(IArguments arguments) throws LuaException {
175178
return notConnected(null);
176179

177180
MEStorage monitor = AEApi.getMonitor(node);
178-
Pair<ItemFilter, String> filter = ItemFilter.parse(arguments.getTable(0));
181+
Pair<ItemFilter, String> filter = ItemFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
179182
if (filter.rightPresent())
180183
return MethodResult.of(null, filter.getRight());
181184

@@ -192,7 +195,7 @@ public MethodResult getFluid(IArguments arguments) throws LuaException {
192195
if (!isAvailable())
193196
return notConnected(null);
194197

195-
Pair<FluidFilter, String> filter = FluidFilter.parse(arguments.getTable(0));
198+
Pair<FluidFilter, String> filter = FluidFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
196199
if (filter.rightPresent())
197200
return MethodResult.of(null, filter.getRight());
198201

@@ -209,7 +212,7 @@ public MethodResult getChemical(IArguments arguments) throws LuaException {
209212
if (!isAvailable())
210213
return notConnected(null);
211214

212-
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(arguments.getTable(0));
215+
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
213216
if (filter.rightPresent())
214217
return MethodResult.of(null, filter.getRight());
215218

@@ -226,7 +229,7 @@ public final MethodResult getItems(IArguments arguments) throws LuaException {
226229
if (!isAvailable())
227230
return notConnected(null);
228231

229-
Pair<ItemFilter, String> filter = ItemFilter.parse(arguments.optTable(0, Collections.emptyMap()));
232+
Pair<ItemFilter, String> filter = ItemFilter.parse(arguments.optTableUnsafe(0).orElse(EmptyLuaTable.INSTANCE));
230233
if (filter.rightPresent())
231234
return MethodResult.of(null, filter.getRight());
232235

@@ -241,7 +244,7 @@ public final MethodResult getFluids(IArguments arguments) throws LuaException {
241244
if (!isAvailable())
242245
return notConnected(null);
243246

244-
Pair<FluidFilter, String> filter = FluidFilter.parse(arguments.optTable(0, Collections.emptyMap()));
247+
Pair<FluidFilter, String> filter = FluidFilter.parse(arguments.optTableUnsafe(0).orElse(EmptyLuaTable.INSTANCE));
245248
if (filter.rightPresent())
246249
return MethodResult.of(null, filter.getRight());
247250

@@ -259,7 +262,7 @@ public MethodResult getChemicals(IArguments arguments) throws LuaException {
259262
if (!APAddon.APP_MEKANISTICS.isLoaded())
260263
return MethodResult.of(null, StatusConstants.ADDON_NOT_LOADED.withInfo(APAddon.APP_MEKANISTICS.name()));
261264

262-
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(arguments.optTable(0, Collections.emptyMap()));
265+
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(arguments.optTableUnsafe(0).orElse(EmptyLuaTable.INSTANCE));
263266
if (filter.rightPresent())
264267
return MethodResult.of(null, filter.getRight());
265268

@@ -274,7 +277,7 @@ public final MethodResult getCraftableItems(IArguments arguments) throws LuaExce
274277
if (!isAvailable())
275278
return notConnected(null);
276279

277-
Pair<ItemFilter, String> filter = ItemFilter.parse(arguments.optTable(0, Collections.emptyMap()));
280+
Pair<ItemFilter, String> filter = ItemFilter.parse(arguments.optTableUnsafe(0).orElse(EmptyLuaTable.INSTANCE));
278281
if (filter.rightPresent())
279282
return MethodResult.of(null, filter.getRight());
280283

@@ -289,7 +292,7 @@ public final MethodResult getCraftableFluids(IArguments arguments) throws LuaExc
289292
if (!isAvailable())
290293
return notConnected(null);
291294

292-
Pair<FluidFilter, String> filter = FluidFilter.parse(arguments.optTable(0, Collections.emptyMap()));
295+
Pair<FluidFilter, String> filter = FluidFilter.parse(arguments.optTableUnsafe(0).orElse(EmptyLuaTable.INSTANCE));
293296
if (filter.rightPresent())
294297
return MethodResult.of(null, filter.getRight());
295298

@@ -306,7 +309,7 @@ public MethodResult getCraftableChemicals(IArguments arguments) throws LuaExcept
306309
if (!APAddon.APP_MEKANISTICS.isLoaded())
307310
return MethodResult.of(null, StatusConstants.ADDON_NOT_LOADED.withInfo(APAddon.APP_MEKANISTICS.name()));
308311

309-
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(arguments.optTable(0, Collections.emptyMap()));
312+
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(arguments.optTableUnsafe(0).orElse(EmptyLuaTable.INSTANCE));
310313
if (filter.rightPresent())
311314
return MethodResult.of(null, filter.getRight());
312315

@@ -442,11 +445,13 @@ public MethodResult getPatterns(IArguments arguments) throws LuaException {
442445

443446
// Expected input is a table with either an input table, an output table or both to filter for both
444447
// If no table is provided or it's empty, return every pattern
445-
Map<?, ?> filterTable = arguments.optTable(0, Collections.emptyMap());
446-
if (filterTable.isEmpty()) {
448+
Optional<LuaTable<?, ?>> optFilter = arguments.optTableUnsafe(0);
449+
if (optFilter.isEmpty()) {
447450
return MethodResult.of(AEApi.listPatterns(node.getGrid(), getLevel()));
448451
}
449452

453+
LuaTable<?, ?> filterTable = optFilter.get();
454+
450455
boolean hasInputFilter = filterTable.containsKey("input");
451456
boolean hasOutputFilter = filterTable.containsKey("output");
452457
boolean hasAnyFilter = hasInputFilter || hasOutputFilter;
@@ -459,12 +464,12 @@ public MethodResult getPatterns(IArguments arguments) throws LuaException {
459464
GenericFilter<?> outputFilter = null;
460465

461466
if (hasInputFilter) {
462-
Map<?, ?> inputFilterTable = TableHelper.getTableField(filterTable, "input");
467+
LuaTable<?, ?> inputFilterTable = new ObjectLuaTable(filterTable.getTable("input"));
463468

464469
inputFilter = GenericFilter.parseGeneric(inputFilterTable).getLeft();
465470
}
466471
if (hasOutputFilter) {
467-
Map<?, ?> outputFilterTable = TableHelper.getTableField(filterTable, "output");
472+
LuaTable<?, ?> outputFilterTable = new ObjectLuaTable(filterTable.getTable("output"));
468473

469474
outputFilter = GenericFilter.parseGeneric(outputFilterTable).getLeft();
470475
}
@@ -681,7 +686,7 @@ public final MethodResult craftItem(IComputerAccess computer, IArguments argumen
681686
if (!isAvailable())
682687
return notConnected(null);
683688

684-
Pair<ItemFilter, String> filter = ItemFilter.parse(arguments.getTable(0));
689+
Pair<ItemFilter, String> filter = ItemFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
685690
if (filter.rightPresent())
686691
return MethodResult.of(null, filter.getRight());
687692

@@ -713,7 +718,7 @@ public final MethodResult craftFluid(IComputerAccess computer, IArguments argume
713718
if (!isAvailable())
714719
return notConnected(null);
715720

716-
Pair<FluidFilter, String> filter = FluidFilter.parse(arguments.getTable(0));
721+
Pair<FluidFilter, String> filter = FluidFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
717722
if (filter.rightPresent())
718723
return MethodResult.of(null, filter.getRight());
719724

@@ -744,7 +749,7 @@ public MethodResult craftChemical(IComputerAccess computer, IArguments arguments
744749
if (!APAddon.APP_MEKANISTICS.isLoaded())
745750
return MethodResult.of(null, StatusConstants.ADDON_NOT_LOADED.withInfo(APAddon.APP_MEKANISTICS.name()));
746751

747-
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(arguments.getTable(0));
752+
Pair<ChemicalFilter, String> filter = ChemicalFilter.parse(new ObjectLuaTable(arguments.getTable(0)));
748753
if (filter.rightPresent())
749754
return MethodResult.of(null, filter.getRight());
750755

@@ -811,7 +816,7 @@ public MethodResult cancelCraftingTasks(IArguments arguments) throws LuaExceptio
811816

812817
ICraftingService craftingGrid = node.getGrid().getService(ICraftingService.class);
813818

814-
Pair<? extends GenericFilter<?>, String> filter = GenericFilter.parseGeneric(arguments.getTable(0));
819+
Pair<? extends GenericFilter<?>, String> filter = GenericFilter.parseGeneric(new ObjectLuaTable(arguments.getTable(0)));
815820
if (filter.getRight() != null)
816821
return MethodResult.of(0, filter.getRight());
817822

@@ -833,7 +838,7 @@ public final MethodResult isCraftable(IArguments arguments) throws LuaException
833838
if (!isAvailable())
834839
return notConnected(false);
835840

836-
Pair<? extends GenericFilter<?>, String> filter = GenericFilter.parseGeneric(arguments.getTable(0));
841+
Pair<? extends GenericFilter<?>, String> filter = GenericFilter.parseGeneric(new ObjectLuaTable(arguments.getTable(0)));
837842
if (filter.getRight() != null)
838843
return MethodResult.of(false, filter.getRight());
839844

@@ -852,7 +857,7 @@ public final MethodResult isCrafting(IArguments arguments) throws LuaException {
852857

853858
ICraftingService grid = node.getGrid().getService(ICraftingService.class);
854859

855-
Pair<? extends GenericFilter<?>, String> filter = GenericFilter.parseGeneric(arguments.getTable(0));
860+
Pair<? extends GenericFilter<?>, String> filter = GenericFilter.parseGeneric(new ObjectLuaTable(arguments.getTable(0)));
856861
if (filter.getRight() != null)
857862
return MethodResult.of(false, filter.getRight());
858863

0 commit comments

Comments
 (0)