mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Underped MCU and Access Points' outer component nodes a little.
This also means MCU is now network visible again.
This commit is contained in:
parent
62afa212d5
commit
6e4debf72b
@ -16,8 +16,6 @@ import net.minecraft.nbt.NBTTagCompound
|
|||||||
import net.minecraftforge.common.util.Constants.NBT
|
import net.minecraftforge.common.util.Constants.NBT
|
||||||
import net.minecraftforge.common.util.ForgeDirection
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
|
|
||||||
import scala.collection.convert.WrapAsScala._
|
|
||||||
|
|
||||||
class AccessPoint extends Switch with WirelessEndpoint with traits.PowerAcceptor {
|
class AccessPoint extends Switch with WirelessEndpoint with traits.PowerAcceptor {
|
||||||
var strength = Settings.get.maxWirelessRange
|
var strength = Settings.get.maxWirelessRange
|
||||||
|
|
||||||
@ -94,28 +92,32 @@ class AccessPoint extends Switch with WirelessEndpoint with traits.PowerAcceptor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override protected def createNode(plug: Plug) = api.Network.newNode(plug, Visibility.Network).
|
override protected def createNode(plug: Plug) = api.Network.newNode(plug, Visibility.Network).
|
||||||
withConnector(math.round(Settings.get.bufferAccessPoint)).
|
withConnector(math.round(Settings.get.bufferAccessPoint)).
|
||||||
create()
|
create()
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
|
||||||
|
|
||||||
override protected def onPlugConnect(plug: Plug, node: Node) {
|
override protected def onPlugConnect(plug: Plug, node: Node) {
|
||||||
super.onPlugConnect(plug, node)
|
super.onPlugConnect(plug, node)
|
||||||
if (node == plug.node) {
|
if (node == plug.node) {
|
||||||
api.Network.joinWirelessNetwork(this)
|
api.Network.joinWirelessNetwork(this)
|
||||||
}
|
}
|
||||||
if (!node.network.nodes.exists(componentNodes.contains)) {
|
if (plug.isPrimary)
|
||||||
node.connect(componentNodes(plug.side.ordinal))
|
plug.node.connect(componentNodes(plug.side.ordinal()))
|
||||||
}
|
else
|
||||||
|
componentNodes(plug.side.ordinal).remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected def onPlugDisconnect(plug: Plug, node: Node) {
|
override protected def onPlugDisconnect(plug: Plug, node: Node) {
|
||||||
super.onPlugDisconnect(plug, node)
|
super.onPlugDisconnect(plug, node)
|
||||||
if (node == plug.node) {
|
if (node == plug.node) {
|
||||||
api.Network.leaveWirelessNetwork(this)
|
api.Network.leaveWirelessNetwork(this)
|
||||||
componentNodes(plug.side.ordinal).remove()
|
|
||||||
}
|
}
|
||||||
|
if (plug.isPrimary && node != plug.node)
|
||||||
|
plug.node.connect(componentNodes(plug.side.ordinal()))
|
||||||
|
else
|
||||||
|
componentNodes(plug.side.ordinal).remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -13,6 +13,7 @@ import li.cil.oc.common.Tier
|
|||||||
import li.cil.oc.common.item.data.MicrocontrollerData
|
import li.cil.oc.common.item.data.MicrocontrollerData
|
||||||
import li.cil.oc.util.ExtendedArguments._
|
import li.cil.oc.util.ExtendedArguments._
|
||||||
import li.cil.oc.util.ExtendedNBT._
|
import li.cil.oc.util.ExtendedNBT._
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraftforge.common.util.Constants.NBT
|
import net.minecraftforge.common.util.Constants.NBT
|
||||||
@ -38,6 +39,7 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
|
|||||||
|
|
||||||
if (machine != null) {
|
if (machine != null) {
|
||||||
machine.node.asInstanceOf[Connector].setLocalBufferSize(0)
|
machine.node.asInstanceOf[Connector].setLocalBufferSize(0)
|
||||||
|
machine.setCostPerTick(Settings.get.microcontrollerCost)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def tier = info.tier
|
override def tier = info.tier
|
||||||
@ -60,6 +62,16 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float): Array[Node] = {
|
||||||
|
super.onAnalyze(player, side, hitX, hitY, hitZ)
|
||||||
|
if (ForgeDirection.getOrientation(side) != facing)
|
||||||
|
Array(componentNodes(side))
|
||||||
|
else
|
||||||
|
Array(machine.node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def internalComponents(): java.lang.Iterable[ItemStack] = asJavaIterable(info.components)
|
override def internalComponents(): java.lang.Iterable[ItemStack] = asJavaIterable(info.components)
|
||||||
|
|
||||||
override def componentSlot(address: String) = components.indexWhere(_.exists(env => env.node != null && env.node.address == address))
|
override def componentSlot(address: String) = components.indexWhere(_.exists(env => env.node != null && env.node.address == address))
|
||||||
@ -132,13 +144,23 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
|
|||||||
create()
|
create()
|
||||||
|
|
||||||
override protected def onPlugConnect(plug: Plug, node: Node): Unit = {
|
override protected def onPlugConnect(plug: Plug, node: Node): Unit = {
|
||||||
|
super.onPlugConnect(plug, node)
|
||||||
if (node == plug.node) {
|
if (node == plug.node) {
|
||||||
api.Network.joinNewNetwork(machine.node)
|
api.Network.joinNewNetwork(machine.node)
|
||||||
machine.node.connect(snooperNode)
|
machine.node.connect(snooperNode)
|
||||||
machine.setCostPerTick(Settings.get.microcontrollerCost)
|
|
||||||
node.connect(componentNodes(plug.side.ordinal))
|
|
||||||
}
|
}
|
||||||
super.onPlugConnect(plug, node)
|
if (plug.isPrimary)
|
||||||
|
plug.node.connect(componentNodes(plug.side.ordinal()))
|
||||||
|
else
|
||||||
|
componentNodes(plug.side.ordinal).remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected def onPlugDisconnect(plug: Plug, node: Node) {
|
||||||
|
super.onPlugDisconnect(plug, node)
|
||||||
|
if (plug.isPrimary && node != plug.node)
|
||||||
|
plug.node.connect(componentNodes(plug.side.ordinal()))
|
||||||
|
else
|
||||||
|
componentNodes(plug.side.ordinal).remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected def onPlugMessage(plug: Plug, message: Message): Unit = {
|
override protected def onPlugMessage(plug: Plug, message: Message): Unit = {
|
||||||
@ -166,7 +188,10 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
|
|||||||
zipWithIndex.foreach {
|
zipWithIndex.foreach {
|
||||||
case (tag, index) => componentNodes(index).load(tag)
|
case (tag, index) => componentNodes(index).load(tag)
|
||||||
}
|
}
|
||||||
|
snooperNode.load(nbt.getCompoundTag(Settings.namespace + "snooper"))
|
||||||
super.readFromNBTForServer(nbt)
|
super.readFromNBTForServer(nbt)
|
||||||
|
api.Network.joinNewNetwork(machine.node)
|
||||||
|
machine.node.connect(snooperNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def writeToNBTForServer(nbt: NBTTagCompound) {
|
override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||||
@ -180,6 +205,7 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
|
|||||||
tag
|
tag
|
||||||
case _ => new NBTTagCompound()
|
case _ => new NBTTagCompound()
|
||||||
})
|
})
|
||||||
|
nbt.setNewCompoundTag(Settings.namespace + "snooper", snooperNode.save)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
Loading…
x
Reference in New Issue
Block a user