Disable ability to use copy outputs when output selected

Because it doesn't work, and has strange behavior, this is being disabled
for now (possibly forever).
This commit is contained in:
Firenoo committed 2023-05-10 22:34:31 -07:00
1 parent ba11840e1c
commit 551dc07dbf
6 files changed
+40 -14

No files matched your search

@@ -3,10 +3,8 @@ package com.projecturanus.betterp2p.client.gui.widget
import com.projecturanus.betterp2p.client.gui.*
import com.projecturanus.betterp2p.item.BetterMemoryCardModes
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.renderer.OpenGlHelper
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.resources.I18n
import net.minecraft.util.IIcon
import org.lwjgl.opengl.GL11
import kotlin.reflect.KProperty0
@@ -81,7 +79,8 @@ class WidgetP2PDevice(private val selectedInfoProperty: KProperty0<InfoWrapper?>
}
val mode = modeSupplier()
if (mode == BetterMemoryCardModes.COPY && !info.output && info.frequency != 0.toLong()) {
if (mode == BetterMemoryCardModes.COPY && (!info.output && info.frequency != 0.toLong()) ||
selectedInfo?.output == true) {
info.bindButton.enabled = false
}
drawButtons(gui, info, mouseX, mouseY, partialTicks)
@@ -30,6 +30,7 @@ enum class BetterMemoryCardModes(val unlocalizedName: String, vararg val unlocal
"gui.advanced_memory_card.mode.copy.desc.1",
"gui.advanced_memory_card.mode.copy.desc.2",
"gui.advanced_memory_card.mode.copy.desc.3",
"gui.advanced_memory_card.mode.copy.desc.4",
);
fun next(): BetterMemoryCardModes {
@@ -83,7 +83,14 @@ object ItemAdvancedMemoryCard : Item() {
info.selectedEntry = hashP2P(part)
} else {
type = TUNNEL_ANY
status = P2PStatus(te.getGridNode(ForgeDirection.getOrientation(side)).grid, player, type)
if (part != null) {
// If we have a PartP2PTunnelME, it looks at the P2P grid node,
// so we should use the part instead.
status = P2PStatus(part.gridNode.grid, player, type)
} else {
// Fall back to the tile entity.
status = P2PStatus(te.getGridNode(ForgeDirection.getOrientation(side)).grid, player, type)
}
info.selectedEntry = NONE_SELECTED
}
info.type = type
@@ -15,9 +15,7 @@ class ServerLinkP2PHandler : IMessageHandler<C2SLinkP2P, IMessage?> {
if (result != null) {
status.listP2P[message.input] = result.first
status.listP2P[message.output] = result.second
ModNetwork.channel.sendTo(
S2CRefreshInfo(status.listP2P.values.map { it.toInfo() }),
ctx.serverHandler.playerEntity)
return S2CRefreshInfo(status.refresh(status.lastP2PType).map { it.toInfo() })
}
return null
}
@@ -7,6 +7,7 @@ import appeng.api.parts.IPart
import appeng.api.parts.PartItemStack
import appeng.me.GridAccessException
import appeng.me.GridNode
import appeng.me.cache.P2PCache
import appeng.parts.automation.UpgradeInventory
import appeng.parts.p2p.PartP2PInterface
import appeng.parts.p2p.PartP2PTunnel
@@ -23,7 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection
fun linkP2P(player: EntityPlayer, inputIndex: Long, outputIndex: Long, status: P2PStatus) : Pair<PartP2PTunnel<*>, PartP2PTunnel<*>>? {
// If these calls mess up we have bigger problems...
val input = status.listP2P[inputIndex]!!
val output = status.listP2P[outputIndex]!!
var output = status.listP2P[outputIndex]!!
val grid: IGrid? = input.gridNode?.grid
if (grid is ISecurityGrid) {
@@ -34,8 +35,27 @@ fun linkP2P(player: EntityPlayer, inputIndex: Long, outputIndex: Long, status: P
// TODO Change to exception
if (input.javaClass != output.javaClass) {
// Cannot pair two different type of P2P
return null
//change output to input
val host = output.host
host.removePart(output.side, false)
val dir = host.addPart(input.getItemStack(PartItemStack.Wrench), output.side, player)
val newPart = host.getPart(dir)
if (newPart is PartP2PTunnel<*>) {
newPart.outputProperty = true
newPart.onTunnelNetworkChange()
try {
val p2p: P2PCache = newPart.proxy.p2P
p2p.updateFreq(newPart, output.frequency)
output = newPart
} catch (e: GridAccessException) {
// :P
}
println("part changed")
} else {
// error
return null
}
}
if (input == output) {
// Network loop
@@ -21,10 +21,11 @@ gui.advanced_memory_card.mode.output=Current Mode: Bind to §6Output
gui.advanced_memory_card.mode.output.desc.1=• Before binding, the §aselected §aP2P §7and §bbind §btarget §7have their connections removed.
gui.advanced_memory_card.mode.output.desc.2=• The §aselected P2P §7becomes the the §9input§7, while the §bbind §btarget §7becomes the §6output§7.
gui.advanced_memory_card.mode.output.desc.3=• The §bbind target §7becomes the same type as its new input.
gui.advanced_memory_card.mode.copy=Current Mode: Copy §6Output
gui.advanced_memory_card.mode.copy.desc.1=• Before binding, the §bbind §btarget §7has its connections removed.
gui.advanced_memory_card.mode.copy.desc.2=• The §aselected §aP2P §7becomes the §9input§7, while the §bbind §btarget §7is added to the list of the §aselected §aP2P's §6outputs§7.
gui.advanced_memory_card.mode.copy.desc.3=• The §bbind target §7becomes the same type as its new input.
gui.advanced_memory_card.mode.copy=Current Mode: Copy §9Input §7to §6Output
gui.advanced_memory_card.mode.copy.desc.1=• §aSelected P2P §7must be an §9input.
gui.advanced_memory_card.mode.copy.desc.2=• Before binding, the §bbind §btarget §7has its connections removed.
gui.advanced_memory_card.mode.copy.desc.3=• The §aselected §aP2P §7becomes the §9input§7, while the §bbind §btarget §7is added to the list of the §aselected §aP2P's §6outputs§7.
gui.advanced_memory_card.mode.copy.desc.4=• The §bbind target §7becomes the same type as its new input.
gui.advanced_memory_card.desc.not_set=Not set
gui.advanced_memory_card.desc.effect=Effect:
gui.advanced_memory_card.gui_scale.small=Current Size: Small