Commit Graph

81 Commits

Author SHA1 Message Date
Spottedleaf
b160a14068 Retrieve BlockState directly from chunk section for random tick
This appears to be faster than going directly to the global
palette, even though the global palette should be a simple list
get call.
2024-07-14 18:19:41 -07:00
Spottedleaf
225d5f937d Avoid collision shapes outside world border in findFreePosition
This is to correctly adhere to Vanilla behavior.
2024-07-14 12:56:30 -07:00
Spottedleaf
1f0ca522c7 Port random ticking patch from Paper 2024-07-14 12:55:46 -07:00
Spottedleaf
e0aac6916b Update raw palette array on value insertion for SingleValuePalette
It may be possible to invoke moonrise$getRawPalette before
the palette's single value is initialised, so we need to track
the returned raw palette array.
2024-07-14 05:14:36 -07:00
Spottedleaf
24657f1fd6 Update last chunk position in findSupportingBlock
Fixes fetching chunks needlessly multiple times.

Thanks Lulu13022002 for pointing this out
2024-07-13 11:38:57 -07:00
Spottedleaf
2eb4a71a35 Add todo.txt 2024-07-11 12:29:55 -07:00
Spottedleaf
523e8d98c4 Changes made while porting collision patch to Paper
1. Need a better solution for EntityMixin block/fire collision
2. Fixed inconsistent Vanilla behavior for ExplosionMixin
   Mostly revolved around the explosion intensity calculator,
   as well as the damage calculator
3. Optimise ExplosionMixin to not call getSeenPercent twice,
   which is a new "feature" of 1.21
4. Optimise VoxelShapeMixin#toAabbsUncached()
   The regular forAllBoxes method on VoxelShape will incur
   indirection costs due to the virtual method invoke on
   the coordinate retrieval as well as on the consumer itself
2024-07-11 11:57:18 -07:00
Spottedleaf
6d8e12ed6f Copy entity tracker optimisations from Folia 2024-07-11 09:00:54 -07:00
Spottedleaf
6ff9aca2db Increment ChunkHolderManager current tick
This is an oversight from copying from Folia. The current tick
should be incremented so that incremental autosave can properly
occur.
2024-07-11 08:56:00 -07:00
Spottedleaf
e73a2443c7 Synchronise config reloading
In the future, config will be writable by both client & server
and so synchronisation should be happening.
2024-07-08 05:54:22 -07:00
Spottedleaf
bd3f32c944 Execute chunk tasks mid-tick.
If the server tick length is high, then the amount of time
available to process chunk tasks inbetween ticks is low. As a
result, chunk loading and generation may appear to slow down.

To ensure that chunk tasks are always processed, we add logic to
execute chunk tasks during tile entity tick, entity tick, chunk
random ticking, and scheduled block/fluid ticking. The mid-tick task
execution is timed so that it is not prioritised over the server
tick.
2024-06-28 19:04:11 -07:00
Spottedleaf
2c97e8dc6e Fairly execute chunk tasks for all worlds
To ensure that a single world does not eat up allocated
processing time for tasks, execute tasks for all worlds
before returning from pollTaskInternal().
2024-06-28 18:08:46 -07:00
Spottedleaf
641694d07c Fix NPE when retrieving an entity with a null UUID
While the null UUID is almost certainly an error, the old
implementation did not NPE as it used a plain HashMap for lookup
by UUID, whereas we use a ConcurrentHashMap which will NPE on
null keys.
2024-06-23 18:51:14 -07:00
Spottedleaf
4c36d6db57 Fix unload queue storing chunks in wrong sections
The unload queue stored the chunks in the same section as
the chunk coordinate, when it needed to apply the unload shift.

Additionally, change the default region shift to the ticket
propagator shift as there is no benefit to using a low region
shift since no regionizing is occuring. This makes the unload
queue shift 6, which should reduce the number of sections to deal
with while processing unloads.
2024-06-21 11:44:53 -07:00
Spottedleaf
30cb658845 Move field initializations out of constructor injects
They should be less fragile for breakages.

Additionally, modify PoiManagerMixin to work around an issue where
our getOrCreate() method is not being invoked _because_ its return
type was PoiSection and not Object. Apparently, the JVM will search
the superclass when a direct match (params+return type) is not found.
2024-06-19 17:36:57 -07:00
Spottedleaf
044a23f34a Add debug chunks command
This feature dumps the entire chunk system state to disk, useful
for debugging the chunk system state without a debugger.
2024-06-19 11:53:06 -07:00
Spottedleaf
4911c5033a Move addition to full chunk map before calling callbacks
The full chunk map should mirror immediately the
full chunk status, so it should be added immediately after
upgrading to FULL or removed immediately before downgrading to
INACCESSIBLE.
2024-06-19 10:10:31 -07:00
Spottedleaf
393bd84ca8 Null check onComplete parameter for scheduleChunkLoad with gen = false
When gen = true, the parameter may be null. There is no reason it
should NPE then when gen = false.
2024-06-19 08:19:31 -07:00
Spottedleaf
ed3e278562 Fix NPE in ServerLevelMixin#moonrise$getFullChunkIfLoaded
d23825aa56
2024-06-18 18:31:48 -07:00
Spottedleaf
502cee89cd Fix respawning not loading chunks
We need to copy the real player field and view distance holder
object over, as Vanilla re-creates ServerPlayer objects unlike
CraftBukkit.
2024-06-18 16:20:34 -07:00
Spottedleaf
ac971bee98 Add relight command
This is simply for feature parity with Paper.
2024-06-18 15:58:54 -07:00
Spottedleaf
240faf56a4 Fix implementations of ChunkHolder#getChunkIfPresent
Implementations for ChunkStatuses below FULL are supposed to always
return ProtoChunk instances. However, since we used the last completed
status, it could return LevelChunk.

To resolve this, follow Vanilla behavior of tracking chunk
completions by status and replace old ProtoChunk statuses with
ImposterProtoChunk when the chunk generates to FULL.

Additionally, implement an optimisation for retrieving full chunks
by storing a map of pos -> LevelChunk. This requires only a simple
map lookup to occur for full chunks which are loaded.
2024-06-16 13:46:42 -07:00
Spottedleaf
62efccbd3f Null check max status in GenerationChunkHolder#getChunkIfPresent
If the ticket level is set to unloaded, then it will be null.
2024-06-16 12:12:42 -07:00
Spottedleaf
867f165eb6 WIP changes from stream 2024-06-15 07:33:34 -07:00
Spottedleaf
188ddaae7b Update to 1.21 2024-06-14 09:50:54 -07:00
Spottedleaf
fff73cff5b Add proper moonrise configuration
The config is stored under `moonrise.yaml` in the working
directory. Comments document each option.
2024-06-11 10:11:32 -07:00
Spottedleaf
23f201e5ed Sync chunk system changes from Paper
Additionally, slightly increase parallelism of ticket level
propagation
2024-06-05 12:56:43 -07:00
Spottedleaf
b6a8fed850 Add conformVisibility for mixin overwrites
We don't actually want to change the visibility of mixins when
overwriting them.

This reduces the surface area for mod conflicts.
2024-05-29 01:35:45 -07:00
Spottedleaf
c8fec9d3ac Add moonrise command
For now, includes the holderinfo and chunkinfo commands
from Paper.
2024-05-28 06:04:54 -07:00
Spottedleaf
3222ed8c6f Clamp tick distance by load distance
This brings expected behavior in-line more with Vanilla,
which will not always load chunks up to the tick distance.
2024-05-28 05:15:56 -07:00
Spottedleaf
3ab838b507 Move raw palette to Data container
This allows us to have safe off-thread reads, as we can guarantee
that the palette is associated with the data (which is why
a Data container is used in the first place).
2024-05-28 04:52:38 -07:00
Spottedleaf
845e8fb76a Clean up some mixins by using mixinextras @Local
Allowing us to capture local variables removes the need
for hacks in @Redirect working around lack of local variable
capture.
2024-05-27 06:15:14 -07:00
Jason Penilla
0fa6d0710f Clean up concurrentutil dependency declaration 2024-05-26 12:39:39 -07:00
Jason Penilla
86e91df061 Disable legacy mixin ap 2024-05-26 12:30:04 -07:00
Jason Penilla
ef9673d4c0 Make output file names less confusing 2024-05-26 11:43:19 -07:00
Jason Penilla
d03938eaf7 Fix actions build 2024-05-26 11:31:13 -07:00
Spottedleaf
b31223e24a Extract chunk system threads to general common threads
This allows us to use them for chunk rendering, which
should reduce competition between the background executor pool
and the chunk system for cpu resources.
2024-05-26 09:12:26 -07:00
Spottedleaf
1d60cdb400 Fix CME in StructureTemplate.Palette
The cache needs to be a CHM to prevent CMEs. Since the only usage
is compute() on static data, this is all we need to fix the
threading issues here.
2024-05-26 08:37:34 -07:00
Spottedleaf
959fc80c67 Switch to Tuinity logo
It looks better
2024-05-25 21:11:24 -07:00
Spottedleaf
63a54a6f8a Port Chunk System Rewrite 2024-05-25 20:56:05 -07:00
Spottedleaf
66f63e1296 Move explosions patch to collisions patch
Given that the explosions patch depends on the collisions one,
it makes sense to put them together.
2024-05-23 08:21:15 -07:00
Spottedleaf
ade9ea3626 Remove explosions profiling mixin 2024-05-23 08:03:54 -07:00
Spottedleaf
798d8f8384 Move ConcurrentUtil to own project
Currently, requires compiling separately and installing to
maven local

https://github.com/Spottedleaf/ConcurrentUtil
2024-05-23 07:13:03 -07:00
Spottedleaf
2ce869b7a4 Style changes
Mostly protected -> private in final classes
2024-05-23 06:06:50 -07:00
Spottedleaf
60fe328a92 Make makeExecutor public to fix mod conflict 2024-05-22 16:53:54 -07:00
Jason Penilla
5ec8a635a7 Add actions workflow 2024-05-22 16:51:49 -07:00
Spottedleaf
ca661908c4 Fix accesswideners 2024-05-22 15:58:24 -07:00
Spottedleaf
8e5f550739 Optimise palette
Palette has 4 implementations: global, hash, linear, and single.

When only one implementation is being used (i.e all chunks
loaded have sections with linear palette) the JIT can optimise
the call to #valueFor quite well. When there are two implementations
(i.e hash, linear) the JIT can still optimise the call but at a
slight cost.

However, when there are three or more in use
(i.e linear, hash, single/global) the JIT cannot
optimise the call and must revert to an interface invoke - which
is terribly slow.

In order to optimise this, we can extract an array for
the hash, linear, and single palette implementations and
perform lookups on the array directly instead of invoking
2024-05-22 15:04:01 -07:00
Spottedleaf
a1cf0d5c22 Starlight: Change light engine allocations to avoid double allocations
The light tasks may allocate a light engine themselves, and as a
result increase memory usage. We can avoid these allocations
by only allocating the instances for block changes and releasing
immediately after.
2024-05-22 14:25:21 -07:00
Spottedleaf
adad376255 Optimise BlockSoil nearby water lookup
Ported from Paper
2024-05-22 14:25:21 -07:00