Skip to content

Commit dcec13e

Browse files
committed
Merge branch 'mc1.21.1/dev' of https://github.com/BirbIrl/Create into mc1.21.1/dev
2 parents 9c4b772 + 3d867c4 commit dcec13e

File tree

1 file changed

+2
-46
lines changed

1 file changed

+2
-46
lines changed

src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/RedstoneRequesterPeripheral.java

+2-46
Original file line numberDiff line numberDiff line change
@@ -51,52 +51,8 @@ public RedstoneRequesterPeripheral(RedstoneRequesterBlockEntity blockEntity) {
5151
* filter of {} requests all items from the network trollface.jpeg
5252
*/
5353
@LuaFunction(mainThread = true)
54-
public final int request(IArguments arguments) throws LuaException {
55-
if (!(arguments.get(0) instanceof Map<?, ?>))
56-
return 0;
57-
Map<?, ?> filter = (Map<?, ?>) arguments.get(0);
58-
String address;
59-
// Computercraft has forced my hand to make this dollar store filter algo
60-
List<BigItemStack> validItems = new ArrayList<>();
61-
int totalItemCount = 0;
62-
for (BigItemStack entry : blockEntity.getAccurateSummary().getStacks()) {
63-
if (ComputerUtil.bigItemStackToLuaTableFilter(entry, filter) > 0) {
64-
// limit the number of items pulled from the system equals to the requested
65-
// count parameter
66-
if (filter.containsKey("count")) {
67-
Object count = filter.get("count");
68-
if (count instanceof Double) {
69-
int maxCount = ((Double) count).intValue();
70-
int remainingCount = maxCount - totalItemCount;
71-
72-
if (remainingCount > 0) {
73-
int itemsToAdd = Math.min(remainingCount, entry.count);
74-
entry.count = itemsToAdd;
75-
totalItemCount += itemsToAdd;
76-
} else
77-
break;
78-
}
79-
} else {
80-
totalItemCount += entry.count;
81-
}
82-
validItems.add(entry);
83-
}
84-
}
85-
if (arguments.get(1) instanceof String)
86-
address = arguments.getString(1);
87-
else
88-
address = "";
89-
90-
PackageOrder order = new PackageOrder(validItems);
91-
blockEntity.broadcastPackageRequest(RequestType.RESTOCK, order, null, address);
92-
93-
/*
94-
* CatnipServices.NETWORK
95-
* .sendToServer(new PackageOrderRequestPacket(blockEntity.getBlockPos(), new
96-
* PackageOrder(itemsToOrder),
97-
* address, false, new PackageOrder(stacks);
98-
*/
99-
return totalItemCount;
54+
public final void request() throws LuaException {
55+
blockEntity.triggerRequest();
10056
}
10157

10258
@LuaFunction(mainThread = true)

0 commit comments

Comments
 (0)