diff --git a/gradle.properties b/gradle.properties index a36d244b9..f14180c72 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,19 +11,13 @@ artifact_basename=appliedenergistics2 minecraft_release=1.15 minecraft_version=1.15.2 mcp_mappings=20200613-1.15.1 -forge_version=31.2.19 +forge_version=31.2.20 ######################################################### # Provided APIs # ######################################################### jei_version=6.0.0.4 -tesla_version=1.0.63 -ic2_version=2.8.73-ex112 -top_version=2.0.2-4 -cofhcore_version=1.12.2-4.5.2.19 -crafttweaker_version=4.1.8.9 -inventorytweaks_version=1.63 -ctm_version=MC1.12.2-0.3.1.16 +top_version=2.0.4-5 hwyla_version=1.10.8-B72_1.15.2 ######################################################### @@ -32,4 +26,8 @@ hwyla_version=1.10.8-B72_1.15.2 website_version=1.15.2 curse_versions=1.15.2 +######################################################### +# Gradle # +######################################################### +# Various tasks like runData will fail when run as daemon org.gradle.daemon=false diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index 54e21c02f..af49744d6 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -75,12 +75,11 @@ dependencies { // compile against provided APIs compileOnly "mezz.jei:jei-${minecraft_version}:${jei_version}:api" - //compileOnly "net.darkhax.tesla:Tesla-1.12.2:${tesla_version}" - //compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api" compileOnly "mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}:api" // Runtime, Mods runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") + runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}") // unit test dependencies testCompile "junit:junit:4.13" diff --git a/src/main/java/appeng/core/AppEng.java b/src/main/java/appeng/core/AppEng.java index 9674ce445..6e409c153 100644 --- a/src/main/java/appeng/core/AppEng.java +++ b/src/main/java/appeng/core/AppEng.java @@ -79,6 +79,7 @@ import appeng.core.sync.network.NetworkHandler; import appeng.core.worlddata.WorldData; import appeng.entity.*; import appeng.hooks.TickHandler; +import appeng.integration.Integrations; import appeng.parts.PartPlacement; import appeng.parts.automation.PlaneModelLoader; import appeng.server.ServerHelper; @@ -143,6 +144,8 @@ public final class AppEng { modEventBus.addListener(registration::registerTextures); modEventBus.addListener(registration::registerCommands); + modEventBus.addListener(Integrations::enqueueIMC); + modEventBus.addListener(this::commonSetup); // Register client-only events diff --git a/src/main/java/appeng/integration/Integrations.java b/src/main/java/appeng/integration/Integrations.java new file mode 100644 index 000000000..8f3d87caf --- /dev/null +++ b/src/main/java/appeng/integration/Integrations.java @@ -0,0 +1,30 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2020, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration; + +import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; + +import appeng.integration.modules.theoneprobe.TheOneProbeModule; + +public class Integrations { + + public static void enqueueIMC(final InterModEnqueueEvent event) { + TheOneProbeModule.enqueueIMC(event); + } +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/PartInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/PartInfoProvider.java new file mode 100644 index 000000000..cb0c8a6c0 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/PartInfoProvider.java @@ -0,0 +1,79 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe; + +import java.util.List; +import java.util.Optional; + +import com.google.common.collect.Lists; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.parts.IPart; +import appeng.core.AppEng; +import appeng.integration.modules.theoneprobe.part.ChannelInfoProvider; +import appeng.integration.modules.theoneprobe.part.IPartProbInfoProvider; +import appeng.integration.modules.theoneprobe.part.P2PStateInfoProvider; +import appeng.integration.modules.theoneprobe.part.PartAccessor; +import appeng.integration.modules.theoneprobe.part.PowerStateInfoProvider; +import appeng.integration.modules.theoneprobe.part.StorageMonitorInfoProvider; + +public final class PartInfoProvider implements IProbeInfoProvider { + private final List providers; + + private final PartAccessor accessor = new PartAccessor(); + + public PartInfoProvider() { + final IPartProbInfoProvider channel = new ChannelInfoProvider(); + final IPartProbInfoProvider power = new PowerStateInfoProvider(); + final IPartProbInfoProvider storageMonitor = new StorageMonitorInfoProvider(); + final IPartProbInfoProvider p2p = new P2PStateInfoProvider(); + + this.providers = Lists.newArrayList(channel, power, p2p, storageMonitor); + } + + @Override + public String getID() { + return AppEng.MOD_ID + ":PartInfoProvider"; + } + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + final TileEntity te = world.getTileEntity(data.getPos()); + final Optional maybePart = this.accessor.getMaybePart(te, data); + + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); + + for (final IPartProbInfoProvider provider : this.providers) { + provider.addProbeInfo(part, mode, probeInfo, player, world, blockState, data); + } + } + + } +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeModule.java b/src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeModule.java new file mode 100644 index 000000000..ac83cda28 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeModule.java @@ -0,0 +1,45 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe; + +import java.util.function.Function; + +import net.minecraftforge.fml.InterModComms; +import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; + +import mcjty.theoneprobe.api.ITheOneProbe; + +import appeng.integration.IIntegrationModule; +import appeng.integration.modules.theoneprobe.config.AEConfigProvider; + +public class TheOneProbeModule implements IIntegrationModule, Function { + + public static void enqueueIMC(final InterModEnqueueEvent event) { + InterModComms.sendTo("theoneprobe", "getTheOneProbe", TheOneProbeModule::new); + } + + @Override + public Void apply(ITheOneProbe input) { + input.registerProbeConfigProvider(new AEConfigProvider()); + input.registerProvider(new TileInfoProvider()); + input.registerProvider(new PartInfoProvider()); + + return null; + } +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeText.java b/src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeText.java new file mode 100644 index 000000000..d68e12753 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeText.java @@ -0,0 +1,47 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe; + +import java.util.Locale; + +import net.minecraft.util.text.TranslationTextComponent; + +public enum TheOneProbeText { + CRAFTING, DEVICE_ONLINE, DEVICE_OFFLINE, DEVICE_MISSING_CHANNEL, P2P_UNLINKED, P2P_INPUT_ONE_OUTPUT, + P2P_INPUT_MANY_OUTPUTS, P2P_OUTPUT, P2P_FREQUENCY, LOCKED, UNLOCKED, SHOWING, CONTAINS, CHANNELS, STORED_ENERGY; + + private final String root; + + TheOneProbeText() { + this.root = "theoneprobe.appliedenergistics2"; + } + + public String getTranslationString(Object... args) { + return getTranslationComponent(args).getFormattedText(); + } + + public TranslationTextComponent getTranslationComponent(Object... args) { + return new TranslationTextComponent(this.getUnlocalized(), args); + } + + public String getUnlocalized() { + return this.root + '.' + this.name().toLowerCase(Locale.ENGLISH); + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/TileInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/TileInfoProvider.java new file mode 100644 index 000000000..815a3ac1f --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/TileInfoProvider.java @@ -0,0 +1,73 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe; + +import java.util.List; + +import com.google.common.collect.Lists; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.core.AppEng; +import appeng.integration.modules.theoneprobe.tile.ChargerInfoProvider; +import appeng.integration.modules.theoneprobe.tile.CraftingMonitorInfoProvider; +import appeng.integration.modules.theoneprobe.tile.ITileProbInfoProvider; +import appeng.integration.modules.theoneprobe.tile.PowerStateInfoProvider; +import appeng.integration.modules.theoneprobe.tile.PowerStorageInfoProvider; +import appeng.tile.AEBaseTile; + +public final class TileInfoProvider implements IProbeInfoProvider { + private final List providers; + + public TileInfoProvider() { + final ITileProbInfoProvider charger = new ChargerInfoProvider(); + final ITileProbInfoProvider energyCell = new CraftingMonitorInfoProvider(); + final ITileProbInfoProvider craftingBlock = new PowerStateInfoProvider(); + final ITileProbInfoProvider craftingMonitor = new PowerStorageInfoProvider(); + + this.providers = Lists.newArrayList(charger, energyCell, craftingBlock, craftingMonitor); + } + + @Override + public String getID() { + return AppEng.MOD_ID + ":TileInfoProvider"; + } + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + final TileEntity tile = world.getTileEntity(data.getPos()); + + if (tile instanceof AEBaseTile) { + final AEBaseTile aeBaseTile = (AEBaseTile) tile; + + for (final ITileProbInfoProvider provider : this.providers) { + provider.addProbeInfo(aeBaseTile, mode, probeInfo, player, world, blockState, data); + } + } + } +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/config/AEConfigProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/config/AEConfigProvider.java new file mode 100644 index 000000000..a38191d7d --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/config/AEConfigProvider.java @@ -0,0 +1,49 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.config; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeConfig; +import mcjty.theoneprobe.api.IProbeConfigProvider; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeHitEntityData; + +import appeng.tile.AEBaseTile; + +public class AEConfigProvider implements IProbeConfigProvider { + + @Override + public void getProbeConfig(IProbeConfig config, PlayerEntity player, World world, Entity entity, + IProbeHitEntityData data) { + // Still no AE entities. + } + + @Override + public void getProbeConfig(IProbeConfig config, PlayerEntity player, World world, BlockState blockState, + IProbeHitData data) { + if (world.getTileEntity(data.getPos()) instanceof AEBaseTile) { + config.setRFMode(0); + } + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java new file mode 100644 index 000000000..ff574868f --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java @@ -0,0 +1,60 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.part; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.parts.IPart; +import appeng.integration.modules.theoneprobe.TheOneProbeText; +import appeng.parts.networking.PartCableSmart; +import appeng.parts.networking.PartDenseCableSmart; + +public class ChannelInfoProvider implements IPartProbInfoProvider { + + @Override + public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + if (part instanceof PartDenseCableSmart || part instanceof PartCableSmart) { + final int usedChannels; + final int maxChannels = (part instanceof PartDenseCableSmart) ? 32 : 8; + + if (part.getGridNode().isActive()) { + final CompoundNBT tmp = new CompoundNBT(); + part.writeToNBT(tmp); + usedChannels = tmp.getByte("usedChannels"); + } else { + usedChannels = 0; + } + + final String formattedChannelString = TheOneProbeText.CHANNELS.getTranslationString(usedChannels, + maxChannels); + + probeInfo.text(formattedChannelString); + } + + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/part/IPartProbInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/part/IPartProbInfoProvider.java new file mode 100644 index 000000000..2c40599d4 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/part/IPartProbInfoProvider.java @@ -0,0 +1,45 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.part; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.parts.IPart; + +/** + * Similar to {@link IProbeInfoProvider}, but already providing the + * {@link IPart} being looked at. + * + */ +public interface IPartProbInfoProvider { + + /** + * @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, + * World, IBlockState, IProbeHitData) + */ + void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data); +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/part/P2PStateInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/part/P2PStateInfoProvider.java new file mode 100644 index 000000000..7c60e64b6 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/part/P2PStateInfoProvider.java @@ -0,0 +1,106 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.part; + +import com.google.common.collect.Iterators; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.parts.IPart; +import appeng.integration.modules.theoneprobe.TheOneProbeText; +import appeng.me.GridAccessException; +import appeng.parts.p2p.PartP2PTunnel; +import appeng.util.Platform; + +public class P2PStateInfoProvider implements IPartProbInfoProvider { + + private static final int STATE_UNLINKED = 0; + private static final int STATE_OUTPUT = 1; + private static final int STATE_INPUT = 2; + + @Override + public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + if (part instanceof PartP2PTunnel) { + final PartP2PTunnel tunnel = (PartP2PTunnel) part; + + if (!tunnel.isPowered()) { + return; + } + + // The default state + int state = STATE_UNLINKED; + int outputCount = 0; + + if (!tunnel.isOutput()) { + outputCount = getOutputCount(tunnel); + if (outputCount > 0) { + // Only set it to INPUT if we know there are any outputs + state = STATE_INPUT; + } + } else { + final PartP2PTunnel input = tunnel.getInput(); + if (input != null) { + state = STATE_OUTPUT; + } + } + + switch (state) { + case STATE_UNLINKED: + probeInfo.text(TheOneProbeText.P2P_UNLINKED.getTranslationString()); + break; + case STATE_OUTPUT: + probeInfo.text(TheOneProbeText.P2P_OUTPUT.getTranslationString()); + break; + case STATE_INPUT: + probeInfo.text(getOutputText(outputCount)); + break; + } + + final short freq = tunnel.getFrequency(); + final String freqTooltip = Platform.p2p().toHexString(freq); + + probeInfo.text(freqTooltip); + } + } + + private static int getOutputCount(PartP2PTunnel tunnel) { + try { + return Iterators.size(tunnel.getOutputs().iterator()); + } catch (GridAccessException e) { + // Well... unknown size it is! + return 0; + } + } + + private static String getOutputText(int outputs) { + if (outputs <= 1) { + return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getTranslationString(); + } else { + return TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getTranslationString(outputs); + } + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/part/PartAccessor.java b/src/main/java/appeng/integration/modules/theoneprobe/part/PartAccessor.java new file mode 100644 index 000000000..c717940fd --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/part/PartAccessor.java @@ -0,0 +1,49 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.part; + +import java.util.Optional; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +import mcjty.theoneprobe.api.IProbeHitData; + +import appeng.api.parts.IPart; +import appeng.api.parts.IPartHost; +import appeng.api.parts.SelectedPart; + +public final class PartAccessor { + + public Optional getMaybePart(final TileEntity te, final IProbeHitData data) { + if (te instanceof IPartHost) { + BlockPos pos = data.getPos(); + final Vec3d position = data.getHitVec().add(-pos.getX(), -pos.getY(), -pos.getZ()); + final IPartHost host = (IPartHost) te; + final SelectedPart sp = host.selectPart(position); + + if (sp.part != null) { + return Optional.of(sp.part); + } + } + + return Optional.empty(); + } +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/part/PowerStateInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/part/PowerStateInfoProvider.java new file mode 100644 index 000000000..119af8f74 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/part/PowerStateInfoProvider.java @@ -0,0 +1,61 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.part; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.implementations.IPowerChannelState; +import appeng.api.parts.IPart; +import appeng.integration.modules.theoneprobe.TheOneProbeText; + +public class PowerStateInfoProvider implements IPartProbInfoProvider { + + @Override + public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + if (part instanceof IPowerChannelState) { + final IPowerChannelState state = (IPowerChannelState) part; + final String tooltip = this.getToolTip(state.isActive(), state.isPowered()); + + probeInfo.text(tooltip); + } + + } + + private String getToolTip(final boolean isActive, final boolean isPowered) { + final String result; + + if (isActive && isPowered) { + result = TheOneProbeText.DEVICE_ONLINE.getTranslationString(); + } else if (isPowered) { + result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getTranslationString(); + } else { + result = TheOneProbeText.DEVICE_OFFLINE.getTranslationString(); + } + + return result; + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/part/StorageMonitorInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/part/StorageMonitorInfoProvider.java new file mode 100644 index 000000000..359a4bd5d --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/part/StorageMonitorInfoProvider.java @@ -0,0 +1,66 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.part; + +import net.minecraft.block.BlockState; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.implementations.parts.IPartStorageMonitor; +import appeng.api.parts.IPart; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IAEStack; +import appeng.integration.modules.theoneprobe.TheOneProbeText; + +public class StorageMonitorInfoProvider implements IPartProbInfoProvider { + + @Override + public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + if (part instanceof IPartStorageMonitor) { + final IPartStorageMonitor monitor = (IPartStorageMonitor) part; + + final IAEStack displayed = monitor.getDisplayed(); + final boolean isLocked = monitor.isLocked(); + + // TODO: generalize + if (displayed instanceof IAEItemStack) { + final IAEItemStack ais = (IAEItemStack) displayed; + probeInfo.text(TheOneProbeText.SHOWING.getTranslationComponent() + ": " + + ais.asItemStackRepresentation().getDisplayName()); + } else if (displayed instanceof IAEFluidStack) { + final IAEFluidStack ais = (IAEFluidStack) displayed; + final String fluidName = I18n.format(ais.getFluidStack().getTranslationKey()); + final String text = TheOneProbeText.SHOWING.getTranslationComponent() + ": " + fluidName; + + probeInfo.text(text); + } + + probeInfo.text(isLocked ? TheOneProbeText.LOCKED.getTranslationString() + : TheOneProbeText.UNLOCKED.getTranslationString()); + } + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/tile/ChargerInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/tile/ChargerInfoProvider.java new file mode 100644 index 000000000..510627969 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/tile/ChargerInfoProvider.java @@ -0,0 +1,56 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.tile; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.items.IItemHandler; + +import mcjty.theoneprobe.api.ElementAlignment; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.tile.AEBaseTile; +import appeng.tile.misc.TileCharger; + +public class ChargerInfoProvider implements ITileProbInfoProvider { + + @Override + public void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + if (tile instanceof TileCharger) { + final TileCharger charger = (TileCharger) tile; + final IItemHandler chargerInventory = charger.getInternalInventory(); + final ItemStack chargingItem = chargerInventory.getStackInSlot(0); + + if (!chargingItem.isEmpty()) { + final String currentInventory = chargingItem.getDisplayName().getString(); + final IProbeInfo centerAlignedHorizontalLayout = probeInfo + .horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)); + + centerAlignedHorizontalLayout.item(chargingItem); + centerAlignedHorizontalLayout.text(currentInventory); + } + } + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/tile/CraftingMonitorInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/tile/CraftingMonitorInfoProvider.java new file mode 100644 index 000000000..2506ae152 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/tile/CraftingMonitorInfoProvider.java @@ -0,0 +1,61 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.tile; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.ElementAlignment; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.storage.data.IAEItemStack; +import appeng.integration.modules.theoneprobe.TheOneProbeText; +import appeng.tile.AEBaseTile; +import appeng.tile.crafting.TileCraftingMonitorTile; + +public class CraftingMonitorInfoProvider implements ITileProbInfoProvider { + + @Override + public void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + if (tile instanceof TileCraftingMonitorTile) { + final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) tile; + final IAEItemStack displayStack = monitor.getJobProgress(); + + if (displayStack != null) { + // TODO: check if OK + final ItemStack itemStack = displayStack.asItemStackRepresentation(); + final String itemName = itemStack.getDisplayName().getString(); + final String formattedCrafting = TheOneProbeText.CRAFTING.getTranslationComponent(itemName) + .getFormattedText(); + + final IProbeInfo centerAlignedHorizontalLayout = probeInfo + .horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)); + + centerAlignedHorizontalLayout.item(itemStack); + centerAlignedHorizontalLayout.text(formattedCrafting); + } + } + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/tile/ITileProbInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/tile/ITileProbInfoProvider.java new file mode 100644 index 000000000..380883c17 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/tile/ITileProbInfoProvider.java @@ -0,0 +1,45 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.tile; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.tile.AEBaseTile; + +/** + * Similar to {@link IProbeInfoProvider}, but already providing the + * {@link AEBaseTile} being looked at. + * + */ +public interface ITileProbInfoProvider { + + /** + * @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, + * World, IBlockState, IProbeHitData) + */ + void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data); +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/tile/PowerStateInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/tile/PowerStateInfoProvider.java new file mode 100644 index 000000000..06c82ce07 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/tile/PowerStateInfoProvider.java @@ -0,0 +1,55 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.tile; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.implementations.IPowerChannelState; +import appeng.integration.modules.theoneprobe.TheOneProbeText; +import appeng.tile.AEBaseTile; + +public class PowerStateInfoProvider implements ITileProbInfoProvider { + + @Override + public void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + if (tile instanceof IPowerChannelState) { + final IPowerChannelState state = (IPowerChannelState) tile; + + final boolean isActive = state.isActive(); + final boolean isPowered = state.isPowered(); + + if (isActive && isPowered) { + probeInfo.text(TheOneProbeText.DEVICE_ONLINE.getTranslationString()); + } else if (isPowered) { + probeInfo.text(TheOneProbeText.DEVICE_MISSING_CHANNEL.getTranslationString()); + } else { + probeInfo.text(TheOneProbeText.DEVICE_OFFLINE.getTranslationString()); + } + } + + } + +} diff --git a/src/main/java/appeng/integration/modules/theoneprobe/tile/PowerStorageInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/tile/PowerStorageInfoProvider.java new file mode 100644 index 000000000..43b752d40 --- /dev/null +++ b/src/main/java/appeng/integration/modules/theoneprobe/tile/PowerStorageInfoProvider.java @@ -0,0 +1,61 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.theoneprobe.tile; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.ProbeMode; + +import appeng.api.networking.energy.IAEPowerStorage; +import appeng.integration.modules.theoneprobe.TheOneProbeText; +import appeng.tile.AEBaseTile; +import appeng.util.Platform; + +public class PowerStorageInfoProvider implements ITileProbInfoProvider { + + @Override + public void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world, + BlockState blockState, IProbeHitData data) { + if (tile instanceof IAEPowerStorage) { + final IAEPowerStorage storage = (IAEPowerStorage) tile; + final double maxPower = storage.getAEMaxPower(); + + if (maxPower > 0) { + final long internalCurrentPower = (long) (storage.getAECurrentPower() * 100); + + if (internalCurrentPower >= 0) { + final long internalMaxPower = (long) (100 * maxPower); + + final String formatCurrentPower = Platform.formatPowerLong(internalCurrentPower, false); + final String formatMaxPower = Platform.formatPowerLong(internalMaxPower, false); + final String formattedString = TheOneProbeText.STORED_ENERGY + .getTranslationComponent(formatCurrentPower, formatMaxPower).getFormattedText(); + + probeInfo.text(formattedString); + } + } + } + + } + +} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index ec1800132..699a80cd3 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,53 +1,21 @@ -# There are several mandatory fields (#mandatory), and many more that are optional (#optional). -# The overall format is standard TOML format, v0.5.0. -# Note that there are a couple of TOML lists in this file. -# Find more information on toml format here: https://github.com/toml-lang/toml - -# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml -modLoader="javafml" #mandatory - -# A version range to match for said mod loader - for regular FML @Mod it will be the minecraft version (without the 1.) -loaderVersion="[31,)" #mandatory - -# A URL to query for updates for this mod. See the JSON update specification -#updateJSONURL="" #optional - -# A URL to refer people to when problems occur with this mod -issueTrackerURL="https://github.com/AppliedEnergistics/Applied-Energistics-2/issues" #optional - -# A URL for the "homepage" for this mod, displayed in the mod UI -displayURL="https://github.com/AppliedEnergistics/Applied-Energistics-2" #optional - -# A file name (in the root of the mod JAR) containing a logo for display +modLoader="javafml" +loaderVersion="[31,)" +#updateJSONURL="" +issueTrackerURL="https://github.com/AppliedEnergistics/Applied-Energistics-2/issues" +displayURL="https://github.com/AppliedEnergistics/Applied-Energistics-2" logoFile="logo.png" +#credits="Thanks for this example mod goes to Java" +authors="TeamAppliedEnergistics" -# A text field displayed in the mod UI -#credits="Thanks for this example mod goes to Java" #optional - -# A text field displayed in the mod UI -authors="TeamAppliedEnergistics" #optional - -# A list of mods - how many allowed here is determined by the individual mod loader -[[mods]] #mandatory - -# The modid of the mod -modId="appliedenergistics2" #mandatory - -# The version number of the mod -version="${file.jarVersion}" #mandatory - -# A display name for the mod -displayName="Applied Energistics 2" #mandatory - -# The description text for the mod (multi line!) (#mandatory) +[[mods]] +modId="appliedenergistics2" +version="${file.jarVersion}" +displayName="Applied Energistics 2" description="A Mod about Matter, Energy and using them to conquer the world.." -# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. [[dependencies.jei]] - modId="forge" #mandatory - mandatory=true #mandatory - versionRange="[31.0.0,)" #mandatory - # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory + modId="forge" + mandatory=true + versionRange="[31.0.0,)" ordering="NONE" - # Side this dependency is applied on - BOTH, CLIENT or SERVER side="BOTH" \ No newline at end of file