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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package github.kasuminova.mmce.common.integration.theoneprobe;

import appeng.api.implementations.IPowerChannelState;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
import github.kasuminova.mmce.common.tile.base.MEMachineComponent;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.IProbeInfoProvider;
import mcjty.theoneprobe.api.ProbeMode;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class MachineryHatchInfoProvider implements IProbeInfoProvider {
@Override
public String getID() {
return "modularmachinery:machinery_hatch_info_provider";
}

@Override
public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, EntityPlayer entityPlayer, World world, IBlockState iBlockState, IProbeHitData iProbeHitData) {
if (!iBlockState.getBlock().hasTileEntity(iBlockState)) {
return;
}
TileEntity tileEntity = world.getTileEntity(iProbeHitData.getPos());
if (!(tileEntity instanceof MEMachineComponent meHatch)) {
return;
}

// Implementation taken from appeng.integration.modules.theoneprobe.PartInfoProvider
final IPowerChannelState state = meHatch;

final boolean isActive = state.isActive();
final boolean isPowered = state.isPowered();

if (isActive && isPowered) {
iProbeInfo.text(TheOneProbeText.DEVICE_ONLINE.getLocal());
} else if (isPowered) {
iProbeInfo.text(TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal());
} else {
iProbeInfo.text(TheOneProbeText.DEVICE_OFFLINE.getLocal());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package github.kasuminova.mmce.common.tile.base;

import appeng.api.implementations.IPowerChannelState;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
Expand All @@ -24,7 +25,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public abstract class MEMachineComponent extends TileColorableMachineComponent implements SelectiveUpdateTileEntity, MachineComponentTile, IActionHost, IGridProxyable {
public abstract class MEMachineComponent extends TileColorableMachineComponent implements SelectiveUpdateTileEntity, MachineComponentTile, IActionHost, IGridProxyable, IPowerChannelState {

protected final AENetworkProxy proxy = new AENetworkProxy(this, "aeProxy", getVisualItemStack(), true);
protected final IActionSource source;
Expand Down Expand Up @@ -132,4 +133,13 @@ public void validate() {
Sides.SERVER.runIfPresent(() -> ModularMachinery.EXECUTE_MANAGER.addSyncTask(proxy::onReady));
}

@Override
public boolean isPowered() {
return proxy.isPowered();
}

@Override
public boolean isActive() {
return proxy.isActive();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void init() {
IntegrationTypeHelper.filterModIdRequirementTypes();

if (Mods.TOP.isPresent()) {
ModIntegrationTOP.registerProvider();
ModIntegrationTOP.registerProviders();
ModularMachinery.log.info("[ModularMachinery-CE] TheOneProbe integration is enabled! Stop looking at the dark controller gui!");
}
if (Mods.GREGTECHCEU.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package hellfirepvp.modularmachinery.common.integration;

import github.kasuminova.mmce.common.integration.theoneprobe.MachineryHatchInfoProvider;
import hellfirepvp.modularmachinery.common.integration.theoneprobe.MMInfoProvider;
import mcjty.theoneprobe.TheOneProbe;
import mcjty.theoneprobe.apiimpl.TheOneProbeImp;
Expand All @@ -16,10 +17,11 @@ public class ModIntegrationTOP {
public static boolean showRecipeProgressBarDecimalPoints = true;
public static boolean showParallelControllerInfo = true;

public static void registerProvider() {
public static void registerProviders() {
TheOneProbeImp top = TheOneProbe.theOneProbeImp;

top.registerProvider(new MMInfoProvider());
top.registerProvider(new MachineryHatchInfoProvider());
}

public static void loadFromConfig(Configuration cfg) {
Expand Down
Loading