From aa9181cfeaf68d4cde0c42dff561f92805247ede Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 11 Aug 2019 23:41:47 -0400 Subject: [PATCH] Add chat block --- .../shadowfacts/asmr/manager/ManagerBlock.kt | 4 ++- .../asmr/manager/ManagerBlockEntity.kt | 3 +- .../asmr/program/blocks/ChatBlock.kt | 30 +++++++++++++++++++ .../resources/assets/asmr/lang/en_us.json | 4 ++- 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/main/kotlin/net/shadowfacts/asmr/program/blocks/ChatBlock.kt diff --git a/src/main/kotlin/net/shadowfacts/asmr/manager/ManagerBlock.kt b/src/main/kotlin/net/shadowfacts/asmr/manager/ManagerBlock.kt index 019f973..745fa6b 100644 --- a/src/main/kotlin/net/shadowfacts/asmr/manager/ManagerBlock.kt +++ b/src/main/kotlin/net/shadowfacts/asmr/manager/ManagerBlock.kt @@ -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) diff --git a/src/main/kotlin/net/shadowfacts/asmr/manager/ManagerBlockEntity.kt b/src/main/kotlin/net/shadowfacts/asmr/manager/ManagerBlockEntity.kt index 9dae70a..2ca16e3 100644 --- a/src/main/kotlin/net/shadowfacts/asmr/manager/ManagerBlockEntity.kt +++ b/src/main/kotlin/net/shadowfacts/asmr/manager/ManagerBlockEntity.kt @@ -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) } diff --git a/src/main/kotlin/net/shadowfacts/asmr/program/blocks/ChatBlock.kt b/src/main/kotlin/net/shadowfacts/asmr/program/blocks/ChatBlock.kt new file mode 100644 index 0000000..d29e4b0 --- /dev/null +++ b/src/main/kotlin/net/shadowfacts/asmr/program/blocks/ChatBlock.kt @@ -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( + val type: ProgramType +): SimpleExecutableBlock( + Identifier(ASMR.modid, "chat") +) { + + val input = ProgramBlockInput(Identifier(ASMR.modid, "chat.input"), type, this) + + override val inputs: Array> = arrayOf(input) + override val outputs: Array> = arrayOf() + + override fun execute() { + MinecraftClient.getInstance().player.sendMessage(LiteralText(input.value.toString())) + } + +} \ No newline at end of file diff --git a/src/main/resources/assets/asmr/lang/en_us.json b/src/main/resources/assets/asmr/lang/en_us.json index 8aaab6c..1e50b97 100644 --- a/src/main/resources/assets/asmr/lang/en_us.json +++ b/src/main/resources/assets/asmr/lang/en_us.json @@ -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" } \ No newline at end of file