Remove test blocks
This commit is contained in:
parent
2c19b8456b
commit
a8f0387577
|
@ -17,10 +17,6 @@ import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlock
|
||||||
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlockEntity
|
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlockEntity
|
||||||
import net.shadowfacts.phycon.network.block.terminal.TerminalBlock
|
import net.shadowfacts.phycon.network.block.terminal.TerminalBlock
|
||||||
import net.shadowfacts.phycon.network.block.terminal.TerminalBlockEntity
|
import net.shadowfacts.phycon.network.block.terminal.TerminalBlockEntity
|
||||||
import net.shadowfacts.phycon.network.block.test.DestBlock
|
|
||||||
import net.shadowfacts.phycon.network.block.test.DestBlockEntity
|
|
||||||
import net.shadowfacts.phycon.network.block.test.SourceBlock
|
|
||||||
import net.shadowfacts.phycon.network.block.test.SourceBlockEntity
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author shadowfacts
|
* @author shadowfacts
|
||||||
|
@ -34,9 +30,6 @@ object PhyBlockEntities {
|
||||||
val MINER = create(::MinerBlockEntity, PhyBlocks.MINER)
|
val MINER = create(::MinerBlockEntity, PhyBlocks.MINER)
|
||||||
val REDSTONE_CONTROLLER = create(::RedstoneControllerBlockEntity, PhyBlocks.REDSTONE_CONTROLLER)
|
val REDSTONE_CONTROLLER = create(::RedstoneControllerBlockEntity, PhyBlocks.REDSTONE_CONTROLLER)
|
||||||
|
|
||||||
val SOURCE = create(::SourceBlockEntity, PhyBlocks.SOURCE)
|
|
||||||
val DEST = create(::DestBlockEntity, PhyBlocks.DEST)
|
|
||||||
|
|
||||||
private fun <T: BlockEntity> create(builder: () -> T, block: Block): BlockEntityType<T> {
|
private fun <T: BlockEntity> create(builder: () -> T, block: Block): BlockEntityType<T> {
|
||||||
return BlockEntityType.Builder.create(builder, block).build(null)
|
return BlockEntityType.Builder.create(builder, block).build(null)
|
||||||
}
|
}
|
||||||
|
@ -48,9 +41,6 @@ object PhyBlockEntities {
|
||||||
register(ExtractorBlock.ID, EXTRACTOR)
|
register(ExtractorBlock.ID, EXTRACTOR)
|
||||||
register(MinerBlock.ID, MINER)
|
register(MinerBlock.ID, MINER)
|
||||||
register(RedstoneControllerBlock.ID, REDSTONE_CONTROLLER)
|
register(RedstoneControllerBlock.ID, REDSTONE_CONTROLLER)
|
||||||
|
|
||||||
register(SourceBlock.ID, SOURCE)
|
|
||||||
register(DestBlock.ID, DEST)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun register(id: Identifier, type: BlockEntityType<*>) {
|
private fun register(id: Identifier, type: BlockEntityType<*>) {
|
||||||
|
|
|
@ -10,8 +10,6 @@ import net.shadowfacts.phycon.network.block.netinterface.InterfaceBlock
|
||||||
import net.shadowfacts.phycon.network.block.netswitch.SwitchBlock
|
import net.shadowfacts.phycon.network.block.netswitch.SwitchBlock
|
||||||
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlock
|
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlock
|
||||||
import net.shadowfacts.phycon.network.block.terminal.TerminalBlock
|
import net.shadowfacts.phycon.network.block.terminal.TerminalBlock
|
||||||
import net.shadowfacts.phycon.network.block.test.DestBlock
|
|
||||||
import net.shadowfacts.phycon.network.block.test.SourceBlock
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author shadowfacts
|
* @author shadowfacts
|
||||||
|
@ -26,9 +24,6 @@ object PhyBlocks {
|
||||||
val MINER = MinerBlock()
|
val MINER = MinerBlock()
|
||||||
val REDSTONE_CONTROLLER = RedstoneControllerBlock()
|
val REDSTONE_CONTROLLER = RedstoneControllerBlock()
|
||||||
|
|
||||||
val SOURCE = SourceBlock()
|
|
||||||
val DEST = DestBlock()
|
|
||||||
|
|
||||||
fun init() {
|
fun init() {
|
||||||
register(InterfaceBlock.ID, INTERFACE)
|
register(InterfaceBlock.ID, INTERFACE)
|
||||||
register(TerminalBlock.ID, TERMINAL)
|
register(TerminalBlock.ID, TERMINAL)
|
||||||
|
@ -37,9 +32,6 @@ object PhyBlocks {
|
||||||
register(ExtractorBlock.ID, EXTRACTOR)
|
register(ExtractorBlock.ID, EXTRACTOR)
|
||||||
register(MinerBlock.ID, MINER)
|
register(MinerBlock.ID, MINER)
|
||||||
register(RedstoneControllerBlock.ID, REDSTONE_CONTROLLER)
|
register(RedstoneControllerBlock.ID, REDSTONE_CONTROLLER)
|
||||||
|
|
||||||
register(SourceBlock.ID, SOURCE)
|
|
||||||
register(DestBlock.ID, DEST)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun register(id: Identifier, block: Block) {
|
private fun register(id: Identifier, block: Block) {
|
||||||
|
|
|
@ -13,8 +13,6 @@ import net.shadowfacts.phycon.network.block.netinterface.InterfaceBlock
|
||||||
import net.shadowfacts.phycon.network.block.netswitch.SwitchBlock
|
import net.shadowfacts.phycon.network.block.netswitch.SwitchBlock
|
||||||
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlock
|
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlock
|
||||||
import net.shadowfacts.phycon.network.block.terminal.TerminalBlock
|
import net.shadowfacts.phycon.network.block.terminal.TerminalBlock
|
||||||
import net.shadowfacts.phycon.network.block.test.DestBlock
|
|
||||||
import net.shadowfacts.phycon.network.block.test.SourceBlock
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author shadowfacts
|
* @author shadowfacts
|
||||||
|
@ -29,9 +27,6 @@ object PhyItems {
|
||||||
val MINER = BlockItem(PhyBlocks.MINER, Item.Settings())
|
val MINER = BlockItem(PhyBlocks.MINER, Item.Settings())
|
||||||
val REDSTONE_CONTROLLER = BlockItem(PhyBlocks.REDSTONE_CONTROLLER, Item.Settings())
|
val REDSTONE_CONTROLLER = BlockItem(PhyBlocks.REDSTONE_CONTROLLER, Item.Settings())
|
||||||
|
|
||||||
val SOURCE = BlockItem(PhyBlocks.SOURCE, Item.Settings())
|
|
||||||
val DEST = BlockItem(PhyBlocks.DEST , Item.Settings())
|
|
||||||
|
|
||||||
val SCREWDRIVER = ScrewdriverItem()
|
val SCREWDRIVER = ScrewdriverItem()
|
||||||
val CONSOLE = ConsoleItem()
|
val CONSOLE = ConsoleItem()
|
||||||
|
|
||||||
|
@ -44,9 +39,6 @@ object PhyItems {
|
||||||
register(MinerBlock.ID, MINER)
|
register(MinerBlock.ID, MINER)
|
||||||
register(RedstoneControllerBlock.ID, REDSTONE_CONTROLLER)
|
register(RedstoneControllerBlock.ID, REDSTONE_CONTROLLER)
|
||||||
|
|
||||||
register(SourceBlock.ID, SOURCE)
|
|
||||||
register(DestBlock.ID, DEST)
|
|
||||||
|
|
||||||
register(ScrewdriverItem.ID, SCREWDRIVER)
|
register(ScrewdriverItem.ID, SCREWDRIVER)
|
||||||
register(ConsoleItem.ID, CONSOLE)
|
register(ConsoleItem.ID, CONSOLE)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
package net.shadowfacts.phycon.network.block.test
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState
|
|
||||||
import net.minecraft.block.Material
|
|
||||||
import net.minecraft.entity.player.PlayerEntity
|
|
||||||
import net.minecraft.util.ActionResult
|
|
||||||
import net.minecraft.util.Hand
|
|
||||||
import net.minecraft.util.Identifier
|
|
||||||
import net.minecraft.util.hit.BlockHitResult
|
|
||||||
import net.minecraft.util.math.BlockPos
|
|
||||||
import net.minecraft.util.math.Direction
|
|
||||||
import net.minecraft.world.BlockView
|
|
||||||
import net.minecraft.world.World
|
|
||||||
import net.minecraft.world.WorldAccess
|
|
||||||
import net.shadowfacts.phycon.PhysicalConnectivity
|
|
||||||
import net.shadowfacts.phycon.network.DeviceBlock
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author shadowfacts
|
|
||||||
*/
|
|
||||||
class DestBlock: DeviceBlock<DestBlockEntity>(Settings.of(Material.METAL)) {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ID = Identifier(PhysicalConnectivity.MODID, "dest")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createBlockEntity(world: BlockView): DestBlockEntity {
|
|
||||||
return DestBlockEntity()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getNetworkConnectedSides(state: BlockState, world: WorldAccess, pos: BlockPos): MutableCollection<Direction> {
|
|
||||||
return EnumSet.allOf(Direction::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUse(
|
|
||||||
blockState: BlockState?,
|
|
||||||
world: World,
|
|
||||||
pos: BlockPos,
|
|
||||||
playerEntity: PlayerEntity?,
|
|
||||||
hand: Hand?,
|
|
||||||
blockHitResult: BlockHitResult?
|
|
||||||
): ActionResult {
|
|
||||||
println("dest IP: ${getBlockEntity(world, pos)!!.ipAddress}")
|
|
||||||
return ActionResult.SUCCESS
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package net.shadowfacts.phycon.network.block.test
|
|
||||||
|
|
||||||
import net.minecraft.util.math.Direction
|
|
||||||
import net.shadowfacts.phycon.api.Interface
|
|
||||||
import net.shadowfacts.phycon.api.packet.Packet
|
|
||||||
import net.shadowfacts.phycon.init.PhyBlockEntities
|
|
||||||
import net.shadowfacts.phycon.network.DeviceBlockEntity
|
|
||||||
import net.shadowfacts.phycon.network.NetworkUtil
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author shadowfacts
|
|
||||||
*/
|
|
||||||
class DestBlockEntity: DeviceBlockEntity(PhyBlockEntities.DEST) {
|
|
||||||
|
|
||||||
override fun handle(packet: Packet) {
|
|
||||||
println("$this ($ipAddress) received packet: $packet")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun findDestination(): Interface? {
|
|
||||||
for (dir in Direction.values()) {
|
|
||||||
val itf = NetworkUtil.findConnectedInterface(world!!, pos, dir)
|
|
||||||
if (itf != null) {
|
|
||||||
return itf
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package net.shadowfacts.phycon.network.block.test
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState
|
|
||||||
import net.minecraft.block.Material
|
|
||||||
import net.minecraft.util.Identifier
|
|
||||||
import net.minecraft.util.math.BlockPos
|
|
||||||
import net.minecraft.util.math.Direction
|
|
||||||
import net.minecraft.world.BlockView
|
|
||||||
import net.minecraft.world.WorldAccess
|
|
||||||
import net.shadowfacts.phycon.PhysicalConnectivity
|
|
||||||
import net.shadowfacts.phycon.network.DeviceBlock
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author shadowfacts
|
|
||||||
*/
|
|
||||||
class SourceBlock: DeviceBlock<SourceBlockEntity>(Settings.of(Material.METAL)) {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ID = Identifier(PhysicalConnectivity.MODID, "source")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createBlockEntity(world: BlockView): SourceBlockEntity {
|
|
||||||
return SourceBlockEntity()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getNetworkConnectedSides(state: BlockState, world: WorldAccess, pos: BlockPos): MutableCollection<Direction> {
|
|
||||||
return EnumSet.allOf(Direction::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package net.shadowfacts.phycon.network.block.test
|
|
||||||
|
|
||||||
import net.minecraft.util.Tickable
|
|
||||||
import net.minecraft.util.math.Direction
|
|
||||||
import net.shadowfacts.phycon.api.Interface
|
|
||||||
import net.shadowfacts.phycon.api.packet.Packet
|
|
||||||
import net.shadowfacts.phycon.api.util.IPAddress
|
|
||||||
import net.shadowfacts.phycon.init.PhyBlockEntities
|
|
||||||
import net.shadowfacts.phycon.network.DeviceBlockEntity
|
|
||||||
import net.shadowfacts.phycon.network.NetworkUtil
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author shadowfacts
|
|
||||||
*/
|
|
||||||
class SourceBlockEntity: DeviceBlockEntity(PhyBlockEntities.SOURCE), Tickable {
|
|
||||||
|
|
||||||
override fun handle(packet: Packet) {
|
|
||||||
TODO("Not yet implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun tick() {
|
|
||||||
super.tick()
|
|
||||||
if (!world!!.isClient && counter % 40 == 0L) {
|
|
||||||
sendPacket(TestPacket(ipAddress, IPAddress(170, 171, 101, 168)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun findDestination(): Interface? {
|
|
||||||
for (dir in Direction.values()) {
|
|
||||||
val itf = NetworkUtil.findConnectedInterface(world!!, pos, dir)
|
|
||||||
if (itf != null) {
|
|
||||||
return itf
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package net.shadowfacts.phycon.network.block.test
|
|
||||||
|
|
||||||
import net.shadowfacts.phycon.api.util.IPAddress
|
|
||||||
import net.shadowfacts.phycon.network.packet.BasePacket
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author shadowfacts
|
|
||||||
*/
|
|
||||||
class TestPacket(source: IPAddress, destination: IPAddress): BasePacket(source, destination) {
|
|
||||||
}
|
|
Loading…
Reference in New Issue