subnode bullshit
This commit is contained in:
@@ -40,8 +40,7 @@ class CapacitorEntity(pos: BlockPos, state: BlockState) : NodeEntity(BlockEntiti
|
|||||||
class CapacitorBlock : BaseBlock("capacitor"), EntityBlock {
|
class CapacitorBlock : BaseBlock("capacitor"), EntityBlock {
|
||||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? {
|
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? {
|
||||||
val cap = CapacitorEntity(blockPos, blockState)
|
val cap = CapacitorEntity(blockPos, blockState)
|
||||||
cap.syncReachable()
|
cap.initNetworking()
|
||||||
Networking.addNode(cap.getNode())
|
|
||||||
return cap
|
return cap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class ScreenBlock() : BaseBlock("screen"), EntityBlock {
|
|||||||
|
|
||||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? {
|
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? {
|
||||||
val scr = ScreenEntity(blockPos, blockState)
|
val scr = ScreenEntity(blockPos, blockState)
|
||||||
Networking.addNode(scr.getNode())
|
scr.initNetworking()
|
||||||
return scr
|
return scr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ open class NodeEntity(blockEntityType: BlockEntityType<*>, blockPos: BlockPos, b
|
|||||||
// stuff
|
// stuff
|
||||||
open fun getNode(): Networking.Node? = null
|
open fun getNode(): Networking.Node? = null
|
||||||
|
|
||||||
|
open fun getSubnodes(): List<Networking.Node> = listOf()
|
||||||
|
|
||||||
|
fun initNetworking() {
|
||||||
|
val node = getNode()
|
||||||
|
if(node != null) Networking.addNode(node)
|
||||||
|
getSubnodes().forEach { Networking.addNode(it) }
|
||||||
|
syncReachable()
|
||||||
|
}
|
||||||
|
|
||||||
open fun getDirectConnections(): List<NodeEntity> {
|
open fun getDirectConnections(): List<NodeEntity> {
|
||||||
if(level == null) return listOf();
|
if(level == null) return listOf();
|
||||||
val offs = listOf(
|
val offs = listOf(
|
||||||
@@ -80,6 +89,7 @@ open class NodeEntity(blockEntityType: BlockEntityType<*>, blockPos: BlockPos, b
|
|||||||
super.setRemoved()
|
super.setRemoved()
|
||||||
syncReachable()
|
syncReachable()
|
||||||
val n = getNode()
|
val n = getNode()
|
||||||
if(n != null) Networking.removeNode(n);
|
if(n != null) Networking.removeNode(n)
|
||||||
|
getSubnodes().forEach { Networking.removeNode(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,6 +146,7 @@ object Networking {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun directConnectTo(other: Node) {
|
fun directConnectTo(other: Node) {
|
||||||
|
if(other == this) return;
|
||||||
if(other in connections) return;
|
if(other in connections) return;
|
||||||
connections.add(other);
|
connections.add(other);
|
||||||
this.onConnect(other);
|
this.onConnect(other);
|
||||||
|
|||||||
Reference in New Issue
Block a user