-
Notifications
You must be signed in to change notification settings - Fork 1k
Computer Craft integration for Update 6 Logistics Blocks #7669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I've been grinding the pr for 3 days on and on, while i was in the zoneee but now i'm taking a bit of a break. I'll be editing this message with random things i might need to change (even if the fixes are really really easy, i don't have the time to test):
|
Thanks for the PR. Is it possible to target 1.20 for feature parity? If not that's okay, you'll just have to make it clear in the wiki that 1.20 users do not have access to this |
I definitely want to at least try getting this working for 1.20! |
Turning this into a draft for a bit. We're also completely open to pulling in #7453 ! Once that gets pulled we'll have even more features :D |
} | ||
|
||
@LuaFunction(mainThread = true) | ||
public final void setAddress(IArguments arguments) throws LuaException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, drive by review here — you can use Optional
here, to skip having to do the arg checking yourself.
public final void setAddress(IArguments arguments) throws LuaException { | |
public final void setAddress(Optional<String> argument) throws LuaException { | |
if (argument.isPresent()) { | |
blockEntity.addressFilter = argument.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much squid! I'll tweak every case of setAddress
and the sort to match this :D
Also, psst, if you wanna see the pharaoh's curse (also known as baby's first time dealing with type madness) i suggest looking at bigItemStackToLuaTableFilter: https://github.com/BirbIrl/Create/blob/mc1.21.1/dev/src/main/java/com/simibubi/create/compat/computercraft/implementation/ComputerUtil.java#L19
it's so much spaghetti - i.. i can't even explain it. there's some documentation on how it's supposed to work here:
https://birbirl.github.io/wiki/users/cc-tweaked-integration/logistics/stock-ticker#request
if you look at it and instantly have ideas, i'd highly appreciate notes on any tweaks to make it comprehensible :D
(it works, just... i don't want random maintainers to stumble upon it when they find some issue with the filtering)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, had missed your comment!
Oh, hah. That is a gnarly beast. Frankly, I'm not sure there's any nice way to write this code, parsing Lua structures is a right pain.
Honestly, what I'd probably recommend is instead of trying to compare the map against the result of VanillaDetailRegistries.ITEM_STACK.getDetails
, parse the filter into a predicate, and then match that against the actual ItemStack
. So maybe something like:
record ItemStackFilter(
Optional<Item> item,
Optional<String> displayName,
List<ResourceLocation> tags,
List<EnchantmentFilter> enchantments,
) : Predicate<ItemStack> {
@Override
public boolean test(ItemStack stack) {
if(item.isPresent() && stack.getItem() != item.get()) return false;
if(diplayName.isPresent() && !stack.getHoverName().getString().equals(displayName.get()) return false;
// ...
}
}
For the actual parsing, I was going to suggest using LuaTable
's helper methods for extracting keys out the table, but that actually has much less functionality then I thought it did. I will try to flesh that out. I would instead recommend using something like CC:T's TableHelper
(I'm happy to share that under Create's license), so shift some of the parsing away.
So for instance, you might have:
var displayName = Optional.ofNullable(optStringField(filter, "displayName", null));
// ...
return ItemStackFilter(..., displayName, ...)
Honestly, the Ideal(TM) thing to do would probably be to add this to CC's API (so other mods can register their own filter). I'd have to have a think — this probably only makes sense if other mods would find it useful, and not entirely sure if that's true!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaah by now we're reaching a point of burnout as we increased the number of peripherals from 2 to 7 and finishing off documentation, so it's reassuring to know my way of doing things is not the worst :DDD. It works and i'm terrified of breaking it so i'll leave it at that.
If there's ever going to be a native CC way we'll definitely try to implement it, to be consistent with all other peripheral implementations :D
I've also made us of Optional<> as much as possible, it's made the code so much easier to read.
Thanks for the in depth overview squid!
seems to work flawlessly.
enchantment checks exclusive, (one enchant per one set of enchant traits), made it so the number of enchants in the filter and items have to match. Will give a good example of it in the documentation linked in the pr
packager/postbox/frogge
…getting to set a variable t what they want it to be
Order is off when placing into requester
fixed the ordering bug
Added some safety stuff and made it actually save
an error? it's the same thing!
between stock ticker and redstone requester peripheral
Added ShopUpdate packet for updating shop rendering on computer updates
!!! There is a bug left to fix, the tablecloth stops being a blockentity even when a computer is plugged in, so after .setWares(nil) it stops being interactable with the computer.
With unified effort, @AsterAether, @Karotte128, @McArctic and I have finished the PR! We have quadrupled the amount of features, going from 2 to 7 peripherals, now supporting:
All of which serve different purposes and have unique functionality :D
...And more! We've also managed to backport this to 1.20.1 and tested both versions. I'll be opening a PR today with our 1.20.1 branch as well. Thank you to Aster, Karotte, Arctic for doing the other 75% of the work! This wouldn't've been possible without their help. PS. We plan to add more features when we regenerate and #7453 gets pulled in. Their event system works wonders with what we've done, and adding their functionality to the logistics blocks will be a walk in the park. Hopefully. So please consider pulling that in as well! |
closed in favor of #7883 |
Hi, this is cross-linked with the wiki pr that has all the documenation. you can preview the documentation here. I added a new folder called "logistics" with the 2 new peripherals.
I also made an unlisted youtube video showcasing the PR: https://youtu.be/_zsRSmOwv90
The most notable additions are:
The blockentity for the packager now gets a new variable that only gets used if a powered on computer is actively connected to it - it overwrites the address it'd get from a sign with one from the computer, if one exists.
There is a full item-filtering-search-requesting algorithm made to work with the type-unsafeness of lua, working in spirit with how native Computer Craft does, and similarly to that of AdvancedPeripherals and similar bridging mods. Basically, type in some data, the Logistical system will get you a package matching that data under a given address. Full documentation here.
Couple notes:
null
causes issues down the stack. the packager can handle null addresses just fine tho.if this gets pulled in i'd also like to use their function to send events whenever a package is sent, whenever a package is received - et cetra. tons of room here. Could also add events to packagers to fire with the address of the package and contents whenever it pulls in an item :D.
and even with all that, this is a major CC implementation that expands the amount of things you can do in create by a LOT, while encouraging to use create's new features instead of sending and reading items by a wired CC network.
(oh also there is also full type checking and error handling with custom messages and examples to help guide players :>)
And thank you for making one of the best designed mods, i'm in love with 6.0!