diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullLanguageProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullLanguageProvider.java index ae6a026..dc47ebc 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullLanguageProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullLanguageProvider.java @@ -7,7 +7,6 @@ import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.integration.Addons; -import gripe._90.fulleng.integration.requester.RequesterIntegration; import gripe._90.fulleng.integration.tooltips.TooltipProvider; public class FullLanguageProvider extends LanguageProvider { @@ -19,8 +18,8 @@ public FullLanguageProvider(PackOutput output) { public void addTranslations() { add("config.jade.plugin_fulleng." + TooltipProvider.STORAGE_MONITOR, "Fullblock Storage Monitor"); - if (Addons.REQUESTER.isLoaded()) { - add(RequesterIntegration.NOT_INSTALLED.getString(), "ME Requester not installed."); + for (var addon : Addons.values()) { + add(addon.getNotInstalledTooltip().getString(), addon.getModName() + " not installed."); } } diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java index e0227a7..833081b 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java @@ -2,6 +2,7 @@ import org.jetbrains.annotations.NotNull; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; @@ -13,6 +14,7 @@ import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.block.FullBlock; import gripe._90.fulleng.definition.FullEngBlocks; +import gripe._90.fulleng.integration.Addons; public class FullRecipeProvider extends RecipeProvider { public FullRecipeProvider(PackOutput output) { @@ -28,11 +30,15 @@ public void buildRecipes(@NotNull RecipeOutput output) { block(output, FullEngBlocks.STORAGE_MONITOR); block(output, FullEngBlocks.CONVERSION_MONITOR); + + if (Addons.REQUESTER.isLoaded()) { + block(Addons.REQUESTER.conditionalOutput(output), FullEngBlocks.REQUESTER_TERMINAL); + } } private void block(@NotNull RecipeOutput output, BlockDefinition> block) { var part = block.block().getEquivalentPart(); - var partId = part.id().getPath(); + var partId = BuiltInRegistries.ITEM.getKey(part.asItem()).getPath(); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, block) .requires(part) diff --git a/src/main/java/gripe/_90/fulleng/block/FullBlock.java b/src/main/java/gripe/_90/fulleng/block/FullBlock.java index 13327e6..141bd68 100644 --- a/src/main/java/gripe/_90/fulleng/block/FullBlock.java +++ b/src/main/java/gripe/_90/fulleng/block/FullBlock.java @@ -2,6 +2,7 @@ import org.jetbrains.annotations.NotNull; +import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -13,16 +14,15 @@ import appeng.api.orientation.IOrientationStrategy; import appeng.api.orientation.OrientationStrategies; import appeng.block.AEBaseEntityBlock; -import appeng.core.definitions.ItemDefinition; import gripe._90.fulleng.block.entity.FullBlockEntity; public abstract class FullBlock extends AEBaseEntityBlock { public static final BooleanProperty POWERED = BooleanProperty.create("powered"); - private final ItemDefinition equivalentPart; + private final ItemLike equivalentPart; - public FullBlock(ItemDefinition equivalentPart) { + public FullBlock(ItemLike equivalentPart) { super(BlockBehaviour.Properties.of() .strength(2.2f, 11.0f) .mapColor(MapColor.METAL) @@ -48,7 +48,7 @@ public IOrientationStrategy getOrientationStrategy() { return OrientationStrategies.full(); } - public ItemDefinition getEquivalentPart() { + public ItemLike getEquivalentPart() { return equivalentPart; } diff --git a/src/main/java/gripe/_90/fulleng/block/MonitorBlock.java b/src/main/java/gripe/_90/fulleng/block/MonitorBlock.java index 8384d2a..6712118 100644 --- a/src/main/java/gripe/_90/fulleng/block/MonitorBlock.java +++ b/src/main/java/gripe/_90/fulleng/block/MonitorBlock.java @@ -5,6 +5,7 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; @@ -13,7 +14,6 @@ import net.minecraft.world.phys.BlockHitResult; import appeng.api.util.DimensionalBlockPos; -import appeng.core.definitions.ItemDefinition; import appeng.util.InteractionUtil; import appeng.util.Platform; @@ -22,7 +22,7 @@ public class MonitorBlock extends FullBlock { public static final BooleanProperty LOCKED = BooleanProperty.create("locked"); - public MonitorBlock(ItemDefinition equivalentPart) { + public MonitorBlock(ItemLike equivalentPart) { super(equivalentPart); } diff --git a/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java b/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java index c5d4030..c205a26 100644 --- a/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java +++ b/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java @@ -28,9 +28,10 @@ import gripe._90.fulleng.block.entity.terminal.PatternEncodingTerminalBlockEntity; import gripe._90.fulleng.block.entity.terminal.StorageTerminalBlockEntity; import gripe._90.fulleng.block.entity.terminal.TerminalBlockEntity; +import gripe._90.fulleng.integration.Addons; +import gripe._90.fulleng.integration.IntegrationBlockItem; import gripe._90.fulleng.integration.requester.RequesterTerminalBlock; import gripe._90.fulleng.integration.requester.RequesterTerminalBlockEntity; -import gripe._90.fulleng.integration.requester.RequesterTerminalBlockItem; public class FullEngBlocks { private static final List> BLOCKS = new ArrayList<>(); @@ -53,7 +54,7 @@ public static List> getBlocks() { "ME Requester Terminal", "requester_terminal", RequesterTerminalBlock::new, - RequesterTerminalBlockItem::new); + block -> new IntegrationBlockItem(block, Addons.REQUESTER)); static

BlockDefinition> monitor(ItemDefinition> equivalentPart) { diff --git a/src/main/java/gripe/_90/fulleng/integration/Addons.java b/src/main/java/gripe/_90/fulleng/integration/Addons.java index 98ed461..df243a1 100644 --- a/src/main/java/gripe/_90/fulleng/integration/Addons.java +++ b/src/main/java/gripe/_90/fulleng/integration/Addons.java @@ -1,25 +1,46 @@ package gripe._90.fulleng.integration; +import net.minecraft.ChatFormatting; +import net.minecraft.data.recipes.RecipeOutput; +import net.minecraft.network.chat.Component; import net.neoforged.fml.ModList; import net.neoforged.fml.loading.LoadingModList; import net.neoforged.fml.loading.moddiscovery.ModInfo; +import net.neoforged.neoforge.common.conditions.ModLoadedCondition; + +import gripe._90.fulleng.FullblockEnergistics; public enum Addons { - REQUESTER("merequester"); + REQUESTER("merequester", "ME Requester"); private final String modId; + private final String modName; - Addons(String modId) { + Addons(String modId, String modName) { this.modId = modId; + this.modName = modName; } public String getModId() { return modId; } + public String getModName() { + return modName; + } + public boolean isLoaded() { return ModList.get() != null ? ModList.get().isLoaded(getModId()) : LoadingModList.get().getMods().stream().map(ModInfo::getModId).anyMatch(getModId()::equals); } + + public Component getNotInstalledTooltip() { + return Component.translatable("gui." + FullblockEnergistics.MODID + ".not_installed." + modId) + .withStyle(ChatFormatting.GRAY); + } + + public RecipeOutput conditionalOutput(RecipeOutput output) { + return output.withConditions(new ModLoadedCondition(modId)); + } } diff --git a/src/main/java/gripe/_90/fulleng/integration/IntegrationBlockItem.java b/src/main/java/gripe/_90/fulleng/integration/IntegrationBlockItem.java new file mode 100644 index 0000000..4c9b1cf --- /dev/null +++ b/src/main/java/gripe/_90/fulleng/integration/IntegrationBlockItem.java @@ -0,0 +1,27 @@ +package gripe._90.fulleng.integration; + +import java.util.List; + +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; + +import appeng.block.AEBaseBlockItem; + +public class IntegrationBlockItem extends AEBaseBlockItem { + private final Addons addon; + + public IntegrationBlockItem(Block id, Addons addon) { + super(id, new Properties()); + this.addon = addon; + } + + @Override + public void addCheckedInformation(ItemStack stack, Level level, List lines, TooltipFlag advTooltips) { + if (!addon.isLoaded()) { + lines.add(addon.getNotInstalledTooltip()); + } + } +} diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java index 298c2f3..4508419 100644 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java +++ b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterIntegration.java @@ -1,16 +1,15 @@ package gripe._90.fulleng.integration.requester; +import com.almostreliable.merequester.Registration; import com.almostreliable.merequester.client.RequesterTerminalScreen; -import net.minecraft.network.chat.Component; - +import appeng.core.definitions.ItemDefinition; import appeng.init.client.InitScreens; -import gripe._90.fulleng.FullblockEnergistics; - public final class RequesterIntegration { - public static final Component NOT_INSTALLED = - Component.translatable("gui." + FullblockEnergistics.MODID + ".RequesterNotInstalled"); + static ItemDefinition getRequesterTerminalPart() { + return Registration.REQUESTER_TERMINAL; + } public static void initScreen() { InitScreens.register( diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlock.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlock.java index 0da40ea..17fc2d9 100644 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlock.java +++ b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlock.java @@ -5,14 +5,16 @@ import appeng.core.definitions.AEParts; import gripe._90.fulleng.block.TerminalBlock; +import gripe._90.fulleng.integration.Addons; public class RequesterTerminalBlock extends TerminalBlock { public RequesterTerminalBlock() { - super(AEParts.TERMINAL); + super(Addons.REQUESTER.isLoaded() ? RequesterIntegration.getRequesterTerminalPart() : AEParts.TERMINAL); } + @NotNull @Override - public @NotNull String getDescriptionId() { - return "item.merequester.requester_terminal"; + public String getDescriptionId() { + return "item." + Addons.REQUESTER.getModId() + ".requester_terminal"; } } diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockItem.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockItem.java deleted file mode 100644 index 27c4509..0000000 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockItem.java +++ /dev/null @@ -1,28 +0,0 @@ -package gripe._90.fulleng.integration.requester; - -import java.util.List; - -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; - -import appeng.block.AEBaseBlockItem; -import appeng.core.localization.Tooltips; - -import gripe._90.fulleng.integration.Addons; - -public class RequesterTerminalBlockItem extends AEBaseBlockItem { - public RequesterTerminalBlockItem(Block id) { - super(id, new Item.Properties()); - } - - @Override - public void addCheckedInformation(ItemStack stack, Level level, List tooltip, TooltipFlag flag) { - if (!Addons.REQUESTER.isLoaded()) { - tooltip.add(Tooltips.of(RequesterIntegration.NOT_INSTALLED)); - } - } -} diff --git a/src/main/resources/data/fulleng/advancements/recipes/ae2.main/terminals/block_requester_terminal_from_part.json b/src/main/resources/data/fulleng/advancements/recipes/ae2.main/terminals/block_requester_terminal_from_part.json deleted file mode 100644 index 21f57b2..0000000 --- a/src/main/resources/data/fulleng/advancements/recipes/ae2.main/terminals/block_requester_terminal_from_part.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "criteria": { - "has_terminal": { - "conditions": { - "items": [ - { - "items": ["merequester:requester_terminal"] - } - ] - }, - "trigger": "minecraft:inventory_changed" - }, - "has_the_recipe": { - "conditions": { - "recipe": "fulleng:terminals/block_terminal_from_part" - }, - "trigger": "minecraft:recipe_unlocked" - } - }, - "requirements": [["has_terminal", "has_the_recipe"]], - "rewards": { - "recipes": ["fulleng:terminals/block_terminal_from_part"] - } -} diff --git a/src/main/resources/data/fulleng/advancements/recipes/ae2.main/terminals/part_requester_terminal_from_block.json b/src/main/resources/data/fulleng/advancements/recipes/ae2.main/terminals/part_requester_terminal_from_block.json deleted file mode 100644 index ffb3db5..0000000 --- a/src/main/resources/data/fulleng/advancements/recipes/ae2.main/terminals/part_requester_terminal_from_block.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "criteria": { - "has_terminal": { - "conditions": { - "items": [ - { - "items": ["merequester:requester_terminal"] - } - ] - }, - "trigger": "minecraft:inventory_changed" - }, - "has_the_recipe": { - "conditions": { - "recipe": "fulleng:terminals/part_terminal_from_block" - }, - "trigger": "minecraft:recipe_unlocked" - } - }, - "requirements": [["has_terminal", "has_the_recipe"]], - "rewards": { - "recipes": ["fulleng:terminals/part_terminal_from_block"] - } -} diff --git a/src/main/resources/data/fulleng/recipes/block_requester_terminal_from_part.json b/src/main/resources/data/fulleng/recipes/block_requester_terminal_from_part.json deleted file mode 100644 index ef3744a..0000000 --- a/src/main/resources/data/fulleng/recipes/block_requester_terminal_from_part.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "ingredients": [ - { - "item": "merequester:requester_terminal" - } - ], - "result": { - "item": "fulleng:requester_terminal" - } -} diff --git a/src/main/resources/data/fulleng/recipes/part_requester_terminal_from_block.json b/src/main/resources/data/fulleng/recipes/part_requester_terminal_from_block.json deleted file mode 100644 index 06e9d77..0000000 --- a/src/main/resources/data/fulleng/recipes/part_requester_terminal_from_block.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "ingredients": [ - { - "item": "fulleng:requester_terminal" - } - ], - "result": { - "item": "merequester:requester_terminal" - } -}