Compare commits
No commits in common. "2035874baaa04885a27944527033a7a568b5b3c7" and "815a9ab8afb664c8e5054f40765a8625393cffa2" have entirely different histories.
2035874baa
...
815a9ab8af
|
@ -45,12 +45,8 @@ dependencies {
|
|||
runtimeOnly project(":plugin:rei")
|
||||
include project(":plugin:rei")
|
||||
|
||||
modRuntime("io.github.cottonmc:cotton-resources:${project.cotton_resources_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
}
|
||||
modRuntime("com.terraformersmc:modmenu:${project.modmenu_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
}
|
||||
modRuntime "io.github.cottonmc:cotton-resources:${project.cotton_resources_version}"
|
||||
modRuntime "com.terraformersmc:modmenu:${project.modmenu_version}"
|
||||
|
||||
testImplementation "org.junit.jupiter:junit-jupiter:${project.junit_version}"
|
||||
}
|
||||
|
|
|
@ -33,12 +33,8 @@ dependencies {
|
|||
|
||||
implementation project(":")
|
||||
|
||||
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${project.rei_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
}
|
||||
modRuntime("me.shedaniel:RoughlyEnoughItems:${project.rei_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
}
|
||||
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api:${project.rei_version}"
|
||||
modRuntime "me.shedaniel:RoughlyEnoughItems:${project.rei_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
|
|
@ -17,7 +17,10 @@ import net.shadowfacts.phycon.api.packet.Packet
|
|||
import net.shadowfacts.phycon.init.PhyBlockEntities
|
||||
import net.shadowfacts.phycon.block.DeviceBlockEntity
|
||||
import net.shadowfacts.phycon.block.terminal.TerminalBlockEntity
|
||||
import net.shadowfacts.phycon.component.*
|
||||
import net.shadowfacts.phycon.component.ActivationController
|
||||
import net.shadowfacts.phycon.component.NetworkStackDispatcher
|
||||
import net.shadowfacts.phycon.component.NetworkStackProvider
|
||||
import net.shadowfacts.phycon.component.handleItemStack
|
||||
import net.shadowfacts.phycon.packet.*
|
||||
import net.shadowfacts.phycon.util.ActivationMode
|
||||
import net.shadowfacts.phycon.util.ClientConfigurableDevice
|
||||
|
@ -52,7 +55,6 @@ class MinerBlockEntity: DeviceBlockEntity(PhyBlockEntities.MINER),
|
|||
is ExtractStackPacket -> handleExtractStack(packet)
|
||||
is CapacityPacket -> handleCapacity(packet)
|
||||
is ItemStackPacket -> handleItemStack(packet)
|
||||
is RemoteActivationPacket -> controller.handleRemoteActivation(packet)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,11 +122,9 @@ class MinerBlockEntity: DeviceBlockEntity(PhyBlockEntities.MINER),
|
|||
override fun tick() {
|
||||
super.tick()
|
||||
|
||||
if (!world!!.isClient) {
|
||||
if (minerMode == MinerMode.AUTOMATIC) {
|
||||
controller.tick()
|
||||
}
|
||||
finishTimedOutPendingInsertions()
|
||||
if (!world!!.isClient && minerMode == MinerMode.AUTOMATIC) {
|
||||
|
||||
controller.tick()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@ class RedstoneControllerBlockEntity: DeviceBlockEntity(PhyBlockEntities.REDSTONE
|
|||
|
||||
var managedDevices = Array<IPAddress?>(5) { null }
|
||||
var redstoneMode = RedstoneMode.HIGH
|
||||
set(value) {
|
||||
field = value
|
||||
redstoneStateChanged()
|
||||
}
|
||||
|
||||
private var redstonePowered = false
|
||||
|
||||
|
@ -28,8 +24,6 @@ class RedstoneControllerBlockEntity: DeviceBlockEntity(PhyBlockEntities.REDSTONE
|
|||
}
|
||||
|
||||
fun redstoneStateChanged() {
|
||||
if (world!!.isClient) return
|
||||
|
||||
val oldPowered = redstonePowered
|
||||
redstonePowered = cachedState[RedstoneControllerBlock.POWERED]
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.shadowfacts.phycon.block.redstone_emitter
|
|||
import alexiil.mc.lib.attributes.item.GroupedItemInvView
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.text.TranslatableText
|
||||
import net.shadowfacts.phycon.api.packet.Packet
|
||||
import net.shadowfacts.phycon.api.util.IPAddress
|
||||
import net.shadowfacts.phycon.block.DeviceBlockEntity
|
||||
|
@ -27,11 +26,6 @@ class RedstoneEmitterBlockEntity: DeviceBlockEntity(PhyBlockEntities.REDSTONE_EM
|
|||
|
||||
var stackToMonitor: ItemStack = ItemStack.EMPTY
|
||||
var maxAmount = 64
|
||||
var mode = Mode.ANALOG
|
||||
set(value) {
|
||||
field = value
|
||||
recalculateRedstone()
|
||||
}
|
||||
|
||||
override fun handle(packet: Packet) {
|
||||
when (packet) {
|
||||
|
@ -67,8 +61,6 @@ class RedstoneEmitterBlockEntity: DeviceBlockEntity(PhyBlockEntities.REDSTONE_EM
|
|||
}
|
||||
|
||||
private fun recalculateRedstone() {
|
||||
if (world!!.isClient) return
|
||||
|
||||
if (stackToMonitor.isEmpty) {
|
||||
cachedEmittedPower = 0
|
||||
updateWorld()
|
||||
|
@ -78,15 +70,11 @@ class RedstoneEmitterBlockEntity: DeviceBlockEntity(PhyBlockEntities.REDSTONE_EM
|
|||
acc + inv.getAmount(stackToMonitor)
|
||||
}
|
||||
cachedEmittedPower =
|
||||
when (mode) {
|
||||
Mode.ANALOG -> if (networkAmount == 0) {
|
||||
0
|
||||
} else {
|
||||
1 + round(networkAmount / maxAmount.toDouble() * 14).toInt()
|
||||
}
|
||||
Mode.DIGITAL -> if (networkAmount >= maxAmount) 15 else 0
|
||||
if (networkAmount == 0) {
|
||||
0
|
||||
} else {
|
||||
1 + round(networkAmount / maxAmount.toDouble() * 14).toInt()
|
||||
}
|
||||
|
||||
updateWorld()
|
||||
}
|
||||
|
||||
|
@ -111,18 +99,9 @@ class RedstoneEmitterBlockEntity: DeviceBlockEntity(PhyBlockEntities.REDSTONE_EM
|
|||
|
||||
override fun writeDeviceConfiguration(tag: CompoundTag) {
|
||||
tag.putInt("MaxAmount", maxAmount)
|
||||
tag.putString("Mode", mode.name)
|
||||
}
|
||||
|
||||
override fun loadDeviceConfiguration(tag: CompoundTag) {
|
||||
maxAmount = tag.getInt("MaxAmount")
|
||||
mode = Mode.valueOf(tag.getString("Mode"))
|
||||
}
|
||||
|
||||
enum class Mode {
|
||||
ANALOG, DIGITAL;
|
||||
|
||||
val friendlyName = TranslatableText("gui.phycon.redstone_emitter_mode.${name.toLowerCase()}")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@ class TerminalScreen(handler: TerminalScreenHandler, playerInv: PlayerInventory,
|
|||
if (value && !oldValue) {
|
||||
amountBox.text = "1"
|
||||
}
|
||||
updateFocusedElement()
|
||||
}
|
||||
private var dialogChildren = mutableListOf<AbstractButtonWidget>()
|
||||
|
||||
|
@ -163,20 +162,9 @@ class TerminalScreen(handler: TerminalScreenHandler, playerInv: PlayerInventory,
|
|||
}
|
||||
dialogChildren.add(request)
|
||||
|
||||
updateFocusedElement()
|
||||
requestUpdatedItems()
|
||||
}
|
||||
|
||||
private fun updateFocusedElement() {
|
||||
focused = if (showingAmountDialog) {
|
||||
amountBox
|
||||
} else if (searchBox.isFocused) {
|
||||
searchBox
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestUpdatedItems() {
|
||||
val player = MinecraftClient.getInstance().player!!
|
||||
player.networkHandler.sendPacket(C2STerminalUpdateDisplayedItems(handler.terminal, searchBox.text, sortButton.mode, scrollPosition))
|
||||
|
@ -272,7 +260,8 @@ class TerminalScreen(handler: TerminalScreenHandler, playerInv: PlayerInventory,
|
|||
override fun onMouseClick(slot: Slot?, invSlot: Int, clickData: Int, type: SlotActionType?) {
|
||||
super.onMouseClick(slot, invSlot, clickData, type)
|
||||
|
||||
updateFocusedElement()
|
||||
// don't unfocus the search box on mouse click
|
||||
searchBox.setSelected(true)
|
||||
|
||||
if (slot != null && !slot.stack.isEmpty && handler.isNetworkSlot(slot.id)) {
|
||||
val stack = slot.stack
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.shadowfacts.phycon.screen.console.DeviceConsoleScreen
|
|||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class ConsoleItem: Item(Settings().maxCount(1)) {
|
||||
class ConsoleItem: Item(Settings()) {
|
||||
companion object {
|
||||
val ID = Identifier(PhysicalConnectivity.MODID, "console")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.shadowfacts.phycon.util.containsInclusive
|
|||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class ScrewdriverItem: Item(Settings().maxCount(1)) {
|
||||
class ScrewdriverItem: Item(Settings()) {
|
||||
companion object {
|
||||
val ID = Identifier(PhysicalConnectivity.MODID, "screwdriver")
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import net.shadowfacts.kiwidsl.dsl
|
|||
import net.shadowfacts.phycon.block.DeviceBlockEntity
|
||||
import net.shadowfacts.phycon.block.miner.MinerBlockEntity
|
||||
import net.shadowfacts.phycon.block.redstone_controller.RedstoneControllerBlockEntity
|
||||
import net.shadowfacts.phycon.block.redstone_emitter.RedstoneEmitterBlockEntity
|
||||
import net.shadowfacts.phycon.component.ActivationController
|
||||
import net.shadowfacts.phycon.component.NetworkStackProvider
|
||||
import net.shadowfacts.phycon.component.NetworkStackReceiver
|
||||
|
@ -81,15 +80,6 @@ class DeviceConsoleScreen(
|
|||
ReceiverViewController(device),
|
||||
))
|
||||
}
|
||||
if (device is RedstoneEmitterBlockEntity) {
|
||||
tabs.add(TabViewController.SimpleTab(
|
||||
TextureView(Texture(Identifier("textures/item/redstone.png"), 0, 0, 16, 16)).apply {
|
||||
intrinsicContentSize = Size(16.0, 16.0)
|
||||
},
|
||||
TranslatableText("block.phycon.redstone_emitter"),
|
||||
RedstoneEmitterViewController(device)
|
||||
))
|
||||
}
|
||||
|
||||
tabController = TabViewController(tabs)
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package net.shadowfacts.phycon.screen.console
|
||||
|
||||
import net.minecraft.client.MinecraftClient
|
||||
import net.minecraft.text.TranslatableText
|
||||
import net.shadowfacts.cacao.util.Color
|
||||
import net.shadowfacts.cacao.view.Label
|
||||
import net.shadowfacts.cacao.view.button.EnumButton
|
||||
import net.shadowfacts.cacao.viewcontroller.ViewController
|
||||
import net.shadowfacts.kiwidsl.dsl
|
||||
import net.shadowfacts.phycon.block.redstone_emitter.RedstoneEmitterBlockEntity
|
||||
import net.shadowfacts.phycon.networking.C2SConfigureDevice
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class RedstoneEmitterViewController(
|
||||
val device: RedstoneEmitterBlockEntity,
|
||||
): ViewController() {
|
||||
|
||||
override fun viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
val label = Label(TranslatableText("gui.phycon.console.emitter.mode")).apply {
|
||||
textColor = Color.TEXT
|
||||
}
|
||||
view.addSubview(label)
|
||||
|
||||
val mode = EnumButton(device.mode, RedstoneEmitterBlockEntity.Mode::friendlyName)
|
||||
mode.handler = {
|
||||
device.mode = it.value
|
||||
MinecraftClient.getInstance().player!!.networkHandler.sendPacket(C2SConfigureDevice(device))
|
||||
}
|
||||
view.addSubview(mode)
|
||||
|
||||
view.solver.dsl {
|
||||
mode.widthAnchor equalTo 100
|
||||
mode.heightAnchor equalTo 20
|
||||
mode.topAnchor equalTo view.topAnchor
|
||||
mode.rightAnchor equalTo view.rightAnchor
|
||||
|
||||
label.centerYAnchor equalTo mode.centerYAnchor
|
||||
label.rightAnchor equalTo (mode.leftAnchor - 4)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -32,7 +32,6 @@
|
|||
"gui.phycon.console.receiver.priority": "Receiver Priority",
|
||||
"gui.phycon.console.receiver.priority_desc": "When a device puts items into the network, it starts with receiver (e.g., interfaces) with higher priorities. Priorities can be negative.",
|
||||
"gui.phycon.console.receiver.sync": "Sync with Provider Priority",
|
||||
"gui.phycon.console.emitter.mode": "Measurement Mode",
|
||||
"gui.phycon.redstone_mode.high": "High",
|
||||
"gui.phycon.redstone_mode.low": "Low",
|
||||
"gui.phycon.redstone_mode.toggle": "Toggle",
|
||||
|
@ -43,22 +42,7 @@
|
|||
"gui.phycon.emitter.count": "%d Item(s)",
|
||||
"gui.phycon.miner_mode.automatic": "Automatic",
|
||||
"gui.phycon.miner_mode.on_demand": "On Demand",
|
||||
"gui.phycon.redstone_emitter_mode.analog": "Analog",
|
||||
"gui.phycon.redstone_emitter_mode.digital": "Digital",
|
||||
|
||||
"tooltip.phycon.device.configured": "Configured",
|
||||
"tooltip.phycon.device.ip": "IP: ",
|
||||
|
||||
"advancements.phycon.root.title": "Physical Connectivity",
|
||||
"advancements.phycon.root.description": "Mass item storage and local networking",
|
||||
"advancements.phycon.cable.title": "At a Distance",
|
||||
"advancements.phycon.cable.description": "Place Cables to connect multiple devices",
|
||||
"advancements.phycon.interface.title": "Attachment",
|
||||
"advancements.phycon.interface.description": "Place a Network Interface on a Cable to connect to a Chest",
|
||||
"advancements.phycon.terminal.title": "Spooky Action",
|
||||
"advancements.phycon.terminal.description": "Use a Terminal to interact with a Chest",
|
||||
"advancements.phycon.switch.title": "Interchange",
|
||||
"advancements.phycon.switch.description": "Connect multiple devices with a Network Switch",
|
||||
"advancements.phycon.console.title": "Console",
|
||||
"advancements.phycon.console.description": "Configure a networked device"
|
||||
"tooltip.phycon.device.ip": "IP: "
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"parent": "phycon:root",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "phycon:cable"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.phycon.cable.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.phycon.cable.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": true,
|
||||
"announce_to_chat": true,
|
||||
"hidden": false
|
||||
},
|
||||
"criteria": {
|
||||
"cable": {
|
||||
"trigger": "minecraft:placed_block",
|
||||
"conditions": {
|
||||
"block": "phycon:cable",
|
||||
"item": {
|
||||
"item": "phycon:cable"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"cable"
|
||||
]
|
||||
]
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
"parent": "phycon:switch",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "phycon:console"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.phycon.console.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.phycon.console.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": true,
|
||||
"announce_to_chat": true,
|
||||
"hidden": false
|
||||
},
|
||||
"criteria": {
|
||||
"console": {
|
||||
"trigger": "minecraft:item_used_on_block",
|
||||
"conditions": {
|
||||
"item": {
|
||||
"item": "phycon:console"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"console"
|
||||
]
|
||||
]
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"parent": "phycon:cable",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "phycon:network_interface"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.phycon.interface.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.phycon.interface.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": true,
|
||||
"announce_to_chat": true,
|
||||
"hidden": false
|
||||
},
|
||||
"criteria": {
|
||||
"interface": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"item": "phycon:network_interface"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"interface"
|
||||
]
|
||||
]
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "phycon:terminal"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.phycon.root.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.phycon.root.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": false,
|
||||
"announce_to_chat": false,
|
||||
"hidden": false,
|
||||
"background": "phycon:textures/block/casing.png"
|
||||
},
|
||||
"criteria": {
|
||||
"copper": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"tag": "c:copper_ingots"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"copper"
|
||||
]
|
||||
]
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"parent": "phycon:cable",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "phycon:switch"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.phycon.switch.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.phycon.switch.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": true,
|
||||
"announce_to_chat": true,
|
||||
"hidden": false
|
||||
},
|
||||
"criteria": {
|
||||
"switch": {
|
||||
"trigger": "minecraft:placed_block",
|
||||
"conditions": {
|
||||
"block": "phycon:switch",
|
||||
"item": {
|
||||
"item": "phycon:switch"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"switch"
|
||||
]
|
||||
]
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"parent": "phycon:network_interface",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "phycon:terminal"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.phycon.terminal.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.phycon.terminal.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": true,
|
||||
"announce_to_chat": true,
|
||||
"hidden": false
|
||||
},
|
||||
"criteria": {
|
||||
"terminal": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"item": "phycon:terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"terminal"
|
||||
]
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue