Compare commits

..

No commits in common. "24b7896151c598a51c000e1a2799c84802ed35e9" and "d3a0f279da7d5b757ab02b255683fded4aaa0073" have entirely different histories.

15 changed files with 57 additions and 189 deletions

View File

@ -27,14 +27,14 @@ class RedstoneControllerBlock: FaceDeviceBlock<RedstoneControllerBlockEntity>(Se
}
// todo: don't just copy this from the Interface block
override val faceThickness = 3.0
override val faceThickness = 2.0
override val faceShapes = mapOf(
Direction.DOWN to createCuboidShape(0.0, 0.0, 0.0, 16.0, 3.0, 16.0),
Direction.UP to createCuboidShape(0.0, 13.0, 0.0, 16.0, 16.0, 16.0),
Direction.NORTH to createCuboidShape(0.0, 0.0, 0.0, 16.0, 16.0, 3.0),
Direction.SOUTH to createCuboidShape(0.0, 0.0, 13.0, 16.0, 16.0, 16.0),
Direction.WEST to createCuboidShape(0.0, 0.0, 0.0, 3.0, 16.0, 16.0),
Direction.EAST to createCuboidShape(13.0, 0.0, 0.0, 16.0, 16.0, 16.0)
Direction.DOWN to createCuboidShape(0.0, 0.0, 0.0, 16.0, 2.0, 16.0),
Direction.UP to createCuboidShape(0.0, 14.0, 0.0, 16.0, 16.0, 16.0),
Direction.NORTH to createCuboidShape(0.0, 0.0, 0.0, 16.0, 16.0, 2.0),
Direction.SOUTH to createCuboidShape(0.0, 0.0, 14.0, 16.0, 16.0, 16.0),
Direction.WEST to createCuboidShape(0.0, 0.0, 0.0, 2.0, 16.0, 16.0),
Direction.EAST to createCuboidShape(14.0, 0.0, 0.0, 16.0, 16.0, 16.0)
)
override fun appendProperties(builder: StateManager.Builder<Block, BlockState>) {
@ -55,11 +55,21 @@ class RedstoneControllerBlock: FaceDeviceBlock<RedstoneControllerBlockEntity>(Se
val wasLit = state[LIT]
val isLit = isPowered(world, pos, state[FACING])
if (wasLit != isLit) {
toggleLit(state, world, pos)
if (wasLit) {
world.blockTickScheduler.schedule(pos, this, 4)
} else {
toggleLit(state, world, pos)
}
}
}
}
override fun scheduledTick(state: BlockState, world: ServerWorld, pos: BlockPos, random: Random) {
if (state[LIT] && !isPowered(world, pos, state[FACING])) {
toggleLit(state, world, pos)
}
}
private fun isPowered(world: World, pos: BlockPos, facing: Direction): Boolean {
val offset = pos.offset(facing)
return world.getEmittedRedstonePower(offset, facing) > 0

View File

@ -15,7 +15,6 @@ import net.minecraft.screen.slot.Slot
import net.minecraft.screen.slot.SlotActionType
import net.minecraft.text.LiteralText
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.util.Identifier
import net.shadowfacts.phycon.PhysicalConnectivity
import net.shadowfacts.phycon.networking.C2STerminalRequestItem
@ -162,7 +161,8 @@ class TerminalScreen(handler: TerminalScreenHandler, playerInv: PlayerInventory,
override fun drawForeground(matrixStack: MatrixStack, mouseX: Int, mouseY: Int) {
textRenderer.draw(matrixStack, title, 65f, 6f, 0x404040)
textRenderer.draw(matrixStack, playerInventory.displayName, 65f, backgroundHeight - 94f, 0x404040)
textRenderer.draw(matrixStack, TranslatableText("gui.phycon.terminal_buffer"), 7f, 6f, 0x404040)
// todo: translate this
textRenderer.draw(matrixStack, "Buffer", 7f, 6f, 0x404040)
}
override fun drawBackground(matrixStack: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) {

View File

@ -4,9 +4,12 @@ import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.widget.ButtonWidget
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.LiteralText
import net.minecraft.text.Text
import net.shadowfacts.phycon.network.DeviceBlockEntity
import net.shadowfacts.phycon.network.component.ActivationController
import net.shadowfacts.phycon.networking.C2SConfigureActivationMode
import net.shadowfacts.phycon.util.ActivationMode
import net.shadowfacts.phycon.util.next
import org.lwjgl.glfw.GLFW
@ -63,4 +66,10 @@ class ActivatableDeviceConsoleScreen<T>(
textRenderer.draw(matrixStack, "MAC Address: ${device.macAddress}", minX + 5f, minY + 15f, 0x404040)
}
private val ActivationMode.friendlyName: Text
get() = when (this) {
ActivationMode.AUTOMATIC -> LiteralText("Automatic")
ActivationMode.MANAGED -> LiteralText("Managed")
}
}

View File

@ -1,14 +1,17 @@
package net.shadowfacts.phycon.screen
import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.font.TextRenderer
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.widget.ButtonWidget
import net.minecraft.client.gui.widget.TextFieldWidget
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.LiteralText
import net.minecraft.text.Text
import net.shadowfacts.phycon.api.util.IPAddress
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlockEntity
import net.shadowfacts.phycon.networking.C2SConfigureRedstoneController
import net.shadowfacts.phycon.util.RedstoneMode
import net.shadowfacts.phycon.util.next
import org.lwjgl.glfw.GLFW
@ -96,4 +99,13 @@ class RedstoneControllerConsoleScreen(
textRenderer.draw(matrixStack, "MAC Address: ${device.macAddress}", minX + 5f, minY + 15f, 0x404040)
}
private val RedstoneMode.friendlyName: Text
get() = LiteralText(when (this) {
RedstoneMode.HIGH -> "High"
RedstoneMode.LOW -> "Low"
RedstoneMode.TOGGLE -> "Toggle"
RedstoneMode.RISING_EDGE -> "Rising Edge"
RedstoneMode.FALLING_EDGE -> "Falling Edge"
})
}

View File

@ -1,15 +1,9 @@
package net.shadowfacts.phycon.util
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
/**
* @author shadowfacts
*/
enum class ActivationMode: RotatableEnum {
AUTOMATIC,
MANAGED;
val friendlyName: Text
get() = TranslatableText("gui.phycon.activation_mode.${name.toLowerCase()}")
MANAGED,
}

View File

@ -1,8 +1,5 @@
package net.shadowfacts.phycon.util
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
/**
* @author shadowfacts
*/
@ -24,7 +21,4 @@ enum class RedstoneMode: RotatableEnum {
HIGH, LOW -> true
else -> false
}
val friendlyName: Text
get() = TranslatableText("gui.phycon.redstone_mode.${name.toLowerCase()}")
}

View File

@ -4,52 +4,28 @@
"apply": { "model": "phycon:block/cable_center" }
},
{
"when": { "facing": "down", "lit": "false" },
"apply": { "model": "phycon:block/redstone_controller_side_off" }
"when": { "facing": "down", "lit": "true|false" },
"apply": { "model": "phycon:block/interface_side" }
},
{
"when": { "facing": "up", "lit": "false" },
"apply": { "model": "phycon:block/redstone_controller_side_off", "x": 180 }
"when": { "facing": "up", "lit": "true|false" },
"apply": { "model": "phycon:block/interface_side", "x": 180 }
},
{
"when": { "facing": "north", "lit": "false" },
"apply": { "model": "phycon:block/redstone_controller_side_off", "x": 270 }
"when": { "facing": "north", "lit": "true|false" },
"apply": { "model": "phycon:block/interface_side", "x": 270 }
},
{
"when": { "facing": "south", "lit": "false" },
"apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90 }
"when": { "facing": "south", "lit": "true|false" },
"apply": { "model": "phycon:block/interface_side", "x": 90 }
},
{
"when": { "facing": "west", "lit": "false" },
"apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90, "y": 90 }
"when": { "facing": "west", "lit": "true|false" },
"apply": { "model": "phycon:block/interface_side", "x": 90, "y": 90 }
},
{
"when": { "facing": "east", "lit": "false" },
"apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90, "y": 270 }
},
{
"when": { "facing": "down", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on" }
},
{
"when": { "facing": "up", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 180 }
},
{
"when": { "facing": "north", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 270 }
},
{
"when": { "facing": "south", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90 }
},
{
"when": { "facing": "west", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90, "y": 90 }
},
{
"when": { "facing": "east", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90, "y": 270 }
"when": { "facing": "east", "lit": "true|false" },
"apply": { "model": "phycon:block/interface_side", "x": 90, "y": 270 }
},
{

View File

@ -8,14 +8,5 @@
"block.phycon.redstone_controller": "Redstone Controller",
"item.phycon.screwdriver": "Screwdriver",
"item.phycon.console": "Console",
"gui.phycon.terminal_buffer": "Buffer",
"gui.phycon.redstone_mode.high": "High",
"gui.phycon.redstone_mode.low": "Low",
"gui.phycon.redstone_mode.toggle": "Toggle",
"gui.phycon.redstone_mode.rising_edge": "Rising Edge",
"gui.phycon.redstone_mode.falling_edge": "Falling Edge",
"gui.phycon.activation_mode.automatic": "Automatic",
"gui.phycon.activation_mode.managed": "Managed"
"item.phycon.console": "Console"
}

View File

@ -1,7 +1,6 @@
{
"textures": {
"center": "phycon:block/cable_cap_end",
"particle": "#center"
"center": "phycon:block/cable_cap_end"
},
"elements": [
{

View File

@ -1,33 +0,0 @@
{
"parent": "block/block",
"textures": {
"cable": "phycon:block/cable_straight",
"front": "phycon:block/redstone_controller_front_off",
"back": "phycon:block/redstone_controller_back",
"side": "phycon:block/redstone_controller_back",
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 3, 16],
"faces": {
"down": { "texture": "#front" },
"up": { "texture": "#back" },
"north": { "texture": "#side" },
"south": { "texture": "#side" },
"west": { "texture": "#side" },
"east": { "texture": "#side" }
}
},
{
"from": [6, 3, 6],
"to": [10, 6, 10],
"faces": {
"north": { "texture": "#cable" },
"south": { "texture": "#cable" },
"west": { "texture": "#cable" },
"east": { "texture": "#cable" }
}
}
]
}

View File

@ -1,33 +0,0 @@
{
"parent": "block/block",
"textures": {
"cable": "phycon:block/cable_straight",
"front": "phycon:block/redstone_controller_front_on",
"back": "phycon:block/redstone_controller_back",
"side": "phycon:block/redstone_controller_back"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 3, 16],
"faces": {
"down": { "texture": "#front" },
"up": { "texture": "#back" },
"north": { "texture": "#side" },
"south": { "texture": "#side" },
"west": { "texture": "#side" },
"east": { "texture": "#side" }
}
},
{
"from": [6, 3, 6],
"to": [10, 6, 10],
"faces": {
"north": { "texture": "#cable" },
"south": { "texture": "#cable" },
"west": { "texture": "#cable" },
"east": { "texture": "#cable" }
}
}
]
}

View File

@ -1,51 +0,0 @@
{
"parent": "block/block",
"textures": {
"front": "phycon:block/redstone_controller_front_off",
"back": "phycon:block/redstone_controller_back",
"side": "phycon:block/redstone_controller_back",
"cable_end": "phycon:block/cable_cap_end",
"cable_side": "phycon:block/cable_straight"
},
"elements": [
{
"_comment": "cable center",
"from": [6, 6, 3],
"to": [10, 10, 16],
"faces": {
"down": { "texture": "#cable_side" },
"up": { "texture": "#cable_side" },
"south": { "texture": "#cable_end" },
"west": { "texture": "#cable_side", "rotation": 90, "uv": [6, 0, 10, 16] },
"east": { "texture": "#cable_side", "rotation": 90, "uv": [6, 0, 10, 16] }
}
},
{
"_comment": "redstone controller side",
"from": [0, 0, 0],
"to": [16, 16, 3],
"faces": {
"down": { "texture": "#side" },
"up": { "texture": "#side" },
"north": { "texture": "#front" },
"south": { "texture": "#back" },
"west": { "texture": "#side" },
"east": { "texture": "#side" }
}
}
],
"_test": [
{
"_comment": "cable center",
"from": [6, 6, 3],
"to": [10, 10, 16],
"faces": {
"down": { "texture": "#cable_side", "rotation": 270, "uv": [4, 6, 10, 10] },
"up": { "texture": "#cable_side", "rotation": 90, "uv": [4, 6, 10, 10] },
"south": { "texture": "#cable_end" },
"west": { "texture": "#cable_side", "uv": [4, 6, 10, 10] },
"east": { "texture": "#cable_side", "rotation": 180, "uv": [4, 6, 10, 10] }
}
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB