madness of men
This commit is contained in:
@@ -188,6 +188,7 @@ class CaseBlockEntity(blockPos: BlockPos, blockState: BlockState): NodeBlockEnti
|
|||||||
override fun crash(error: String): Boolean {
|
override fun crash(error: String): Boolean {
|
||||||
if(isOn) {
|
if(isOn) {
|
||||||
beepAsync("--")
|
beepAsync("--")
|
||||||
|
sendMachineEvent(MachineCrashEvent(this, error))
|
||||||
}
|
}
|
||||||
setRunning(false)
|
setRunning(false)
|
||||||
err = error
|
err = error
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ abstract class MachineEvent {
|
|||||||
|
|
||||||
data class MachineRedstoneEvent(override val machine: MachineEntity, val side: Direction, val oldValue: Int, val newValue: Int): MachineEvent()
|
data class MachineRedstoneEvent(override val machine: MachineEntity, val side: Direction, val oldValue: Int, val newValue: Int): MachineEvent()
|
||||||
data class MachinePowerEvent(override val machine: MachineEntity, val nowRunning: Boolean): MachineEvent()
|
data class MachinePowerEvent(override val machine: MachineEntity, val nowRunning: Boolean): MachineEvent()
|
||||||
|
data class MachineCrashEvent(override val machine: MachineEntity, val error: String): MachineEvent()
|
||||||
|
|
||||||
interface MachineEntity {
|
interface MachineEntity {
|
||||||
// Block position of machine, for wireless tech
|
// Block position of machine, for wireless tech
|
||||||
|
|||||||
@@ -17,23 +17,23 @@ interface ComponentItem {
|
|||||||
fun getArchitecturesProvided(itemStack: ItemStack): Set<String> = setOf()
|
fun getArchitecturesProvided(itemStack: ItemStack): Set<String> = setOf()
|
||||||
|
|
||||||
// Component placed, node must now exist
|
// Component placed, node must now exist
|
||||||
fun whenComponentPlaced(itemStack: ItemStack, machine: MachineEntity, newRole: String) {
|
fun whenComponentPlaced(itemStack: ItemStack, machine: MachineEntity?, newRole: String) {
|
||||||
val oldNode = getComponentNode(itemStack)
|
val oldNode = getComponentNode(itemStack)
|
||||||
if(oldNode != null) Networking.removeNode(oldNode) // did a mod forget to call whenComponentTaken?
|
if(oldNode != null) Networking.removeNode(oldNode) // did a mod forget to call whenComponentTaken?
|
||||||
val node = toComponentNode(itemStack, machine) ?: return
|
val node = toComponentNode(itemStack, machine) ?: return
|
||||||
Networking.addNode(node)
|
Networking.addNode(node)
|
||||||
machine.getMachineNode().connectTo(node)
|
machine?.getMachineNode()?.connectTo(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component taken, and thus removed
|
// Component taken, and thus removed
|
||||||
fun whenComponentTaken(itemStack: ItemStack, machine: MachineEntity, previousRole: String) {
|
fun whenComponentTaken(itemStack: ItemStack, machine: MachineEntity?, previousRole: String) {
|
||||||
val node = getComponentNode(itemStack) ?: return
|
val node = getComponentNode(itemStack) ?: return
|
||||||
node.disconnectFrom(machine.getMachineNode())
|
// removing disconnects
|
||||||
Networking.removeNode(node)
|
Networking.removeNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// To node, if applicable. Meant to create the node, but not add it, as it will use the itemStack's address to find it again
|
// To node, if applicable. Meant to create the node, but not add it, as it will use the itemStack's address to find it again
|
||||||
fun toComponentNode(itemStack: ItemStack, machine: MachineEntity): Networking.Node?
|
fun toComponentNode(itemStack: ItemStack, machine: MachineEntity?): Networking.Node?
|
||||||
|
|
||||||
// Gets the node associated to an item, if it exists
|
// Gets the node associated to an item, if it exists
|
||||||
fun getComponentNode(itemStack: ItemStack): Networking.Node? {
|
fun getComponentNode(itemStack: ItemStack): Networking.Node? {
|
||||||
|
|||||||
Reference in New Issue
Block a user