Compare commits

...

2 Commits

Author SHA1 Message Date
Shadowfacts 24b7896151
Add actual Redstone Controller model 2021-02-24 18:58:22 -05:00
Shadowfacts b283480edf
Localize more things 2021-02-23 22:39:51 -05:00
15 changed files with 189 additions and 57 deletions

View File

@ -27,14 +27,14 @@ class RedstoneControllerBlock: FaceDeviceBlock<RedstoneControllerBlockEntity>(Se
} }
// todo: don't just copy this from the Interface block // todo: don't just copy this from the Interface block
override val faceThickness = 2.0 override val faceThickness = 3.0
override val faceShapes = mapOf( override val faceShapes = mapOf(
Direction.DOWN to createCuboidShape(0.0, 0.0, 0.0, 16.0, 2.0, 16.0), Direction.DOWN to createCuboidShape(0.0, 0.0, 0.0, 16.0, 3.0, 16.0),
Direction.UP to createCuboidShape(0.0, 14.0, 0.0, 16.0, 16.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, 2.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, 14.0, 16.0, 16.0, 16.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, 2.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(14.0, 0.0, 0.0, 16.0, 16.0, 16.0) Direction.EAST to createCuboidShape(13.0, 0.0, 0.0, 16.0, 16.0, 16.0)
) )
override fun appendProperties(builder: StateManager.Builder<Block, BlockState>) { override fun appendProperties(builder: StateManager.Builder<Block, BlockState>) {
@ -55,20 +55,10 @@ class RedstoneControllerBlock: FaceDeviceBlock<RedstoneControllerBlockEntity>(Se
val wasLit = state[LIT] val wasLit = state[LIT]
val isLit = isPowered(world, pos, state[FACING]) val isLit = isPowered(world, pos, state[FACING])
if (wasLit != isLit) { if (wasLit != isLit) {
if (wasLit) {
world.blockTickScheduler.schedule(pos, this, 4)
} else {
toggleLit(state, world, pos) 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 { private fun isPowered(world: World, pos: BlockPos, facing: Direction): Boolean {
val offset = pos.offset(facing) val offset = pos.offset(facing)

View File

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

View File

@ -4,12 +4,9 @@ import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.client.gui.widget.ButtonWidget
import net.minecraft.client.util.math.MatrixStack 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.DeviceBlockEntity
import net.shadowfacts.phycon.network.component.ActivationController import net.shadowfacts.phycon.network.component.ActivationController
import net.shadowfacts.phycon.networking.C2SConfigureActivationMode import net.shadowfacts.phycon.networking.C2SConfigureActivationMode
import net.shadowfacts.phycon.util.ActivationMode
import net.shadowfacts.phycon.util.next import net.shadowfacts.phycon.util.next
import org.lwjgl.glfw.GLFW import org.lwjgl.glfw.GLFW
@ -66,10 +63,4 @@ class ActivatableDeviceConsoleScreen<T>(
textRenderer.draw(matrixStack, "MAC Address: ${device.macAddress}", minX + 5f, minY + 15f, 0x404040) 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,17 +1,14 @@
package net.shadowfacts.phycon.screen package net.shadowfacts.phycon.screen
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.font.TextRenderer
import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.client.gui.widget.ButtonWidget
import net.minecraft.client.gui.widget.TextFieldWidget import net.minecraft.client.gui.widget.TextFieldWidget
import net.minecraft.client.util.math.MatrixStack import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.LiteralText import net.minecraft.text.LiteralText
import net.minecraft.text.Text
import net.shadowfacts.phycon.api.util.IPAddress import net.shadowfacts.phycon.api.util.IPAddress
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlockEntity import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlockEntity
import net.shadowfacts.phycon.networking.C2SConfigureRedstoneController import net.shadowfacts.phycon.networking.C2SConfigureRedstoneController
import net.shadowfacts.phycon.util.RedstoneMode
import net.shadowfacts.phycon.util.next import net.shadowfacts.phycon.util.next
import org.lwjgl.glfw.GLFW import org.lwjgl.glfw.GLFW
@ -99,13 +96,4 @@ class RedstoneControllerConsoleScreen(
textRenderer.draw(matrixStack, "MAC Address: ${device.macAddress}", minX + 5f, minY + 15f, 0x404040) 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,9 +1,15 @@
package net.shadowfacts.phycon.util package net.shadowfacts.phycon.util
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
/** /**
* @author shadowfacts * @author shadowfacts
*/ */
enum class ActivationMode: RotatableEnum { enum class ActivationMode: RotatableEnum {
AUTOMATIC, AUTOMATIC,
MANAGED, MANAGED;
val friendlyName: Text
get() = TranslatableText("gui.phycon.activation_mode.${name.toLowerCase()}")
} }

View File

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

View File

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

View File

@ -8,5 +8,14 @@
"block.phycon.redstone_controller": "Redstone Controller", "block.phycon.redstone_controller": "Redstone Controller",
"item.phycon.screwdriver": "Screwdriver", "item.phycon.screwdriver": "Screwdriver",
"item.phycon.console": "Console" "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"
} }

View File

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

View File

@ -0,0 +1,33 @@
{
"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

@ -0,0 +1,33 @@
{
"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

@ -0,0 +1,51 @@
{
"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.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB