Commit Graph

64 Commits

Author SHA1 Message Date
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
Spottedleaf
b51a15f860 Port uncommited changes from chunk system 1.20.4 branch 2024-05-22 14:21:31 -07:00
Spottedleaf
abde2e44b2 Optimise SimpleBitStorage further
Credit to https://lemire.me/blog/2019/02/08/faster-remainders-when-the-divisor-is-a-constant-beating-compilers-and-libdivide
and https://github.com/Vrganj for the algorithm to determine a
magic value to use for both division and mod operations

This improves storage reads by up to 1.3x.
2024-05-22 14:14:30 -07:00
Spottedleaf
028a759a6e Update to 1.20.6 2024-05-22 14:14:04 -07:00
Spottedleaf
9b6662317d Fix world border edge collision
The collision shape of the border is determined by flooring the min values and ceiling the max values, so the isCollidingWithBorder() function should mirror such behavior.
2023-12-19 21:34:25 -08:00
Spottedleaf
cf5a5b3a30 Make worldborder collisions consistent with Vanilla
Vanilla now requires the use of WorldBorder#isInsideCloseToBorder
to consider a border collision
2023-12-18 16:47:43 -08:00
Spottedleaf
bb6d1f2aaa Fix incorrect border collision detection
The epsilon used was in the opposite direction, which would cause
the getCollisions method to incorrectly return it for when players
were exactly on the border but not colliding. To bring it in-line
with the rest of the collision code, the collision must be into
the border by +EPSILON.

Additionally, move the setReadTimeoutHook in the server list
ping patch to a client-side mixin so it does not load in the
dedicated server causing a crash.
2023-12-14 19:05:40 -08:00
Spottedleaf
14b42d3419 Update to 1.20.4 2023-12-10 12:11:27 -08:00
Spottedleaf
602323d3b8 Update to 1.20.3
Change all interfaces used in mixins to have methods prefixed
with "moonrise" or "starlight", to remove risk of conflicting
with Vanilla or other mods methods

Add new patch for optimising ticking block entity removal
 - Similar to Paper's patch for this but uses an in-place removal
   method

Remove most of the fluid mixins:
 - May not be effective, but are a big maintenance problem
2023-12-06 23:28:34 -08:00
Spottedleaf
701a7c7fc1 Improve server ping list response
Change the read timeout and connection timeout both to 5s. This
is to decrease the time to label servers as offline.

Additionally, increase the worker count for pinging servers to 128
from 5. This allows many more server pings to occur at the same time,
which allows users to scroll their serverlist.
2023-10-30 14:38:32 -07:00
Spottedleaf
a5038c0856 Initialise default nibble arrays in ChunkAccess directly
When ChunkAccess was converted to an abstract class some versions
ago, the code to initialise nibble arrays should have been moved.
However, the code was not moved and so now mods constructing their
own implementations of ChunkAccess would not have the nibble arrays
initialised.

Fixes https://github.com/PaperMC/Starlight/issues/186
2023-10-18 06:36:30 -07:00
Spottedleaf
28b19199ce Fix mushrooms not generating in swamps
During feature generation, light data is not initialised and
will always return 15 in Starlight. Vanilla can possibly return
0 if partially initialised, which allows some mushroom blocks to
generate.

In general, the brightness value from the light engine should not
be used until the chunk is ready. To emulate Vanilla behavior better,
we return 0 as the brightness during world gen unless the target
chunk is finished lighting.

The regular light retrieval outside of WorldGenRegion remains
the same, as behaviorally chunks not lit should be at max
skylight and zero block light.

Fixes https://github.com/PaperMC/Starlight/issues/193
2023-10-18 06:33:33 -07:00
Spottedleaf
8f88b1bea1 Add default implementation for ExtendedWorld in Level
This should hopefully help mod compatibility with mods that
implement their own Levels.

Fixes https://github.com/PaperMC/Starlight/issues/187
2023-10-18 06:31:27 -07:00
Spottedleaf
3a2a5dcc05 Remove unused skyLightSources
There is no point in initialising the sources in Starlight,
as we do not use them. Additionally, they are not saved to
disk so we do not need them.

Maintaining and initialising them is not a negligible cost,
which is why they are being removed.
2023-10-18 06:29:48 -07:00
Spottedleaf
85a2c60806 Remove invalid and unused accesswidener
Fixes build
2023-10-17 17:01:40 -07:00
Spottedleaf
2da91fa536 Fix VoxelShape#isFullBlock() for non-single AABB types
The correct logic to implement NOT_SAME with Shapes#block()
is to test whether any shape data exists outside of [0.0, 1.0]
and to test whether the shape is completely filled from 0.0 to 1.0
on all axis. This can be implemented by checking whether the
bounds represent the full block and whether everything within
the bounds is filled.
2023-10-13 03:50:05 -07:00
Spottedleaf
01f9a87d15 Update to 1.20.2 2023-10-13 03:46:04 -07:00
Spottedleaf
dd01bf7bc7 Fix mixin conflict for fabric transfer api in hopper optimisations
The mixin targetted the getSourceContainer invocation, which failed
when the method was overwritten. Move the optimisations to use
one redirect and one inject, which don't appear to affect the
performance.
2023-09-19 11:43:51 -07:00