Commit Graph

101 Commits

Author SHA1 Message Date
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
Spottedleaf
2b63a849d3 Fix CachedToAABBs when offset becomes zero
If the offset were to be undone, then it would incorrectly mark the
cache as not having an offset when it actually did.
2023-09-19 11:40:19 -07:00
Spottedleaf
c7fea2e95d Change getSeenFraction to return float
Vanilla uses float here, so it may change behaviorly slightly
by using more precision.
2023-09-13 13:44:54 -07:00
Spottedleaf
5f11d81b11 Fix NPE in clipsAnything at world height
If the block is out of bounds, then the block state may
be null.
2023-09-13 13:36:14 -07:00
Spottedleaf
fcc3b02a54 Fix incorrect Entity#isInWall() mixin
The VoxelShapes retrieved need to be offset for the
intersection checks.
2023-09-12 07:12:37 -07:00
Spottedleaf
b8935d1dd1 Fix incorrect forAllBoxes implementation
The implementation of FlatBitsetUtil#clearRange was
incorrect, as it did not properly clear long values
inbetween the range and the bitmasks for keeping the first
and last bits were off by one.

The implementation of forAllBoxes did not properly account
for multiple ranges of bits to be set on the Z direction
for a given X and Y, as it would only use the first range.
2023-09-10 17:52:07 -07:00
Spottedleaf
a1e89e9515 Add ZeroCollidingReferenceStateTable for StateHolder property operations
This patch optimises property updating optimisations for StateHolder
operations.

98ae59d859

Additionally, implement some basic optimisations to some BlockPos
operations.

9c4490bda4
2023-09-09 06:02:30 -07:00
Spottedleaf
c4aa0cc0aa Move findSupportingBlock to LevelMixin
This allows us to assume that the getChunkForCollisions
method routes to getChunk(x, z, FULL, false) which allows
us to avoid the indirection caused by different implementations
of that method on different implementations of CollisionGetter.
2023-09-04 16:49:39 -07:00
Spottedleaf
13ce46a086 Optimise BitSetDiscreteVoxelShape#forAllBoxes
This should speed up general shape joining, as VoxelShape#optimize()
uses this method when performing an uncached toAabbs()
2023-09-04 16:14:33 -07:00
Spottedleaf
dc20d1a144 Optimise findFreePosition
Ghasts teleporting can perform many voxelshape operations.
We can reduce the number of voxelshape operations and use
more efficient ones at the same time.
2023-09-01 15:15:03 -07:00
Spottedleaf
48043cd406 Hopper optimisations 2023-08-27 02:20:06 -07:00
Spottedleaf
e19f6a8796 Offset first input to unique id calculation
So that the first murmurHash3 call is unique
2023-08-20 17:19:46 -07:00
Spottedleaf
716342c922 Fix incorrect specialCollidingBlocks calculation clientside
Need to add a hook to the section read function that only
the client calls to actually count, as the client does not
invoke recalcBlockCounts on its own.

Can't be bothered to document the other changes in this commit.
2023-08-20 15:56:24 -07:00
Spottedleaf
d4248d54bb Fix bad particle light colouring
Swapped the light variables by accident
2023-08-12 03:42:39 -07:00