Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/multiblock power rewrite #907

Closed
wants to merge 500 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
500 commits
Select commit Hold shift + click to select a range
aee139b
Register mirrored variants
Gutin1 Nov 4, 2024
60106e5
Rename prepackaged to multiblock items tokens, full prepackaged imple…
Gutin1 Nov 4, 2024
62795a6
give more multiblocks display names
Gutin1 Nov 4, 2024
ec8305b
undo decomp visuals
Gutin1 Nov 4, 2024
3039099
Add a try catch, fix initialization order, remove old powered multibl…
Gutin1 Nov 4, 2024
84f0f5c
Add back simple powered multiblock entity but with working initializa…
Gutin1 Nov 4, 2024
7e30461
unregister ionworlds after components
Gutin1 Nov 4, 2024
63e28fc
Fix initialization order problems
Gutin1 Nov 4, 2024
c98eea8
missed a couple more, data saving improvements
Gutin1 Nov 4, 2024
08c7055
half implemented replacement recipe system
Gutin1 Nov 7, 2024
4654ebe
start of node replacement
Gutin1 Nov 8, 2024
8309e3b
Add back more nodes to new system
Gutin1 Nov 9, 2024
1a15d7f
Halfway through implementation
Gutin1 Nov 10, 2024
dc65285
Add extractor manager, migrate more code
Gutin1 Nov 10, 2024
5b5dd44
Fixing up
Gutin1 Nov 10, 2024
626b699
Get pathfinding working again
Gutin1 Nov 11, 2024
4a0ed6c
Remove old transport nodes
Gutin1 Nov 11, 2024
eb61363
move files around
Gutin1 Nov 11, 2024
bffaf4c
Register extractors in the new system
Gutin1 Nov 11, 2024
51d16e3
Add input manager
Gutin1 Nov 11, 2024
0be6409
Add input locations to multiblock classes, register / release them
Gutin1 Nov 11, 2024
978f4c5
Debug command
Gutin1 Nov 11, 2024
21706fb
move power cell input to the right spot
Gutin1 Nov 11, 2024
8b68582
get multis from input
Gutin1 Nov 11, 2024
cd38c10
debug commands
Gutin1 Nov 12, 2024
2905be5
Simplify pathfinding
Gutin1 Nov 12, 2024
05f33f7
Get powered entities from input manager
Gutin1 Nov 12, 2024
608f98e
Get transfer working
Gutin1 Nov 12, 2024
cb5d79a
tick extractors
Gutin1 Nov 12, 2024
d5fb2bd
Provide block key to cache
Gutin1 Nov 13, 2024
a75e392
give flow meter key
Gutin1 Nov 13, 2024
477c4a2
Add util functions to cached nodes
Gutin1 Nov 13, 2024
aa1df55
Add display back to power flow meter
Gutin1 Nov 13, 2024
2e000f3
Give extractors metadata, reimplement transfer delta
Gutin1 Nov 13, 2024
bead8df
invalidate cache on block change
Gutin1 Nov 13, 2024
7335d09
remove power flow meter display when invalidated
Gutin1 Nov 13, 2024
83ac26e
move files around, rename stuff
Gutin1 Nov 13, 2024
3853d21
clean up power transfer code
Gutin1 Nov 13, 2024
9da1916
synchronize cache access
Gutin1 Nov 13, 2024
79dd511
implement hacky fix for lag
Gutin1 Nov 13, 2024
75a8b8f
Implement fluid nodes
Gutin1 Nov 14, 2024
b15bb38
add fluid junction node w/ channels
Gutin1 Nov 14, 2024
6d24156
fix + util
Gutin1 Nov 14, 2024
2967aaa
Utility functions for fluid transfer, additional capabilities
Gutin1 Nov 14, 2024
a7e9b06
Add holder to text display handler for reliability
Gutin1 Nov 14, 2024
579a64a
add item requirement to multiblock shape
Gutin1 Nov 14, 2024
e3c6c40
Add multiblock workbench
Gutin1 Nov 15, 2024
452d730
Abstract out tool mod menu
Gutin1 Nov 15, 2024
c3a4396
add util for component inventory names
Gutin1 Nov 15, 2024
f5d354b
further abstraction, work on the workbench
Gutin1 Nov 15, 2024
347f1ac
Set second line to multiblock
Gutin1 Nov 15, 2024
dc6f340
Check item requirements
Gutin1 Nov 15, 2024
eb20532
half of item requirenments
Gutin1 Nov 16, 2024
7904345
improve item consumption, packaging
Gutin1 Nov 16, 2024
105d2c5
cleanup
Gutin1 Nov 16, 2024
8696cba
Remove magic numbers, more cleanup, some comments
Gutin1 Nov 16, 2024
9dce55f
Remember what block was used
Gutin1 Nov 16, 2024
eacf527
Move placement modifications to their own function
Gutin1 Nov 16, 2024
b07a004
Add search function
Gutin1 Nov 18, 2024
bdbbc41
Add hints for next / prior multiblocks
Gutin1 Nov 18, 2024
76effc7
Add recipe for multiblock workbench
Gutin1 Nov 18, 2024
a34f23d
fix block requirement alias
Gutin1 Nov 18, 2024
10425bb
Fluid work
Gutin1 Nov 19, 2024
5ef2d97
Remove printlns
Gutin1 Nov 19, 2024
5095beb
Transport code cleanup
Gutin1 Nov 19, 2024
77cf88f
actually save extractor data, more organization
Gutin1 Nov 20, 2024
428208b
rename gas fluids to gas to allow future liquid variants
Gutin1 Nov 20, 2024
6b0ddf6
name them low pressure too
Gutin1 Nov 20, 2024
34fd61e
Multiblock linkage system
Gutin1 Nov 23, 2024
46bdcf2
Adjust ElectrolysisMultiblock shape
Gutin1 Nov 23, 2024
fd8cde6
Remove printlns
Gutin1 Nov 23, 2024
13f817b
Clean up old namespaced keys
Gutin1 Nov 23, 2024
9b2a807
Proper merge nodes
Gutin1 Nov 24, 2024
0a78dc8
Already move it to its own class
Gutin1 Nov 24, 2024
8396c1c
Add sign handling to prepackaged, ability to pick up multis with wrench
Gutin1 Nov 24, 2024
2b78b20
only setup multiblock entity if it had the data, optionally allow blo…
Gutin1 Nov 25, 2024
af4681a
add slab preset
Gutin1 Nov 25, 2024
269a701
more prepackaged presets
Gutin1 Nov 25, 2024
a0a172f
Check for invalid multiblock entities on startup
Gutin1 Nov 25, 2024
a7c9cfc
Prevent power / fluid dupe
Gutin1 Nov 25, 2024
7803496
Get relative face from 2 faces
Gutin1 Nov 25, 2024
30def72
StructureCreator command
Gutin1 Nov 25, 2024
7cddbb6
add permission
Gutin1 Nov 25, 2024
049c498
fix double slabs
Gutin1 Nov 25, 2024
364445f
add more aliases
Gutin1 Nov 25, 2024
a75f8c4
Multiblock shape cleanup and standardization
Gutin1 Nov 25, 2024
e832788
Add trapdoor preset
Gutin1 Nov 26, 2024
0ad9586
Add grindstone preset
Gutin1 Nov 26, 2024
c0ad66f
Add lightning rod, end rod
Gutin1 Nov 26, 2024
8e5a8f3
add inventories
Gutin1 Nov 26, 2024
90a2c64
untested solar panels
Gutin1 Nov 26, 2024
9529e96
Register solar panel cache, proper network type
Gutin1 Nov 26, 2024
432ba08
fix bug, organize
Gutin1 Nov 27, 2024
e6fdaa1
prevent some wireless power transfer scenarios
Gutin1 Nov 27, 2024
9f49556
big fixes, reliability, re-enable sign migrator
Gutin1 Nov 27, 2024
d1e4bb6
don't disable the drill every tick
Gutin1 Nov 27, 2024
8a6f70e
do that better
Gutin1 Nov 27, 2024
28b8a50
copy paper thread dump code into a command
Gutin1 Nov 28, 2024
548483a
Lag improvements, cleanup
Gutin1 Nov 29, 2024
3d9ec7d
check structure async then sync tick
Gutin1 Nov 29, 2024
cd4f974
misc
Gutin1 Nov 29, 2024
4a69064
fix auto crafter lag
Gutin1 Nov 29, 2024
0994351
actually bother to load extractors, routine saving
Gutin1 Nov 30, 2024
e8c32dd
Start work on filter implementation
Gutin1 Nov 30, 2024
579d5e3
Allow placement, drops when shift right click
Gutin1 Dec 1, 2024
4450789
load extractors if no data is present
Gutin1 Dec 1, 2024
cc87a36
black fluid filter interactions if not holding a wrench
Gutin1 Dec 1, 2024
5282599
private
Gutin1 Dec 1, 2024
4681d4f
Add serializable filter data
Gutin1 Dec 1, 2024
744e36b
upstream fixes
Gutin1 Dec 1, 2024
096b23b
re-register large tractor beam
Gutin1 Dec 1, 2024
f1c7ca7
Check multiblock integrity when smacking a sign with a wrench
Gutin1 Dec 1, 2024
67e140a
remove unused function
Gutin1 Dec 1, 2024
9d67aa4
Add filter transport nodes
Gutin1 Dec 3, 2024
3d084c5
capture nodes & extractors when ship pilots, delete old extractors
Gutin1 Dec 4, 2024
7fc46e2
capture nodes & extractors when ship pilots, delete old extractors
Gutin1 Dec 5, 2024
44b7381
don't check chunks if holder is ship
Gutin1 Dec 5, 2024
1462812
fix display rotation
Gutin1 Dec 5, 2024
646f316
reformat debug commands, fix node displacement
Gutin1 Dec 5, 2024
a2de769
fix upstream :(
Gutin1 Dec 20, 2024
97e0268
Fix up wrench, workbench
Gutin1 Dec 30, 2024
665ecfd
fix comodification error, initialization order problem
Gutin1 Dec 30, 2024
c146273
fix for custom turret rendering (temporary)
diena1dev Dec 31, 2024
e72c41c
added BLACK_ENERGY_SWORD recipe
diena1dev Dec 31, 2024
1593179
removed BLACK_ENERGY_SWORD recipe and corresponding imports
diena1dev Jan 1, 2025
1b6e689
Sign text util to avoid raw arrays
Gutin1 Dec 30, 2024
0559097
work on fixes
Gutin1 Dec 30, 2024
b647975
disable fluid for now, fix upstream changes
Gutin1 Jan 2, 2025
978c0f7
fix number format
Gutin1 Jan 11, 2025
152f187
skip multiblocks that could not be deserialized
Gutin1 Jan 11, 2025
6a25f89
fix build limit bug
Gutin1 Jan 11, 2025
0bc4f10
fix build limit bug
Gutin1 Jan 11, 2025
2faf0cd
update packaged multiblocks to 1.21
Gutin1 Jan 12, 2025
9001f89
Add side panel
Gutin1 Jan 12, 2025
ef76132
fix some multiblock names
Gutin1 Jan 12, 2025
6fee342
Rewrite displays, todo make them work again
Gutin1 Jan 12, 2025
2b61289
Remove block entity data filter system
Gutin1 Jan 12, 2025
dab22a0
silly model creator, make use of them
Gutin1 Jan 13, 2025
f499861
Add more descriptions / display names
Gutin1 Jan 13, 2025
10b8509
remove printlns
Gutin1 Jan 13, 2025
577bc33
Add a basic path cache
Gutin1 Jan 13, 2025
bdc3b35
Fix display entities, code cleanup and remove magic numbers
Gutin1 Jan 14, 2025
6c89aba
add power metrics
Gutin1 Jan 14, 2025
b463c77
pathing fixes
Gutin1 Jan 15, 2025
6f2404a
prioritize input nodes in addition to forward
Gutin1 Jan 15, 2025
0274481
Fix initialization order problem with power flow meter
Gutin1 Jan 15, 2025
fc51dff
start of (attempt 4) permanent multiblock recipe system
Gutin1 Jan 16, 2025
ac4ff34
work on the base recipe class
Gutin1 Jan 16, 2025
4a2f588
probably everything I need to migrate recipes over
Gutin1 Jan 16, 2025
d08a32b
abstract for the future
Gutin1 Jan 16, 2025
0d73b1b
more code
Gutin1 Jan 16, 2025
087835c
Add progress recipe for testing
Gutin1 Jan 16, 2025
88077b1
some optimizations, work on progress recipes, fix tick interval
Gutin1 Jan 16, 2025
c17e9b4
Add industry entity, migrate industry entities to it
Gutin1 Jan 17, 2025
9aa9f3e
fix progress result power consumption during normal ticking
Gutin1 Jan 17, 2025
b96ed5f
Make progress result more general use, rename to WarmupResult, build …
Gutin1 Jan 17, 2025
71cbd56
rework results again, use a transaction and separate environment
Gutin1 Jan 17, 2025
09d6d05
migrate recipes over
Gutin1 Jan 17, 2025
aa45ab1
Store the sleep tick end as an epoch milli to make it independent of …
Gutin1 Jan 18, 2025
5307413
move solar panel cache
Gutin1 Jan 18, 2025
187ce93
Add item transport cache
Gutin1 Jan 18, 2025
ec0762d
Store ship nodes & multiblocks in relative positions
Gutin1 Jan 20, 2025
58aa057
Working power transfer on ships
Gutin1 Jan 21, 2025
2ecf7ba
Improved rolling average
Gutin1 Jan 21, 2025
dd4ccc5
typo
Gutin1 Jan 22, 2025
bb832bb
Serialization util
Gutin1 Jan 22, 2025
02493e2
start work on new types of extractors
Gutin1 Jan 22, 2025
da04a71
Move extractor type check from material to block data
Gutin1 Jan 22, 2025
7849295
Change up extractor storage
Gutin1 Jan 22, 2025
f0ddb18
Add item extractor
Gutin1 Jan 22, 2025
724176d
Add pick block for custom items
Gutin1 Jan 22, 2025
e1f1e21
expand gui util
Gutin1 Jan 23, 2025
1b98d96
add cycling for testing
Gutin1 Jan 23, 2025
f64ede0
Build out more item transfer code
Gutin1 Jan 23, 2025
343500b
Implement destination methods
Gutin1 Jan 23, 2025
372d22d
filter out non non-empty inventories (todo full check)
Gutin1 Jan 23, 2025
af53464
Add back filter data structures
Gutin1 Jan 23, 2025
1d06cb7
Add item filter data system, item, gui
Gutin1 Jan 24, 2025
4cf6b57
change item serialization method
Gutin1 Jan 24, 2025
ac53bd6
fix saving, retrieve data from state
Gutin1 Jan 24, 2025
733c9e7
implement filter type specific meta data
Gutin1 Jan 25, 2025
d116f8c
integrate filter into nodes
Gutin1 Jan 26, 2025
a9cf14e
Use filters when pathfinding
Gutin1 Jan 27, 2025
81b1399
Path cache invalidation
Gutin1 Jan 27, 2025
341d737
Ignore cached paths for items, pending compound path keys
Gutin1 Jan 27, 2025
28bc9cf
bare minimum Item transaction
Gutin1 Jan 27, 2025
d4c81a4
build better transaction code
Gutin1 Jan 28, 2025
525e2d5
non-silent exception handling, some other fixes and improvements
Gutin1 Jan 28, 2025
aa61762
move transaction to item
Gutin1 Jan 28, 2025
7bde031
Fix item removal
Gutin1 Jan 28, 2025
547694e
store chunk filters, load from stored data if not present
Gutin1 Jan 29, 2025
faf619d
Convert advanced extractors to command blocks, back up data to them, …
Gutin1 Jan 29, 2025
3cbf511
save chunk filter manager
Gutin1 Jan 29, 2025
25710ac
make command blocks flyable
Gutin1 Jan 29, 2025
f085e17
Move node cache factory to cache type
Gutin1 Jan 29, 2025
853f43a
group by inventory
Gutin1 Jan 29, 2025
5432d02
shorten E/sec to delta e
Gutin1 Jan 30, 2025
f6258b2
Back item transfers with removals from origin
Gutin1 Jan 30, 2025
9d83015
remove printlns, extended logging
Gutin1 Jan 30, 2025
a2209dd
Remove sources from destinations
Gutin1 Jan 30, 2025
f62a618
compare block entities rather than craft inventories
Gutin1 Jan 31, 2025
932e9a2
Allow pathfinds over the same block up to 6 times
Gutin1 Jan 31, 2025
79d3b7f
Fix pilot exception
Gutin1 Jan 31, 2025
959a1d2
Setpower from signs
Gutin1 Jan 31, 2025
1b256ab
Subtract common minimum resistance
Gutin1 Jan 31, 2025
dfa93e5
prevent double hits
Gutin1 Jan 31, 2025
31f5ccf
handle double chests
Gutin1 Jan 31, 2025
417cb77
prevent double chest self transfer
Gutin1 Jan 31, 2025
d37db27
code cleanup, ensure left chest halves are correct regardless of orig…
Gutin1 Jan 31, 2025
69d0ebd
WIP: First pass at multiblock descriptions
kwazedilla Jan 31, 2025
54736fe
WIP: more progress on names and desc (formatting fixes, colored tier …
kwazedilla Jan 31, 2025
5cc53c6
WIP: Finish the rest of the multiblock descriptions
kwazedilla Feb 1, 2025
a8a855f
fixed some formatting issues
kwazedilla Feb 1, 2025
dc87cf6
fix comment
Gutin1 Jan 31, 2025
63c0cbe
Improve world edit integration
Gutin1 Feb 1, 2025
455c890
Replace command blocks with creaking hearts
Gutin1 Feb 1, 2025
56e88d3
Fix exception when loading filters
Gutin1 Feb 1, 2025
d66646f
Add display names to sorting methods
Gutin1 Feb 1, 2025
25f1247
Advanced item extractor gui
Gutin1 Feb 1, 2025
5c96c64
sort round-robin index by distance
Gutin1 Feb 2, 2025
24c6d50
make unselected options gray
Gutin1 Feb 2, 2025
5a3f199
make creaking heart fly
Gutin1 Feb 2, 2025
df7b3f1
menu adjustment
Gutin1 Feb 2, 2025
49a79cb
Redo path cache to allow for different values
Gutin1 Feb 2, 2025
b393ce1
Shift click to not open menus
Gutin1 Feb 2, 2025
055c36d
More robust cache invalidation
Gutin1 Feb 2, 2025
1750c40
don't go all the way up to the line when backing up multis
Gutin1 Feb 2, 2025
cd89d22
Right comes before left in nms
Gutin1 Feb 2, 2025
11751f1
add callback when placing custom block
Gutin1 Feb 2, 2025
535382f
when placing grab the filter & extractor data from the item
Gutin1 Feb 2, 2025
ee3171d
Allow wrench to pick up filters & Extractors, fix filter method saving
Gutin1 Feb 3, 2025
bb1bbd5
dont consume packaged multis in creative
Gutin1 Feb 3, 2025
8cf3a42
change advanced item extractor model
kwazedilla Feb 3, 2025
acd3806
base of ship factory v2
Gutin1 Feb 3, 2025
b649938
item filter model (and move multiblock workbench model)
kwazedilla Feb 4, 2025
d3df041
Store settings
Gutin1 Feb 4, 2025
ec3c95b
Synchronize ionchunk access
Gutin1 Feb 4, 2025
837766e
advanced ship factory gui initial background
kwazedilla Feb 5, 2025
0e0355b
organize a little
Gutin1 Feb 5, 2025
9bb1383
add directional custom blocks
Gutin1 Feb 5, 2025
3696ceb
convert new custom blocks to vaults, disable vault mechanics
Gutin1 Feb 5, 2025
2819a00
Allow placement of directional custom blocks
Gutin1 Feb 5, 2025
69618a3
Make item filter node use face
Gutin1 Feb 5, 2025
3c2f04e
closer item pipe configuration
Gutin1 Feb 6, 2025
b4989cf
fix grindstone node
Gutin1 Feb 6, 2025
63679e2
invalidate path cache on node addition
Gutin1 Feb 6, 2025
a72fd17
probably fix silent stack overflow
Gutin1 Feb 6, 2025
4e24d2f
another merge node bug
Gutin1 Feb 6, 2025
850c208
WIP: more ship factory GUI buttons
kwazedilla Feb 6, 2025
afc16ed
Actually fix the silent stackoverflow
Gutin1 Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
non-silent exception handling, some other fixes and improvements
  • Loading branch information
Gutin1 committed Jan 28, 2025
commit 525e2d5242e930b06b78ac8bf8f8fe3f8499c30e
Original file line number Diff line number Diff line change
@@ -212,7 +212,7 @@ object TransportDebugCommand : SLCommand() {
sender.highlightBlocks(destinations.map(::toVec3i), 50L)
}

const val COLLECT_TRANSPORT_METRICS = true
const val COLLECT_TRANSPORT_METRICS = false

val floodFillTimes = LinkedBlockingDeque<Long>(10_000)
val solarFloodFillTimes = LinkedBlockingDeque<Long>(10_000)
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ class ItemFilterGui(val viewer: Player, private val data: FilterData<ItemStack,
if (cursor.isEmpty) {
entry.value = null
} else {
entry.value = cursor.clone()
entry.value = cursor.asQuantity(1)
}

notifyWindows()
Original file line number Diff line number Diff line change
@@ -30,8 +30,8 @@ import kotlin.concurrent.fixedRateTimer
object NewTransport : IonServerComponent(runAfterTick = true /* Run after tick to wait on the full server startup. */) {
private val transportManagers = ConcurrentHashMap.newKeySet<TransportManager<*>>()

lateinit var monitorThread: Timer
lateinit var executor: ExecutorService
private lateinit var monitorThread: Timer
private lateinit var executor: ExecutorService

override fun onEnable() {
executor = Executors.newFixedThreadPool(64, Tasks.namedThreadFactory("wire-transport"))
@@ -58,6 +58,17 @@ object NewTransport : IonServerComponent(runAfterTick = true /* Run after tick t
saveExtractors()
}

fun runTask(task: () -> Unit) {
executor.execute {
try {
task.invoke()
} catch (e: Throwable) {
log.error("Encountered exception when executing async transport task: ${e.message}")
e.printStackTrace()
}
}
}

fun registerTransportManager(manager: TransportManager<*>) {
transportManagers.add(manager)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.horizonsend.ion.server.features.transport.filters

import net.horizonsend.ion.common.utils.text.toComponent
import net.horizonsend.ion.server.IonServerComponent
import net.horizonsend.ion.server.features.transport.filters.FilterMeta.EmptyFilterMeta
import net.horizonsend.ion.server.features.transport.filters.FilterMeta.ItemFilterMeta
import net.horizonsend.ion.server.features.transport.fluids.Fluid
@@ -109,7 +110,7 @@ abstract class FilterType<T : Any, M : FilterMeta>(
}
}

companion object {
companion object : IonServerComponent() {
private val byId = mapOf("FLUID" to FluidType, "ITEMS" to ItemType)

operator fun get(identifier: String): FilterType<*, *> = byId[identifier] ?: throw NoSuchElementException("Filter type $identifier not found")
Original file line number Diff line number Diff line change
@@ -44,21 +44,21 @@ class FluidTransportCache(holder: CacheHolder<FluidTransportCache>): TransportCa
.addSimpleNode(Material.LAPIS_BLOCK, FluidNode.FluidInvertedMergeNode)
.build()

override fun tickExtractor(location: BlockKey, delta: Double, metaData: ExtractorMetaData?) { NewTransport.executor.submit {
override fun tickExtractor(location: BlockKey, delta: Double, metaData: ExtractorMetaData?) { NewTransport.runTask {
val world = holder.getWorld()
val sources = getExtractorSourceEntities<FluidStoringEntity>(location) { it.isEmpty() }
val source = sources.randomOrNull() ?: return@submit //TODO take from all
val source = sources.randomOrNull() ?: return@runTask //TODO take from all

if (source.getStoredResources().isEmpty()) return@submit
if (source.getStoredResources().isEmpty()) return@runTask

val originNode = holder.nodeProvider.invoke(type, holder.getWorld(), location) ?: return@submit
val originNode = holder.nodeProvider.invoke(type, holder.getWorld(), location) ?: return@runTask

// Flood fill on the network to find power inputs, and check input data for multiblocks using that input that can store any power
val destinations: Collection<BlockKey> = getNetworkDestinations<FluidNode.FluidInputNode>(location, originNode) { node ->
world.ion.inputManager.getHolders(type, node.position).any { entity -> entity is FluidStoringEntity && !entity.isFull() }
}

if (destinations.isEmpty()) return@submit
if (destinations.isEmpty()) return@runTask

val transferLimit = (transportSettings().extractorConfiguration.maxFluidRemovedPerExtractorTick * delta).roundToInt()
val resources = source.getExtractableResources()
Original file line number Diff line number Diff line change
@@ -15,32 +15,32 @@ import net.horizonsend.ion.server.features.transport.nodes.types.ItemNode
import net.horizonsend.ion.server.features.transport.nodes.types.ItemNode.SolidGlassNode
import net.horizonsend.ion.server.features.transport.nodes.types.Node
import net.horizonsend.ion.server.features.transport.util.CacheType
import net.horizonsend.ion.server.features.transport.util.transaction.Change
import net.horizonsend.ion.server.features.transport.util.transaction.ItemTransaction
import net.horizonsend.ion.server.miscellaneous.utils.ADJACENT_BLOCK_FACES
import net.horizonsend.ion.server.miscellaneous.utils.LegacyItemUtils
import net.horizonsend.ion.server.miscellaneous.utils.STAINED_GLASS_PANE_TYPES
import net.horizonsend.ion.server.miscellaneous.utils.STAINED_GLASS_TYPES
import net.horizonsend.ion.server.miscellaneous.utils.coordinates.BlockKey
import net.horizonsend.ion.server.miscellaneous.utils.coordinates.Vec3i
import net.horizonsend.ion.server.miscellaneous.utils.coordinates.getRelative
import net.horizonsend.ion.server.miscellaneous.utils.coordinates.toBlockKey
import net.horizonsend.ion.server.miscellaneous.utils.coordinates.toVec3i
import net.horizonsend.ion.server.miscellaneous.utils.debugAudience
import net.horizonsend.ion.server.miscellaneous.utils.minecraft
import net.minecraft.core.BlockPos
import net.minecraft.world.Container
import net.minecraft.world.level.block.entity.BlockEntity
import org.bukkit.Material
import org.bukkit.Material.CRAFTING_TABLE
import org.bukkit.block.BlockFace
import org.bukkit.block.BlockState
import org.bukkit.block.data.type.CommandBlock
import org.bukkit.block.data.type.Hopper
import org.bukkit.craftbukkit.block.impl.CraftGrindstone
import org.bukkit.craftbukkit.inventory.CraftInventory
import org.bukkit.inventory.Inventory
import org.bukkit.inventory.ItemStack
import kotlin.reflect.KClass

class ItemTransportCache(holder: CacheHolder<ItemTransportCache>): TransportCache(holder) {
class ItemTransportCache(override val holder: CacheHolder<ItemTransportCache>): TransportCache(holder) {
override val type: CacheType = CacheType.ITEMS
override val extractorNodeClass: KClass<out Node> = ItemNode.ItemExtractorNode::class
override val nodeFactory: NodeCacheFactory = NodeCacheFactory.builder()
@@ -70,7 +70,7 @@ class ItemTransportCache(holder: CacheHolder<ItemTransportCache>): TransportCach
delta: Double,
metaData: ExtractorMetaData?,
) {
NewTransport.executor.submit {
NewTransport.runTask {
measureOrFallback(TransportDebugCommand.extractorTickTimes) {
handleExtractorTick(location, delta, metaData as? ItemExtractorMetaData)
}
@@ -105,7 +105,7 @@ class ItemTransportCache(holder: CacheHolder<ItemTransportCache>): TransportCach
debugAudience.information("Checking ${item.type} [$count]")
val destinations: List<BlockKey> = getNetworkDestinations<ItemNode.InventoryNode>(location, originNode) { node ->
val inventory = getInventory(node.position)
inventory != null && inventory.isEmpty //TODO full
inventory != null && LegacyItemUtils.canFit(inventory, item, 1)
}.toList()

if (destinations.isEmpty()) {
@@ -128,7 +128,7 @@ class ItemTransportCache(holder: CacheHolder<ItemTransportCache>): TransportCach
) { node, blockFace ->
if (node !is ItemNode.FilterNode) return@findPath true
debugAudience.serverError("checking filter")
node.matches(item)
node.matches(item).apply { debugAudience.serverError("filter returned $this") }
}
} }

@@ -155,36 +155,46 @@ class ItemTransportCache(holder: CacheHolder<ItemTransportCache>): TransportCach
destinations.minBy { key -> extractorPosition.distance(toVec3i(key)) }
}

val path = destinationMap[destination]!!
debugAudience.information("Selected destination ${toVec3i(destination)}")

val transact = ItemTransaction(holder as CacheHolder<ItemTransportCache>, { stack1, stack2 ->
// val path = destinationMap[destination]!!
val diffProvider = { stack1: ItemStack, stack2: ItemStack ->
stack1.isSimilar(stack2) //TODO
})
}
debugAudience.information("1")

val transact = ItemTransaction(holder)
debugAudience.information("2")

for (source in sources) {
val key = toBlockKey(Vec3i((source.holder as BlockState).location))
println("source holder: ${source.inventory}")
val key = toBlockKey((source.inventory as BlockEntity).blockPos.toVec3i())
debugAudience.information("3 ${toVec3i(key)}")

transact.addRemoval(key, ItemTransaction.ItemDiff(item, -count))
transact.addRemoval(key, Change.ItemRemoval(item, count, diffProvider))
}
debugAudience.information("4")

transact.addAddition(destination, ItemTransaction.ItemDiff(item, count))
transact.addAddition(destination, Change.ItemAddition(item, count))

debugAudience.information("Committing transaction")
transact.commit()
debugAudience.information("Finished transaction")

debugAudience.highlightBlock(toVec3i(destination), 40L)
}
}

fun getInventory(localKey: BlockKey): Inventory? {
fun getInventory(localKey: BlockKey): CraftInventory? {
val globalVec = holder.transportManager.getGlobalCoordinate(toVec3i(localKey))
val nmsChunk = holder.getWorld().minecraft.getChunkIfLoaded(globalVec.x.shr(4), globalVec.z.shr(4)) ?: return null
val tileEntity = nmsChunk.getBlockEntity(BlockPos(globalVec.x, globalVec.y, globalVec.z)) as? Container ?: return null

return CraftInventory(tileEntity)
}

fun getSources(extractorLocation: BlockKey): Set<Inventory> {
val inventories = mutableSetOf<Inventory>()
fun getSources(extractorLocation: BlockKey): Set<CraftInventory> {
val inventories = mutableSetOf<CraftInventory>()

for (face in ADJACENT_BLOCK_FACES) {
val inventoryLocation = getRelative(extractorLocation, face)
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ class PowerTransportCache(holder: CacheHolder<PowerTransportCache>) : TransportC
tickPowerExtractor(location, delta)
}

private fun tickPowerExtractor(location: BlockKey, delta: Double) = NewTransport.executor.submit {
private fun tickPowerExtractor(location: BlockKey, delta: Double) = NewTransport.runTask {
measureOrFallback(TransportDebugCommand.extractorTickTimes) {
val world = holder.getWorld()

@@ -95,7 +95,7 @@ class PowerTransportCache(holder: CacheHolder<PowerTransportCache>) : TransportC
}
}

private fun tickSolarPanel(location: BlockKey, delta: Double, solarCache: SolarPanelCache) = NewTransport.executor.submit {
private fun tickSolarPanel(location: BlockKey, delta: Double, solarCache: SolarPanelCache) = NewTransport.runTask {
measureOrFallback(TransportDebugCommand.solarTickTimes) {
val transportPower = solarCache.getPower(holder.getWorld(), location, delta)
if (transportPower == 0) return@measureOrFallback
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap
import kotlin.jvm.optionals.getOrNull
import kotlin.reflect.KClass

abstract class TransportCache(val holder: CacheHolder<*>) {
abstract class TransportCache(open val holder: CacheHolder<*>) {
/**
* Cache containing a cache state at their corresponding block position.
* The state can either be empty, or present. Empty key / value pairs have not been cached.
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ interface Change {

class ItemRemoval(val item: ItemStack, val amount: Int, val similarityProvider: (ItemStack, ItemStack) -> Boolean) : Change {
override fun check(inventory: Inventory): Boolean {
TODO("Not yet implemented")
return true //TODO
}

override fun execute(inventory: Inventory): Boolean {
@@ -51,14 +51,10 @@ interface Change {

class ItemAddition(val item: ItemStack, val amount: Int) : Change {
override fun check(inventory: Inventory): Boolean {
TODO("Not yet implemented")
return LegacyItemUtils.canFit(inventory, item, amount) //TODO
}

override fun execute(inventory: Inventory): Boolean {
if (!LegacyItemUtils.canFit(inventory, item, amount)) {
return false
}

val stacks = mutableListOf<ItemStack>()

var remaining = amount
Original file line number Diff line number Diff line change
@@ -88,6 +88,7 @@ import net.horizonsend.ion.server.features.starship.hyperspace.HyperspaceBeacons
import net.horizonsend.ion.server.features.starship.movement.PlanetTeleportCooldown
import net.horizonsend.ion.server.features.starship.subsystem.shield.StarshipShields
import net.horizonsend.ion.server.features.transport.NewTransport
import net.horizonsend.ion.server.features.transport.filters.FilterType
import net.horizonsend.ion.server.features.transport.fluids.FluidRegistry
import net.horizonsend.ion.server.features.transport.old.TransportConfig
import net.horizonsend.ion.server.features.transport.old.Wires
@@ -144,6 +145,7 @@ val components: List<IonComponent> = listOf(

TransportConfig.Companion,
Pipes,
FilterType,
Filters,
Wires,
NewTransport,