1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-04-08 19:56:41 +00:00

Add a tag for blocks wired modems should ignore

Includes wired modems (as before), but can be extended by other mods if
needed.
This commit is contained in:
Jonathan Coates 2023-09-11 21:28:56 +01:00
parent 56d97630e8
commit b1248e4901
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
5 changed files with 14 additions and 3 deletions

View File

@ -46,6 +46,14 @@ public class ComputerCraftTags {
public static final TagKey<Block> WIRED_MODEM = make("wired_modem");
public static final TagKey<Block> MONITOR = make("monitor");
/**
* Blocks which should be ignored by a {@code peripheral_hub} peripheral.
* <p>
* This should include blocks which themselves expose a peripheral hub (such as {@linkplain #WIRED_MODEM wired
* modems}).
*/
public static final TagKey<Block> PERIPHERAL_HUB_IGNORE = make("peripheral_hub_ignore");
/**
* Blocks which can be broken by any turtle tool.
*/

View File

@ -35,6 +35,8 @@ class TagProvider {
tags.tag(ComputerCraftTags.Blocks.WIRED_MODEM).add(ModRegistry.Blocks.CABLE.get(), ModRegistry.Blocks.WIRED_MODEM_FULL.get());
tags.tag(ComputerCraftTags.Blocks.MONITOR).add(ModRegistry.Blocks.MONITOR_NORMAL.get(), ModRegistry.Blocks.MONITOR_ADVANCED.get());
tags.tag(ComputerCraftTags.Blocks.PERIPHERAL_HUB_IGNORE).addTag(ComputerCraftTags.Blocks.WIRED_MODEM);
tags.tag(ComputerCraftTags.Blocks.TURTLE_ALWAYS_BREAKABLE).addTag(BlockTags.LEAVES).add(
Blocks.BAMBOO, Blocks.BAMBOO_SAPLING // Bamboo isn't instabreak for some odd reason.
);

View File

@ -4,8 +4,8 @@
package dan200.computercraft.shared.peripheral.modem.wired;
import dan200.computercraft.api.ComputerCraftTags;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.computer.core.ServerContext;
import dan200.computercraft.shared.platform.ComponentAccess;
import dan200.computercraft.shared.platform.PlatformHelper;
@ -124,8 +124,7 @@ public final class WiredModemLocalPeripheral {
private IPeripheral getPeripheralFrom(Level world, BlockPos pos, Direction direction) {
var offset = pos.relative(direction);
var block = world.getBlockState(offset).getBlock();
if (block == ModRegistry.Blocks.WIRED_MODEM_FULL.get() || block == ModRegistry.Blocks.CABLE.get()) return null;
if (world.getBlockState(offset).is(ComputerCraftTags.Blocks.PERIPHERAL_HUB_IGNORE)) return null;
var peripheral = peripherals.get((ServerLevel) world, pos, direction);
return peripheral instanceof WiredModemPeripheral ? null : peripheral;

View File

@ -0,0 +1 @@
{"replace": false, "values": ["#computercraft:wired_modem"]}

View File

@ -0,0 +1 @@
{"values": ["#computercraft:wired_modem"]}