mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-30 00:57:55 +00:00
Allow equipping pocket computers on the bottom
This allows equipping pocket computers on both the back (as before) and bottom of a pocket computer. The asymmetry is a little unfortunate here, but makes some sense with the crafting recipe (above goes behind, below goes on the bottom). - Move some functionality from IPocketAccess into a PocketComputer interface (and PocketComputerInternal) interface, used by the pocket API. IPocketAccess preserves the same interface as before. Unlike ITurtleAccess, we /don't/ expose the PocketSide in the public API. - Several pocket-computer methods (e.g. setUpgradeData, setColour) are now required to be called on the main thread, and when the computer is being held. This allows us to write back changes to the item immediately, rather than the next time the item is ticked. Sadly this doesn't actually remove the need for onCraftedPostProcess as I'd originally hoped, but I think does make the code a little simpler. - Rename "computercraft:pocket_computer" component to "computercraft:back_pocket_computer". - And finally, support multiple upgrades on the pocket computer. This is actually quite an easy change, just tedious — there's lots of places to update! Fixes #1406, and I think fixes #1148 — you can use a speaker to notify you now.
This commit is contained in:
@@ -6,6 +6,7 @@ package dan200.computercraft.shared.integration.rei;
|
||||
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.pocket.core.PocketSide;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItem;
|
||||
import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry;
|
||||
@@ -30,8 +31,14 @@ public class REIComputerCraft implements REICommonPlugin {
|
||||
}, ModRegistry.Items.TURTLE_NORMAL.get(), ModRegistry.Items.TURTLE_ADVANCED.get());
|
||||
|
||||
registry.register((context, stack) -> {
|
||||
var upgrade = PocketComputerItem.getUpgradeWithData(stack);
|
||||
return upgrade == null ? 1 : upgrade.holder().key().location().hashCode();
|
||||
long hash = 1;
|
||||
|
||||
var back = PocketComputerItem.getUpgradeWithData(stack, PocketSide.BACK);
|
||||
var bottom = PocketComputerItem.getUpgradeWithData(stack, PocketSide.BOTTOM);
|
||||
if (back != null) hash = hash * 31 + back.holder().key().location().hashCode();
|
||||
if (bottom != null) hash = hash * 31 + bottom.holder().key().location().hashCode();
|
||||
|
||||
return hash;
|
||||
}, ModRegistry.Items.POCKET_COMPUTER_NORMAL.get(), ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get());
|
||||
|
||||
registry.register((context, stack) -> DyedItemColor.getOrDefault(stack, -1), ModRegistry.Items.DISK.get());
|
||||
|
Reference in New Issue
Block a user