Skip to content

Commit

Permalink
Hide P2P outputs from interface terminal (#241)
Browse files Browse the repository at this point in the history
Co-authored-by: boubou19 <miisterunknown@gmail.com>
  • Loading branch information
Alexdoru and boubou19 authored Nov 17, 2024
1 parent 8b4ab1b commit 8a37e08
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 60 deletions.
9 changes: 6 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.6.45-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-475-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-476-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.8.2:dev')

implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.11.7:dev")
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.11.7:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}

compileOnly("com.github.GTNewHorizons:GTNHLib:0.5.20:dev") { transitive = false }
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.0.3:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.9.17:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.8.22:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.50.68:dev') {
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.50.69:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}

compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
Expand All @@ -19,7 +20,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
Expand All @@ -43,7 +43,6 @@
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.client.gui.IInterfaceTerminalPostUpdate;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
Expand Down Expand Up @@ -846,7 +845,8 @@ private void parsePacketCmd(PacketInterfaceTerminalUpdate.PacketEntry cmd) {
addCmd.name,
addCmd.rows,
addCmd.rowSize,
addCmd.online).setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim, addCmd.side)
addCmd.online,
addCmd.p2pOutput).setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim, addCmd.side)
.setIcons(addCmd.selfRep, addCmd.dispRep).setItems(addCmd.items);
masterList.addEntry(entry);
} else if (cmd instanceof PacketInterfaceTerminalUpdate.PacketRemove) {
Expand Down Expand Up @@ -1148,6 +1148,8 @@ public void refreshVisible() {
String output = GuiInterfaceWireless.this.searchFieldOutputs.getText().toLowerCase();

for (InterfaceWirelessEntry entry : entries) {
if (!entry.online || entry.p2pOutput) continue;

var moleAss = AEApi.instance().definitions().blocks().molecularAssembler().maybeStack(1);
entry.dispY = -9999;
if (onlyMolecularAssemblers
Expand Down Expand Up @@ -1238,13 +1240,14 @@ private class InterfaceWirelessEntry {
int guiHeight;
int dispY = -9999;
boolean online;
boolean p2pOutput;
private Boolean[] brokenRecipes;
int numItems = 0;
/** Should recipe be filtered out/grayed out? */
boolean[] filteredRecipes;
private int hoveredSlotIdx = -1;

InterfaceWirelessEntry(long id, String name, int rows, int rowSize, boolean online) {
InterfaceWirelessEntry(long id, String name, int rows, int rowSize, boolean online, boolean p2pOutput) {
this.id = id;
if (StatCollector.canTranslate(name)) {
this.dispName = StatCollector.translateToLocal(name);
Expand All @@ -1260,6 +1263,7 @@ private class InterfaceWirelessEntry {
this.rows = rows;
this.rowSize = rowSize;
this.online = online;
this.p2pOutput = p2pOutput;
this.optionsButton = new GuiFCImgButton(2, 0, "HIGHLIGHT", "YES");
this.optionsButton.setHalfSize(true);
this.renameButton = new GuiFCImgButton(2, 0, "EDIT", "YES");
Expand Down Expand Up @@ -1378,25 +1382,11 @@ public boolean mouseClicked(int mouseX, int mouseY, int btn) {
blockPos.getDimension(),
ForgeDirection.getOrientation(side)));
} else {
/* View in world */
WorldCoord blockPos2 = new WorldCoord(
(int) mc.thePlayer.posX,
(int) mc.thePlayer.posY,
(int) mc.thePlayer.posZ);
if (mc.theWorld.provider.dimensionId != dim) {
mc.thePlayer.addChatMessage(
new ChatComponentTranslation(PlayerMessages.InterfaceInOtherDim.getName(), dim));
} else {
BlockPosHighlighter.highlightBlock(
blockPos,
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
mc.thePlayer.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceHighlighted.getName(),
blockPos.x,
blockPos.y,
blockPos.z));
}
BlockPosHighlighter.highlightBlocks(
mc.thePlayer,
Collections.singletonList(blockPos),
PlayerMessages.InterfaceHighlighted.getName(),
PlayerMessages.InterfaceInOtherDim.getName());
mc.thePlayer.closeScreen();
}
return true;
Expand Down
46 changes: 12 additions & 34 deletions src/main/java/com/glodblock/github/client/gui/GuiLevelTerminal.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
Expand All @@ -34,7 +35,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -65,7 +65,6 @@
import appeng.api.config.YesNo;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.WorldCoord;
import appeng.client.gui.IGuiTooltipHandler;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
Expand Down Expand Up @@ -1327,8 +1326,6 @@ public AppEngInternalInventory getInventory() {
}

public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) {
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;

if (!section.visible || mouseButton < 0 || mouseButton > 2) {
return false;
}
Expand All @@ -1343,7 +1340,7 @@ public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) {
dim,
ForgeDirection.getOrientation(side),
"");
if (isCtrlKeyDown() && isShiftKeyDown() && hasInfinityBoosterCard(player)) {
if (isCtrlKeyDown() && isShiftKeyDown() && hasInfinityBoosterCard(mc.thePlayer)) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelTerminalCommands(
Action.EDIT,
Expand All @@ -1361,23 +1358,12 @@ public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) {
blockPos.getDimension(),
blockPos.getSide()));
} else {
/* View in world */
WorldCoord blockPos2 = new WorldCoord((int) player.posX, (int) player.posY, (int) player.posZ);
if (mc.theWorld.provider.dimensionId != dim) {
player.addChatMessage(
new ChatComponentTranslation(PlayerMessages.InterfaceInOtherDim.getName(), dim));
} else {
BlockPosHighlighter.highlightBlock(
blockPos,
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
player.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceHighlighted.getName(),
blockPos.x,
blockPos.y,
blockPos.z));
}
player.closeScreen();
BlockPosHighlighter.highlightBlocks(
mc.thePlayer,
Collections.singletonList(blockPos),
PlayerMessages.LevelEmitterHighlighted.getName(),
PlayerMessages.LevelEmitterInAnotherDim.getName());
mc.thePlayer.closeScreen();
}
return true;
}
Expand All @@ -1393,25 +1379,17 @@ public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) {

// send packet to server, request an update
InventoryAction action = switch (mouseButton) {
case 0 -> {
// pickup / set-down.
yield null;
}
case 1 -> {
yield null;
}
case 0 -> null; // pickup / set-down.
case 1 -> null;
case 2 -> {
// creative dupe:
if (player.capabilities.isCreativeMode) {
if (mc.thePlayer.capabilities.isCreativeMode) {
yield InventoryAction.CREATIVE_DUPLICATE;
} else {
yield InventoryAction.AUTO_CRAFT;
}
}
default -> {
// drop item:
yield null;
}
default -> null;// drop item:
};

if (action != null) {
Expand Down

0 comments on commit 8a37e08

Please sign in to comment.