From c8eadf401190db2b9c3145f768063097b9c345bd Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 3 Apr 2024 08:44:30 +0100 Subject: [PATCH] Register CC's modems as brittle This tells Create that modems will pop-off if their neighbour is moved, and so changes the order that the block is moved in. We possibly should use BlockMovementChecks.AttachedCheck instead, to properly handle the direction modems are facing in. However, this doesn't appear to be part of the public API, so probably best avoided. Fixes #948 --- .../computercraft/data/TagProvider.java | 7 ++++ .../shared/integration/ExternalModTags.java | 37 +++++++++++++++++++ .../data/create/tags/blocks/brittle.json | 4 ++ .../data/create/tags/blocks/brittle.json | 3 ++ 4 files changed, 51 insertions(+) create mode 100644 projects/common/src/main/java/dan200/computercraft/shared/integration/ExternalModTags.java create mode 100644 projects/fabric/src/generated/resources/data/create/tags/blocks/brittle.json create mode 100644 projects/forge/src/generated/resources/data/create/tags/blocks/brittle.json diff --git a/projects/common/src/main/java/dan200/computercraft/data/TagProvider.java b/projects/common/src/main/java/dan200/computercraft/data/TagProvider.java index 9b207e09d..4d273bb9e 100644 --- a/projects/common/src/main/java/dan200/computercraft/data/TagProvider.java +++ b/projects/common/src/main/java/dan200/computercraft/data/TagProvider.java @@ -6,6 +6,7 @@ package dan200.computercraft.data; import dan200.computercraft.api.ComputerCraftTags; import dan200.computercraft.shared.ModRegistry; +import dan200.computercraft.shared.integration.ExternalModTags; import dan200.computercraft.shared.platform.RegistryWrappers; import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.data.tags.TagsProvider; @@ -81,6 +82,12 @@ class TagProvider { ); tags.tag(BlockTags.WITHER_IMMUNE).add(ModRegistry.Blocks.COMPUTER_COMMAND.get()); + + tags.tag(ExternalModTags.Blocks.CREATE_BRITTLE).add( + ModRegistry.Blocks.CABLE.get(), + ModRegistry.Blocks.WIRELESS_MODEM_ADVANCED.get(), + ModRegistry.Blocks.WIRELESS_MODEM_ADVANCED.get() + ); } public static void itemTags(ItemTagConsumer tags) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/integration/ExternalModTags.java b/projects/common/src/main/java/dan200/computercraft/shared/integration/ExternalModTags.java new file mode 100644 index 000000000..29a666217 --- /dev/null +++ b/projects/common/src/main/java/dan200/computercraft/shared/integration/ExternalModTags.java @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers +// +// SPDX-License-Identifier: MPL-2.0 + +package dan200.computercraft.shared.integration; + +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.block.Block; + +/** + * Tags defined by external mods. + */ +public final class ExternalModTags { + private ExternalModTags() { + } + + /** + * Block tags defined by external mods. + */ + public static final class Blocks { + private Blocks() { + } + + /** + * Create's "brittle" tag, used to determine if this block needs to be moved before its neighbours. + * + * @see {@code BlockMovementChecks} + */ + public static final TagKey CREATE_BRITTLE = make("create", "brittle"); + + private static TagKey make(String mod, String name) { + return TagKey.create(Registries.BLOCK, new ResourceLocation(mod, name)); + } + } +} diff --git a/projects/fabric/src/generated/resources/data/create/tags/blocks/brittle.json b/projects/fabric/src/generated/resources/data/create/tags/blocks/brittle.json new file mode 100644 index 000000000..32215971e --- /dev/null +++ b/projects/fabric/src/generated/resources/data/create/tags/blocks/brittle.json @@ -0,0 +1,4 @@ +{ + "replace": false, + "values": ["computercraft:cable", "computercraft:wireless_modem_advanced", "computercraft:wireless_modem_advanced"] +} diff --git a/projects/forge/src/generated/resources/data/create/tags/blocks/brittle.json b/projects/forge/src/generated/resources/data/create/tags/blocks/brittle.json new file mode 100644 index 000000000..7dc5f506f --- /dev/null +++ b/projects/forge/src/generated/resources/data/create/tags/blocks/brittle.json @@ -0,0 +1,3 @@ +{ + "values": ["computercraft:cable", "computercraft:wireless_modem_advanced", "computercraft:wireless_modem_advanced"] +}