From 2d432bc27c8eb527da5761a0b2be9562349cf50a Mon Sep 17 00:00:00 2001 From: Firenoo <49818773+firenoo@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:35:31 -0700 Subject: [PATCH] Add dual interfaces to supported P2P list --- dependencies.gradle | 1 + .../java/com/projecturanus/betterp2p/Proxy.kt | 53 ++++++++++++++----- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 4af852a..6ffdf7a 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -8,4 +8,5 @@ dependencies { compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:api') devOnlyNonPublishable('com.github.GTNewHorizons:OpenComputers:1.9.5-GTNH:dev') {transitive = false} compileOnly('pneumaticCraft:PneumaticCraft-1.7.10:1.12.7-152:api') {transitive = false} + api('com.github.GTNewHorizons:AE2FluidCraft-Rework:1.1.29-gtnh-pre:dev') {transitive = false} } diff --git a/src/main/java/com/projecturanus/betterp2p/Proxy.kt b/src/main/java/com/projecturanus/betterp2p/Proxy.kt index 10688a1..fd6c16d 100644 --- a/src/main/java/com/projecturanus/betterp2p/Proxy.kt +++ b/src/main/java/com/projecturanus/betterp2p/Proxy.kt @@ -15,11 +15,14 @@ import appeng.parts.p2p.PartP2PRFPower import appeng.parts.p2p.PartP2PRedstone import appeng.parts.p2p.PartP2PTunnel import appeng.parts.p2p.PartP2PTunnelME +import com.glodblock.github.common.parts.PartFluidP2PInterface +import com.glodblock.github.loader.ItemAndBlockHolder import com.projecturanus.betterp2p.client.render.RenderHandler import com.projecturanus.betterp2p.item.ItemAdvancedMemoryCard import com.projecturanus.betterp2p.network.ServerPlayerDisconnectHandler import com.projecturanus.betterp2p.util.p2p.ClientTunnelInfo import com.projecturanus.betterp2p.util.p2p.TunnelInfo +import cpw.mods.fml.common.Loader import cpw.mods.fml.common.registry.GameRegistry import net.minecraft.item.ItemStack import net.minecraft.item.crafting.ShapelessRecipes @@ -97,6 +100,16 @@ open class CommonProxy { def = partDefs.p2PTunnelMEInterface(), type = typeId++, classType = PartP2PInterface::class.java) + if (Loader.isModLoaded("ae2fc")) { + val item = ItemAndBlockHolder.FLUID_INTERFACE_P2P + if (item != null) { + val clazz = PartFluidP2PInterface::class.java + val type = typeId++ + val info = TunnelInfo(type, item.stack(), clazz) + tunnelTypes[clazz] = info + tunnelIndices[type] = info + } + } } private fun registerTunnel(def: IItemDefinition, type: Int, classType: Class>) { @@ -136,72 +149,84 @@ class ClientProxy: CommonProxy() { */ override fun initTunnels() { val partDefs = AEApi.instance().definitions().parts() + var typeId = 0 registerTunnel( def = partDefs.p2PTunnelME(), - type = TunnelType.ME, + type = typeId++, classType = PartP2PTunnelME::class.java, icon = { PartP2PTunnelME(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelEU(), - type = TunnelType.IC2_POWER, + type = typeId++, classType = PartP2PIC2Power::class.java, icon = { PartP2PIC2Power(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelRF(), - type = TunnelType.RF_POWER, + type = typeId++, classType = PartP2PRFPower::class.java, icon = { PartP2PRFPower(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelRedstone(), - type = TunnelType.REDSTONE, + type = typeId++, classType = PartP2PRedstone::class.java, icon = { PartP2PRedstone(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelLiquids(), - type = TunnelType.FLUID, + type = typeId++, classType = PartP2PLiquids::class.java, icon = { PartP2PLiquids(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelItems(), - type = TunnelType.ITEM, + type = typeId++, classType = PartP2PItems::class.java, icon = { PartP2PItems(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelLight(), - type = TunnelType.LIGHT, + type = typeId++, classType = PartP2PLight::class.java, icon = { PartP2PLight(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelOpenComputers(), - type = TunnelType.COMPUTER_MESSAGE, + type = typeId++, classType = PartP2POpenComputers::class.java, icon = { PartP2POpenComputers(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelPneumaticCraft(), - type = TunnelType.PRESSURE, + type = typeId++, classType = PartP2PPressure::class.java, icon = { PartP2PPressure(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelGregtech(), - type = TunnelType.GT_POWER, + type = typeId++, classType = PartP2PGT5Power::class.java, icon = { PartP2PGT5Power(it).typeTexture }) registerTunnel( def = partDefs.p2PTunnelMEInterface(), - type = TunnelType.ME_INTERFACE, + type = typeId++, classType = PartP2PInterface::class.java, icon = { PartP2PInterface(it).typeTexture }) + if (Loader.isModLoaded("ae2fc")) { + val item = ItemAndBlockHolder.FLUID_INTERFACE_P2P + if (item != null) { + val clazz = PartFluidP2PInterface::class.java + val stack = item.stack() + val type = typeId++ + val info = ClientTunnelInfo(type, stack, clazz) { PartFluidP2PInterface(stack).typeTexture } + tunnelTypes[clazz] = info + tunnelIndices[type] = info + } + } } private inline fun registerTunnel(def: IItemDefinition, - type: TunnelType, + type: Int, classType: Class>, crossinline icon: (ItemStack) -> IIcon) { if (def.isEnabled) { val stack = def.maybeStack(1).get() - val info = ClientTunnelInfo(type.ordinal, stack, classType) { icon(stack) } + val info = ClientTunnelInfo(type, stack, classType) { icon(stack) } tunnelTypes[classType] = info - tunnelIndices[type.ordinal] = info + tunnelIndices[type] = info } } }