Merge remote-tracking branch 'origin/main'
commit
2db508cbdb
@ -0,0 +1,68 @@
|
||||
package net.brokenmoon.redcontrol.util
|
||||
|
||||
import net.brokenmoon.redcontrol.RedControl
|
||||
import net.brokenmoon.redcontrol.api.RCWorldBus
|
||||
import net.brokenmoon.redcontrol.blocks.NetworkCarrier
|
||||
import net.minecraft.particle.ParticleTypes
|
||||
import net.minecraft.server.world.ServerWorld
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Direction
|
||||
|
||||
object FloodFill {
|
||||
fun blockFloodFiller(world: ServerWorld, seed: BlockPos) {
|
||||
val checkable = mutableListOf(seed)
|
||||
val seen = mutableListOf<BlockPos>()
|
||||
var bus: RCWorldBus? = null
|
||||
while (checkable.isNotEmpty()) {
|
||||
val pos = checkable.removeFirst()
|
||||
if (pos in seen) {continue}
|
||||
val state = world.getBlockState(pos)
|
||||
if (!state.isIn(RedControl.TAG_BUSABLE)){continue}
|
||||
val net = state.block as? NetworkCarrier
|
||||
if (net != null) {
|
||||
val cpos = pos.toCenterPos()
|
||||
world.spawnParticles(ParticleTypes.WAX_ON,cpos.x,cpos.y,cpos.z,20,0.6,0.6,0.6,0.2)
|
||||
if (bus == null) {
|
||||
bus = net.getBus(world,pos)
|
||||
} else {
|
||||
net.setBus(world,pos,bus)
|
||||
}
|
||||
}
|
||||
//val cpos = pos.toCenterPos()
|
||||
//world.spawnParticles(ParticleTypes.WAX_ON,cpos.x,cpos.y,cpos.z,20,0.2,0.2,0.2,0.2)
|
||||
Direction.entries.forEach {
|
||||
checkable.add(pos.add(it.offsetX,it.offsetY,it.offsetZ))
|
||||
}
|
||||
seen.add(pos)
|
||||
}
|
||||
}
|
||||
fun blockBreakFloodFiller(world: ServerWorld, seed: BlockPos) {
|
||||
val checkable = mutableListOf<BlockPos>()
|
||||
Direction.entries.forEach {
|
||||
checkable.add(seed.add(it.offsetX,it.offsetY,it.offsetZ))
|
||||
}
|
||||
val seen = mutableListOf<BlockPos>()
|
||||
while (checkable.isNotEmpty()) {
|
||||
val pos = checkable.removeFirst()
|
||||
if (pos in seen) {
|
||||
continue
|
||||
}
|
||||
val state = world.getBlockState(pos)
|
||||
if (!state.isIn(RedControl.TAG_BUSABLE)) {
|
||||
continue
|
||||
}
|
||||
Direction.entries.forEach {
|
||||
checkable.add(pos.add(it.offsetX, it.offsetY, it.offsetZ))
|
||||
}
|
||||
seen.add(pos)
|
||||
val nc = (state.block as? NetworkCarrier)
|
||||
if (nc != null) {
|
||||
nc.getBus(world,pos).valid = false
|
||||
val cpos = pos.toCenterPos()
|
||||
world.spawnParticles(ParticleTypes.WAX_OFF,cpos.x,cpos.y,cpos.z,20,0.6,0.6,0.6,0.2)
|
||||
}
|
||||
//val cpos = pos.toCenterPos()
|
||||
//world.spawnParticles(ParticleTypes.WAX_OFF, cpos.x, cpos.y, cpos.z, 20, 0.2, 0.2, 0.2, 0.2)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,9 @@
|
||||
{
|
||||
"values": ["minecraft:glass"]
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:glass",
|
||||
"redcontrol:cpu",
|
||||
"redcontrol:disk_drive",
|
||||
"redcontrol:monitor"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue