Add chat block
This commit is contained in:
parent
82bb799c64
commit
aa9181cfea
|
@ -35,7 +35,9 @@ class ManagerBlock: Block(Settings.of(Material.METAL)), BlockEntityProvider {
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
private fun openManagerUI(managerBlockEntity: ManagerBlockEntity) {
|
private fun openManagerUI(managerBlockEntity: ManagerBlockEntity) {
|
||||||
val vc = ManagerViewController(managerBlockEntity)
|
val vc = ManagerViewController(managerBlockEntity)
|
||||||
val screen = CacaoScreen()
|
val screen = object: CacaoScreen() {
|
||||||
|
override fun isPauseScreen() = false
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
val window = screen.addWindow(Window(vc))
|
val window = screen.addWindow(Window(vc))
|
||||||
MinecraftClient.getInstance().openScreen(screen)
|
MinecraftClient.getInstance().openScreen(screen)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.block.entity.BlockEntity
|
||||||
import net.shadowfacts.asmr.ASMR
|
import net.shadowfacts.asmr.ASMR
|
||||||
import net.shadowfacts.asmr.program.Program
|
import net.shadowfacts.asmr.program.Program
|
||||||
import net.shadowfacts.asmr.program.ProgramType.Companion.INT
|
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.ConstantBlock
|
||||||
import net.shadowfacts.asmr.program.blocks.PrintBlock
|
import net.shadowfacts.asmr.program.blocks.PrintBlock
|
||||||
import net.shadowfacts.asmr.program.blocks.math.BinaryOperatorBlock
|
import net.shadowfacts.asmr.program.blocks.math.BinaryOperatorBlock
|
||||||
|
@ -29,7 +30,7 @@ class ManagerBlockEntity: BlockEntity(ASMR.managerEntityType) {
|
||||||
// it.right.link(from = right.output)
|
// it.right.link(from = right.output)
|
||||||
it.position = Point(120.0, 0.0)
|
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.input.link(from = divide.output)
|
||||||
it.position = Point(240.0, 0.0)
|
it.position = Point(240.0, 0.0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,5 +9,7 @@
|
||||||
"programblock.asmr.binary_operator": "Binary Math Operator",
|
"programblock.asmr.binary_operator": "Binary Math Operator",
|
||||||
"programblock.param.asmr.binary_operator.left_operand": "Left Operand",
|
"programblock.param.asmr.binary_operator.left_operand": "Left Operand",
|
||||||
"programblock.param.asmr.binary_operator.right_operand": "Right 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"
|
||||||
}
|
}
|
Loading…
Reference in New Issue