Add chat block

This commit is contained in:
Shadowfacts 2019-08-11 23:41:47 -04:00
parent 82bb799c64
commit aa9181cfea
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
4 changed files with 38 additions and 3 deletions

View File

@ -35,7 +35,9 @@ class ManagerBlock: Block(Settings.of(Material.METAL)), BlockEntityProvider {
@Environment(EnvType.CLIENT)
private fun openManagerUI(managerBlockEntity: ManagerBlockEntity) {
val vc = ManagerViewController(managerBlockEntity)
val screen = CacaoScreen()
val screen = object: CacaoScreen() {
override fun isPauseScreen() = false
}
try {
val window = screen.addWindow(Window(vc))
MinecraftClient.getInstance().openScreen(screen)

View File

@ -4,6 +4,7 @@ import net.minecraft.block.entity.BlockEntity
import net.shadowfacts.asmr.ASMR
import net.shadowfacts.asmr.program.Program
import net.shadowfacts.asmr.program.ProgramType.Companion.INT
import net.shadowfacts.asmr.program.blocks.ChatBlock
import net.shadowfacts.asmr.program.blocks.ConstantBlock
import net.shadowfacts.asmr.program.blocks.PrintBlock
import net.shadowfacts.asmr.program.blocks.math.BinaryOperatorBlock
@ -29,7 +30,7 @@ class ManagerBlockEntity: BlockEntity(ASMR.managerEntityType) {
// it.right.link(from = right.output)
it.position = Point(120.0, 0.0)
}
val print = program.addBlock(PrintBlock(INT)) {
val print = program.addBlock(ChatBlock(INT)) {
// it.input.link(from = divide.output)
it.position = Point(240.0, 0.0)
}

View File

@ -0,0 +1,30 @@
package net.shadowfacts.asmr.program.blocks
import net.minecraft.client.MinecraftClient
import net.minecraft.text.LiteralText
import net.minecraft.util.Identifier
import net.shadowfacts.asmr.ASMR
import net.shadowfacts.asmr.program.ProgramBlockInput
import net.shadowfacts.asmr.program.ProgramBlockOutput
import net.shadowfacts.asmr.program.ProgramType
import net.shadowfacts.asmr.program.execution.SimpleExecutableBlock
/**
* @author shadowfacts
*/
class ChatBlock<Type: Any>(
val type: ProgramType<Type>
): SimpleExecutableBlock(
Identifier(ASMR.modid, "chat")
) {
val input = ProgramBlockInput(Identifier(ASMR.modid, "chat.input"), type, this)
override val inputs: Array<ProgramBlockInput<*>> = arrayOf(input)
override val outputs: Array<ProgramBlockOutput<*>> = arrayOf()
override fun execute() {
MinecraftClient.getInstance().player.sendMessage(LiteralText(input.value.toString()))
}
}

View File

@ -9,5 +9,7 @@
"programblock.asmr.binary_operator": "Binary Math Operator",
"programblock.param.asmr.binary_operator.left_operand": "Left Operand",
"programblock.param.asmr.binary_operator.right_operand": "Right Operand",
"programblock.param.asmr.binary_operator.result": "Result"
"programblock.param.asmr.binary_operator.result": "Result",
"programblock.asmr.chat": "Chat",
"programblock.param.asmr.chat.input": "Chat Value"
}