Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ dependencies {
shadowImplementation("org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.36.0")

devOnlyNonPublishable("com.github.GTNewHorizons:StructureLib:1.4.43:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.54.158:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.54.194:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.140-GTNH:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-1061-GTNH:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:CarpentersBlocks:3.7.3-GTNH:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:ForgeMultipart:1.7.14:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:WirelessRedstone-CBE:1.7.12:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:Railcraft:9.17.31:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:EnhancedLootBags:1.3.4:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:BetterQuesting:3.8.86-GTNH:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:BetterQuesting:3.8.88-GTNH:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:Angelica:2.2.13:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:TX-Loader:1.9:dev")
devOnlyNonPublishable("curse.maven:cofh-core-69162:2388751")
Expand All @@ -42,12 +42,12 @@ dependencies {
runtimeOnlyNonPublishable("it.unimi.dsi:fastutil:8.5.18")
runtimeOnlyNonPublishable(rfg.deobf("curse.maven:spark-361579:4271867"))

compileOnlyApi("com.github.GTNewHorizons:nei-custom-diagram:1.8.35:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:nei-custom-diagram:1.8.36:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:TinkersConstruct:1.14.112-GTNH:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:Mantle:0.5.4:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:Mobs-Info:0.6.0-GTNH:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:LogisticsPipes:1.5.36-GTNH:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:BuildCraft:7.1.63:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:BuildCraft:7.1.64:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:Translocators:1.4.5:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:SimpleSkinBackport:1.0.3-GTNH:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:OpenComputers:1.12.61-GTNH:dev") { transitive = false }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package com.hfstudio.guidenh.integration;

import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;

import net.minecraft.util.ResourceLocation;

import com.hfstudio.guidenh.client.hotkey.OpenGuideHotkey;
import com.hfstudio.guidenh.guide.scene.snapshot.GuideStructureSnapshotRegistration;
import com.hfstudio.guidenh.integration.ae2.Ae2BlockStatsProvider;
import com.hfstudio.guidenh.integration.ae2.Ae2FakeWorldIntegration;
Expand All @@ -8,6 +15,7 @@
import com.hfstudio.guidenh.integration.api.client.GuideNhClientIntegrationRegistry;
import com.hfstudio.guidenh.integration.bartworks.BartWorksFakeWorldIntegration;
import com.hfstudio.guidenh.integration.betterquesting.BetterQuestingQuestHoverProvider;
import com.hfstudio.guidenh.integration.betterquesting.BqGuidePageLinks;
import com.hfstudio.guidenh.integration.betterquesting.BqGuidePageUriHandler;
import com.hfstudio.guidenh.integration.buildcraft.BuildCraftBlockDisplayProvider;
import com.hfstudio.guidenh.integration.buildcraft.BuildCraftPreviewPrepareContributor;
Expand Down Expand Up @@ -40,6 +48,10 @@
import com.hfstudio.guidenh.integration.structurelib.StructureLibControllerIntegrationRegistry;
import com.hfstudio.guidenh.integration.tinkerconstruct.TinkersConstructPreviewPrepareContributor;

import betterquesting.api2.client.gui.context.QuestHoverRegistry;
import betterquesting.api2.client.gui.context.QuestTooltipRegistry;
import betterquesting.api2.client.gui.panels.content.PanelTextBox;

public class GuideNhClientIntegrationBootstrap {

private GuideNhClientIntegrationBootstrap() {}
Expand Down Expand Up @@ -78,33 +90,28 @@ public static void preInitClient() {

if (Mods.BetterQuesting.isModLoaded()) {
BqGuidePageUriHandler.register();

// TODO: Enable these registrations after BetterQuesting releases the editor and text-box extension APIs.
// TextEditorActionRegistry.register(
// new ResourceLocation("guidenh", "guide_link"),
// new TextEditorMacro("guidenh.compat.bq.insert_guide_link", "[guide] ", "[/guide]"));
// ResourceLocation guidePageInteraction = new ResourceLocation("guidenh", "guide_page");
// PanelTextBox.registerTextProcessor(
// guidePageInteraction,
// text -> BqGuidePageLinks.replaceGuideTags(
// text,
// (target, label) -> PanelTextBox.createInteractiveText(guidePageInteraction, target, label)));
// PanelTextBox.registerTextInteraction(guidePageInteraction, new PanelTextBox.TextInteraction() {
//
// @Override
// public boolean onClick(String target) {
// return BqGuidePageUriHandler.open(BqGuidePageLinks.parsePageSpec(target));
// }
//
// @Override
// public List<String> getTooltip(String target) {
// PageAnchor anchor = BqGuidePageLinks.parsePageSpec(target);
// return anchor != null ? BqGuidePageLinks.getTooltip(anchor) : null;
// }
// });

PanelTextBox.registerTextProcessor(
new ResourceLocation("guidenh", "guide_page_links"),
BqGuidePageLinks::replaceGuideTags);
QuestTooltipRegistry.register((target, tooltip) -> {
if (target instanceof UUID uuid) {
OpenGuideHotkey.appendQuestTooltip(uuid, tooltip);
} else if (target instanceof Entry<?, ?>entry) {
Object key = entry.getKey();
if (key instanceof UUID uuid) {
OpenGuideHotkey.appendQuestTooltip(uuid, tooltip);
}
} else if (target instanceof String s) {
List<String> guideTooltip = BqGuidePageLinks.getTooltip(s);
if (guideTooltip != null) {
tooltip.addAll(guideTooltip);
}
}
});
BetterQuestingQuestHoverProvider hoverProvider = new BetterQuestingQuestHoverProvider();
QuestHoverRegistry.register(hoverProvider);
GuideNhClientIntegrationRegistry.global()
.registerQuestHoverProvider(new BetterQuestingQuestHoverProvider());
.registerQuestHoverProvider(hoverProvider);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hfstudio.guidenh.integration.betterquesting;

import java.util.Map.Entry;
import java.util.UUID;

import org.jetbrains.annotations.Nullable;
Expand All @@ -8,11 +9,26 @@
import com.hfstudio.guidenh.guide.internal.MutableGuide;
import com.hfstudio.guidenh.integration.api.client.QuestHoverProvider;

public class BetterQuestingQuestHoverProvider implements QuestHoverProvider {
import betterquesting.api2.client.gui.context.IQuestHoverListener;

public class BetterQuestingQuestHoverProvider implements QuestHoverProvider, IQuestHoverListener {

@Nullable
private Object currentTarget;

@Override
public @Nullable UUID currentHoveredQuestId() {
return BqCompat.getCurrentHoveredQuestUuid();
if (!(currentTarget instanceof Entry<?, ?>)) {
return null;
}

Object key = ((Entry<?, ?>) currentTarget).getKey();
return key instanceof UUID ? (UUID) key : null;
}

@Override
public void onQuestHoverChanged(@Nullable Object target) {
currentTarget = target;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.hfstudio.guidenh.integration.betterquesting;

import java.util.List;
import java.util.UUID;

import org.jetbrains.annotations.Nullable;

import com.hfstudio.guidenh.guide.GuideBuilder;
import com.hfstudio.guidenh.guide.compiler.TagCompiler;
Expand All @@ -19,9 +16,6 @@
*/
public class BqCompat {

@Nullable
public static volatile UUID currentHoveredQuestUuid;

/**
* Attaches the {@link QuestIndex} to the given guide builder. Safe to call when BQ is
* absent because {@link QuestIndex} only depends on standard library types.
Expand All @@ -39,22 +33,4 @@ public static void appendCompilers(List<TagCompiler> compilers) {
compilers.add(new QuestLinkCompiler());
compilers.add(new QuestCardCompiler());
}

/**
* Returns the UUID of the BetterQuesting quest currently under the mouse cursor in the BQ
* quest line GUI, or {@code null} if no quest is hovered. Updated by the BQ-targeted mixin
* and consumed by the open-guide hotkey handler.
*/
@Nullable
public static UUID getCurrentHoveredQuestUuid() {
return currentHoveredQuestUuid;
}

/**
* Sets the UUID of the BetterQuesting quest currently under the mouse cursor. Intended for
* use by the BQ-targeted mixin only. Pass {@code null} to clear.
*/
public static void setCurrentHoveredQuestUuid(@Nullable UUID uuid) {
currentHoveredQuestUuid = uuid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ public static boolean isGuideUri(@Nullable String url) {

public static List<String> getTooltip(PageAnchor anchor) {
GuidePageLinkTarget target = GuidePageLinkTarget.resolve(anchor);
List<String> tooltip = List.of(
return List.of(
EnumChatFormatting.AQUA + I18n.format("guidenh.compat.bq.open_guide_page"),
EnumChatFormatting.GRAY + target.title());
return tooltip;
EnumChatFormatting.GRAY + target.title(),
EnumChatFormatting.GRAY + I18n.format("betterquesting.tooltip.quest_link.click"));
}

private static String replaceGuideTagsUncached(String text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.jetbrains.annotations.Nullable;

import com.hfstudio.guidenh.guide.scene.level.GuidebookLevel;
import com.hfstudio.guidenh.mixins.late.compat.buildcraft.AccessorTileGenericPipe;

import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.Pipe;
Expand Down Expand Up @@ -36,15 +35,14 @@ public static ItemStack resolveDisplayStack(GuidebookLevel level, Block block, i
return null;
}
TileEntity tile = level.getTileEntity(x, y, z);
if (!isTileGenericPipe(tile)) {
if (!(tile instanceof TileGenericPipe genericPipe)) {
return null;
}
AccessorTileGenericPipe accessor = (AccessorTileGenericPipe) tile;
Pipe<?> pipe = accessor.getPipe();
Pipe<?> pipe = genericPipe.pipe;
if (pipe == null || pipe.item == null) {
return null;
}
return new ItemStack(pipe.item, 1, accessor.invokeGetItemMetadata());
return new ItemStack(pipe.item, 1, genericPipe.getItemMetadata());
}

/**
Expand All @@ -55,17 +53,16 @@ public static ItemStack resolveDisplayStack(GuidebookLevel level, Block block, i
*/
@Optional.Method(modid = "BuildCraft|Transport")
public static void initializePipeRenderState(TileEntity tile) {
if (!isTileGenericPipe(tile)) {
if (!(tile instanceof TileGenericPipe genericPipe)) {
return;
}
AccessorTileGenericPipe accessor = (AccessorTileGenericPipe) tile;
if (accessor.getPipe() == null) {
if (genericPipe.pipe == null) {
return;
}
// Recompute pipeConnectionsBuffer from the current fake-world neighbors, then
// copy the buffer into the PipeRenderState connection matrix.
accessor.invokeComputeConnections();
accessor.invokeRefreshRenderState();
genericPipe.computeConnections();
genericPipe.refreshRenderState();
}

/**
Expand All @@ -78,10 +75,4 @@ public static void prepare(GuidebookLevel level) {
initializePipeRenderState(tile);
}
}

@Optional.Method(modid = "BuildCraft|Transport")
public static boolean isTileGenericPipe(@Nullable TileEntity tile) {
return tile instanceof TileGenericPipe;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.hfstudio.guidenh.guide.scene.level.GuidebookLevel;
import com.hfstudio.guidenh.guide.scene.support.GuideDebugLog;
import com.hfstudio.guidenh.integration.Mods;
import com.hfstudio.guidenh.mixins.late.compat.gregtech.AccessorHatchElementBuilder;

import bartworks.system.material.BWMetaGeneratedBlocks;
import bartworks.system.material.TileEntityMetaGeneratedBlock;
Expand All @@ -36,7 +35,6 @@
import gregtech.api.metatileentity.implementations.MTEMultiBlockBase;
import gregtech.api.structure.error.StructureError;
import gregtech.api.util.GTOreDictUnificator;
import gregtech.api.util.HatchElementBuilder;
import gregtech.common.blocks.ItemMachines;
import gregtech.common.misc.GTStructureChannels;

Expand Down Expand Up @@ -916,49 +914,6 @@ private static boolean isMTEHatchImpl(Object metaTileEntity) {
return metaTileEntity instanceof MTEHatch;
}

public static boolean isHatchElementBuilder(@Nullable Object candidate) {
return Mods.GregTech.isModLoaded() && isHatchElementBuilderImpl(candidate);
}

@Optional.Method(modid = "gregtech_nh")
private static boolean isHatchElementBuilderImpl(Object candidate) {
return candidate instanceof HatchElementBuilder;
}

public static int getHatchBuilderHint(@Nullable Object hatchBuilder) {
if (!isHatchElementBuilder(hatchBuilder)) {
return -1;
}
try {
return getHatchBuilderHintImpl(hatchBuilder);
} catch (Throwable ignored) {
return -1;
}
}

@Optional.Method(modid = "gregtech_nh")
private static int getHatchBuilderHintImpl(Object hatchBuilder) {
return ((AccessorHatchElementBuilder) hatchBuilder).guidenh$getHint();
}

@Nullable
public static ItemStack getStackFormFromMetaTile(@Nullable Object metaTileEntity) {
if (metaTileEntity == null || !Mods.GregTech.isModLoaded()) {
return null;
}
try {
return getStackFormFromMetaTileImpl(metaTileEntity);
} catch (Throwable ignored) {
return null;
}
}

@Optional.Method(modid = "gregtech_nh")
@Nullable
private static ItemStack getStackFormFromMetaTileImpl(Object metaTileEntity) {
return ((IMetaTileEntity) metaTileEntity).getStackForm(1L);
}

public static void logInfoOnce(String key, String message, Object... args) {
if (!GuideDebugLog.isEnabled() || key == null || key.isEmpty() || message == null || message.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.hfstudio.guidenh.guide.internal.util.DisplayScale;
import com.hfstudio.guidenh.guide.scene.support.GuideDebugLog;
import com.hfstudio.guidenh.integration.Mods;
import com.hfstudio.guidenh.mixins.late.compat.neicustomdiagram.AccessorCustomInteractable;

import cpw.mods.fml.common.Optional;

Expand Down Expand Up @@ -198,10 +197,10 @@ private static void renderCustomInteractable(CustomInteractable interactable, Di
int clipY, int clipWidth, int clipHeight) {
if (interactable.drawable() instanceof ComponentLabel componentLabel) {
Point position = interactable.position();
((AccessorCustomInteractable) interactable).getDrawBackground()
interactable.drawBackground()
.accept(position);
renderComponent(componentLabel.component(), position, clipX, clipY, clipWidth, clipHeight);
((AccessorCustomInteractable) interactable).getDrawForeground()
interactable.drawForeground()
.accept(position);
return;
}
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/com/hfstudio/guidenh/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,12 @@ public enum Mixins implements IMixins {
ANGELICA_SCENE_EXPORT(Side.CLIENT, Phase.LATE, Mods.Angelica,
"compat.angelica.MixinVanillaModelMeshesSceneExportCapture"),

BQ_COMPAT(Side.CLIENT, Phase.LATE, Mods.BetterQuesting, "compat.betterquesting.MixinPanelButtonQuest",
"compat.betterquesting.MixinPanelTextBox", "compat.betterquesting.AccessorPanelTextBox"),

GREGTECH_HATCH_BUILDER(Side.CLIENT, Phase.LATE, Mods.GregTech, "compat.gregtech.AccessorHatchElementBuilder",
"compat.gregtech.MixinHatchElementBuilderPreview", "compat.gregtech.MixinHatchElementPlacementPreview"),
GREGTECH_HATCH_BUILDER(Side.CLIENT, Phase.LATE, Mods.GregTech, "compat.gregtech.MixinHatchElementBuilderPreview",
"compat.gregtech.MixinHatchElementPlacementPreview"),

STRUCTURELIB_MINIMUM_HATCHES(Side.CLIENT, Phase.LATE, Mods.StructureLib,
"compat.structurelib.MixinSurvivalBuildStructureWalker"),

BC_TILE_GENERIC_PIPE(Side.CLIENT, Phase.LATE, Mods.BuildCraftTransport,
"compat.buildcraft.AccessorTileGenericPipe"),

NEI_CUSTOM_DIAGRAM(Side.CLIENT, Phase.LATE, Mods.NeiCustomDiagram,
"compat.neicustomdiagram.AccessorCustomInteractable"),

;

private final MixinBuilder builder;
Expand Down

This file was deleted.

Loading