Browse Source

latest version for funni vin man

master
Martmists 2 years ago
parent
commit
dc46666113
  1. 15
      src/main/kotlin/com/martmists/ynet/screen/ControllerConfigScreenHandler.kt
  2. 10
      src/main/kotlin/com/martmists/ynet/screen/util/ColoredButtonWidget.kt
  3. 11
      src/main/resources/assets/ynet/lang/en_us.json

15
src/main/kotlin/com/martmists/ynet/screen/ControllerConfigScreenHandler.kt

@ -29,7 +29,9 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc @@ -29,7 +29,9 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc
val be = player.world.getBlockEntity(pos) as ControllerBlockEntity
var currentBlockSet = false
lateinit var currentChannel: Channel<*>
var channelIndex = -1
val currentChannel: Channel<*>
get() = be.network.channels[channelIndex]
lateinit var currentBlock: ConfiguredBlockEntity
lateinit var selectedButton: AbstractWidget
@ -122,9 +124,8 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc @@ -122,9 +124,8 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc
rpcButton = button ({ channelTypeButton ->
val types = YNetRegistry.getTypes().toMutableList().also { it.add(0, DisabledType) }
val newChannel = Channel(currentChannel.network, currentChannel.connectedBlocks.map { ConfiguredBlockEntity(it.controller, it.be, 0, InteractionMode.DISABLED, mutableListOf()) }.toMutableList(), types.next(currentChannel.type))
be.network.channels[be.network.channels.indexOf(currentChannel)] = newChannel
currentChannel = newChannel
channelTypeButton.label = TranslatableText(newChannel.type.identifier.toString().replace("ynet:", "ynet.ui."))
be.network.channels[channelIndex] = newChannel
channelTypeButton.label = TranslatableText(newChannel.type.identifier.toString().replace("ynet:", "ynet.ui.type."))
(selectedButton as ColoredButtonWidget).color = Color.ofRGB(newChannel.type.color)
be.markDirty()
}) {
@ -177,8 +178,8 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc @@ -177,8 +178,8 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc
for (x in 0 until 10) {
button(Color.ofRGB(be.network.channels[x].type.color), {
currentChannel = be.network.channels[x]
rpcButton.label = TranslatableText(currentChannel.type.identifier.toString().replace("ynet:", "ynet.ui."))
channelIndex = x
rpcButton.label = TranslatableText(currentChannel.type.identifier.toString().replace("ynet:", "ynet.ui.type."))
rpcText.text = TranslatableText("ynet.ui.channel.index", x)
rightPanelEmpty.hidden = true
rightPanelChannel.hidden = false
@ -282,6 +283,7 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc @@ -282,6 +283,7 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc
}
filterInventory.setStack(slotNumber, ItemStack.EMPTY)
}
be.markDirty()
}
return cursor
}
@ -298,6 +300,7 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc @@ -298,6 +300,7 @@ class ControllerConfigScreenHandler(syncId: Int, player: PlayerEntity, pos: Bloc
copy.count = 1
filterInventory.setStack(index, copy)
currentBlock.filter.add(copy)
be.markDirty()
return cursor
}
else -> {

10
src/main/kotlin/com/martmists/ynet/screen/util/ColoredButtonWidget.kt

@ -11,6 +11,7 @@ import com.github.vini2003.blade.common.utilities.Networks @@ -11,6 +11,7 @@ import com.github.vini2003.blade.common.utilities.Networks
import com.github.vini2003.blade.common.widget.OriginalWidgetCollection
import com.github.vini2003.blade.common.widget.WidgetCollection
import com.github.vini2003.blade.common.widget.base.AbstractWidget
import com.martmists.ynet.ext.ofRGB
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.sound.PositionedSoundInstance
import net.minecraft.client.util.math.MatrixStack
@ -25,15 +26,12 @@ class ColoredButtonWidget(private val clickAction: (ColoredButtonWidget) -> Unit @@ -25,15 +26,12 @@ class ColoredButtonWidget(private val clickAction: (ColoredButtonWidget) -> Unit
var disabled: Boolean = false
var label: Text? = null
override fun onAdded(original: OriginalWidgetCollection, immediate: WidgetCollection) {
super.onAdded(original, immediate)
init {
synchronize.add(Networks.MOUSE_CLICK)
}
override fun onMouseClicked(x: Float, y: Float, button: Int) {
if (focused) {
if (focused || (!focused && handler != null && !handler!!.client)) {
clickAction.invoke(this)
playSound()
@ -52,7 +50,7 @@ class ColoredButtonWidget(private val clickAction: (ColoredButtonWidget) -> Unit @@ -52,7 +50,7 @@ class ColoredButtonWidget(private val clickAction: (ColoredButtonWidget) -> Unit
val texture = if (disabled) textureOff else if (focused) textureOnFocus else textureOn
texture.draw(matrices, provider, position.x, position.y, size.width, size.height)
if (color == Color.of(0x000000)) {
if (color == Color.ofRGB(0x000000)) {
Drawings.drawQuad(matrices, provider, Layers.flat(), position.x, position.y, size.width, size.height, color)
}

11
src/main/resources/assets/ynet/lang/en_us.json

@ -1,13 +1,14 @@ @@ -1,13 +1,14 @@
{
"ynet.ui.mode": "Mode",
"ynet.ui.mode.insert": "Insert",
"ynet.ui.extract": "Extract",
"ynet.ui.disabled": "Disabled",
"ynet.ui.mode.extract": "Extract",
"ynet.ui.mode.disabled": "Disabled",
"ynet.ui.type": "Type",
"ynet.ui.item": "Items",
"ynet.ui.fluid": "Fluids",
"ynet.ui.energy": "Tech Reborn Energy",
"ynet.ui.type.disabled": "Disabled",
"ynet.ui.type.item": "Items",
"ynet.ui.type.fluid": "Fluids",
"ynet.ui.type.energy": "TR Energy",
"ynet.ui.priority": "Priority (TODO)",

Loading…
Cancel
Save