Commit graph

64 commits

Author SHA1 Message Date
Nassim Jahnke
c2ef6cc45a Patch updates 2024-12-11 22:21:25 +01:00
Nassim Jahnke
c6e8192e3b More moving around of hunks 2024-12-05 14:44:50 +01:00
Nassim Jahnke
10cba26ae2 Move around patches again 2024-12-05 11:18:29 +01:00
Spottedleaf
8999170435 Apply coordinate offset only to VoxelShape
VoxelShape coordiantes generally are an integer + a sum of powers of
two between [-1, -3]. Most offsets are generally an integer. As
a result, applying an offset to the coordinates generally results
in an error of 0. However, coordinate inputs do not follow such
trends. Thus, when applying an offset to the coordinate input,
there may be some floating point error.

By applying the offset to the VoxelShape coordinates, we can
eliminate additional floating point error.

This change also fixes the inconsistency when using
the single AABB, as input coordinates were not offset
when using the single AABB as the single AABB is already
offset.

Fixes https://github.com/Tuinity/Moonrise/issues/81
This specific issue is caused by floating point error resulting
in the falling anvil's y position becoming around -8E-17 when it
should be 0.
While this is still very comfortably in the collision
epsilon (1.0E-7), this results in the falling anvil's y block
position to become -1 (as the block position is simply
the floor of the coordinate).
2024-12-04 02:52:58 -08:00
Jason Penilla
572fb23805 Update Moonrise 2024-12-03 15:26:43 -07:00
Jason Penilla
5a0e5546e6 Update DataConverter 2024-12-03 15:21:36 -07:00
Nassim Jahnke
df479182fe Add back post_teleport chunk ticket 2024-12-03 22:56:26 +01:00
Nassim Jahnke
636439f610 Fix jd gson version, move back mc util diff 2024-12-03 22:37:48 +01:00
Nassim Jahnke
e3db6ac6e4 moonrise 2024-12-03 21:11:09 +01:00
Nassim Jahnke
3a8f9e0b6e Start update, apply API patches 2024-12-03 17:58:41 +01:00
Spottedleaf
65ca4c1911 Fix several off-by-one errors in view distance calculations
1. For NearbyPlayers, we need to be using the view distance, and
   not the load distance (which is +1 of the view distance).
2. Correctly clamp tick distance to view distance. Since
   load distance is +1 of view distance, we need to subtract
   one from the load distance when clamping.

Additionally, add checks inside ViewDistances to ensure that
the inputs are in range to catch future errors.

Also, clamp simulation distance, as values < 0 or above
MAX_VIEW_DISTANCE do not make sense to configure.
2024-12-01 15:43:56 -08:00
Spottedleaf
6788ba5e80 Fix non-null initialisation of context collision shape
Force LazyEntityCollisionContext#getEntity() to delegate

- By delegating when the entity is retrieved, we can correctly catch
  cases where the collision method is inspecting some entity state.

Adjust constant collision shape determination

- Our previous hack did not actually catch every case. For now,
  it will only assume a constant collision shape of EMPTY for
  air blocks.

Fixes https://github.com/PaperMC/Paper/issues/11697
2024-12-01 13:43:37 -08:00
Spottedleaf
b37a391c02 Remove chunk save reattempt patch
This patch does not appear to be doing anything useful, and may
hide errors.

Currently, the save logic does not run through this path either
so it did not do anything.

Additionally, properly implement support for handling
RegionFileSizeException in Moonrise.
2024-11-28 17:39:40 -08:00
Spottedleaf
c8457716c4 Use Player view distance for PlayerNaturallySpawnCreaturesEvent
The spigot view distance may not be correct, as the player may
have a specific view distance configured.
2024-11-28 14:22:32 -08:00
Spottedleaf
63d0de648f Do not call modifyEntityTrackingRange on own range
The range is already modified, so this call will not do anything.
2024-11-27 12:19:39 -08:00
Spottedleaf
f9b1c374e4 Replace SimpleRandom with (Simple)ThreadUnsafeRandom
ThreadUnsafeRandom is a random implementation that is
identical to LegacyRandomSource behaviourally, but
without the thread checks.

SimpleThreadUnsafeRandom is ThreadUnsafeRandom except with
its nextInt(int) function replaced with a faster
but more biased implementation when bound is very large.

Additionally, replace Level/Entity randoms with ThreadUnsafeRandom.
This avoids the expensive CAS logic at the expense of losing the
thread check.
2024-11-27 06:16:27 -08:00
Spottedleaf
70ccc97b36 Fix non block ticking chunks not sending block/light updates
Needed to redirect the getTickingChunk call in
broadcastChangedChunks to use the chunk to send method.
2024-11-18 22:48:40 -08:00
Spottedleaf
f7086a34b5 Do not create unneccessary callback in ChunkTaskScheduler#scheduleChunkLoad
If the parameter has addTicket = false and onComplete = null,
then the loadCallback would do no work and as a result does
not need to be created.
2024-11-18 22:47:09 -08:00
Spottedleaf
989fd77808 Rework async chunk api implementation
Firstly, the old methods all routed to the CompletableFuture method.
However, the CF method could not guarantee that if the caller
was off-main that the future would be "completed" on-main. Since
the callback methods used the CF one, this meant that the callback
methods did not guarantee that the callbacks were to be called on
the main thread.

Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb)
so that the methods with the callback are guaranteed to invoke
the callback on the main thread. The CF behavior remains unchanged;
it may still appear to complete on main if invoked off-main.

Secondly, remove the scheduleOnMain invocation in the async
chunk completion. This unnecessarily delays the callback
by 1 tick.

Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which
will load chunks within an area. This method is provided as a helper
as keeping all chunks loaded within an area can be complicated to
implement for plugins (due to the lacking ticket API), and is
already implemented internally anyways.

Fourthly, remove the ticket addition that occured with getChunkAt
and getChunkAtAsync. The ticket addition may delay the unloading
of the chunk unnecessarily. It also fixes a very rare timing bug
where the future/callback would be completed after the chunk
unloads.
2024-11-18 22:34:32 -08:00
Nassim Jahnke
a403e97804 Make logs less annoying 2024-11-18 13:06:15 +01:00
Spottedleaf
d0a2d92713 Fix experimental minecart collisions on sloped rails
We are supposed to ignore some collisions on the sloped
rail.
2024-11-14 21:01:04 -08:00
Jason Penilla
41085fc8b9 Fix and optimize getChunkCount (#11610)
It was returning ticking chunk count instead of the intended full chunk count.
We can also directly use the size of the fullChunks collection instead of iterating all chunks.
2024-11-11 12:17:36 -07:00
Jason Penilla
13a6161350 Fix Entity#isTicking and update Paper entity command (#11590)
fixes #10299
2024-11-09 07:41:26 -07:00
Spottedleaf
8480d09670 Handle corrupt light data gracefully
First, if the light data is not marked as correct, we should not be
parsing it in the first place. This will eliminate errors from
parsing possibly different versioned light data.

Secondly, if parsing the light data throws an exception (from
the SWMRNibbleArray constructor), then we can simply mark
the returned chunk as having incorrect light data - rather than
propagating the exception and causing the chunk to be re-generated.
2024-11-02 16:33:08 -07:00
Jason Penilla
c72370d2c0 Use declaration order for state holder property iteration
Mostly an aesthetic change for serialization, should not have any impact on performance or correctness.
2024-10-27 18:29:34 -07:00
Nassim Jahnke
eb6f344912 Remove timings impl 2024-10-27 18:11:15 +01:00
Spottedleaf
0fc6c032fb Fix Anti-Xray using wrong data in chunk deserialize 2024-10-25 12:57:20 -07:00
Spottedleaf
d83a56b430 Fix compile issues 2024-10-25 11:46:53 -07:00
Spottedleaf
1d63b06b5e Finish rebase 2024-10-25 11:40:25 -07:00
Spottedleaf
93271dfe39 Finish mixin diff review
The mixin diff review looks OK, but need to check the
patch diff now.
2024-10-24 12:47:34 -07:00
Spottedleaf
f35b3d7460 Complete rebase, start review 2024-10-24 11:51:29 -07:00
Spottedleaf
df7fb7760b Fix some compile errors from patches 2024-10-24 11:20:51 -07:00
Spottedleaf
7199166cb2 Implement chunk system 2024-10-24 11:11:56 -07:00
Spottedleaf
9472b1ddf5 Implement Starlight 2024-10-24 10:39:36 -07:00
Spottedleaf
eb57d32c94 Implement explosion optimisations 2024-10-24 10:16:56 -07:00
Spottedleaf
5d63f12602 Implement chunk tick iteration optimisations 2024-10-24 10:06:01 -07:00
Spottedleaf
065aecac6c Implement config hooks in PaperHooks 2024-10-24 08:36:07 -07:00
Spottedleaf
4b1beb1404 Merge patches 2024-10-24 08:20:45 -07:00
Spottedleaf
77baea3bf9 Begin fixing issues
See diff in the update text file
2024-10-24 08:18:20 -07:00
Noah van der Aa
510057a8ad okaaay let's go 2024-10-22 18:23:19 +02:00
Bjarne Koll
7c5395237d Updated Upstream (Bukkit/CraftBukkit) (#11501)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
bb4e97c6 Add support for Java 23
bc6874dd Bump asm to 9.7.1
50e8a00b PR-1064: Add specific getTopInventory methods for InventoryView derivatives
758b0a0f SPIGOT-7911: Fix Location#isWorldLoaded() for re-loaded worlds
133a64a7 Improve Registry#getOrThrow messages
be0f5957 PR-1058: Add tests for Minecraft registry <-> Bukkit fields
d1b31df2 PR-1062: Clarify BeaconView documentation
3fab4384 PR-1060: Cache Material to BlockType and ItemType conversion
967a7301 SPIGOT-7906: Increase YAML nesting limit to 100
6ecf033d SPIGOT-7899: Smithing recipes don't require inputs

CraftBukkit Changes:
0a7bd6c81 PR-1493: Improve reroute performance and add some tests
54941524c Add support for Java 23
f4d957fff SPIGOT-7915: Fix World#getKeepSpawnInMemory() using Spawn Radius rather than Spawn Chunk Radius
ded183674 Fix HIDE_ENCHANTS flag in items without enchantments
308785a0a Bump asm to 9.7.1 and re-add ClassReader to ClassWriter
72ce823cd PR-1487: Add specific getTopInventory methods for InventoryView derivatives
11a5e840c SPIGOT-7907, PR-1484: Improve merchant recipe item matching behavior to more closely align with older versions
45b66f7e4 SPIGOT-7909: Always set HIDE_ENCHANTS flag to item if flag is set
963459791 Increase outdated build delay
fc5b2d75f SPIGOT-7910: Fix launching breeze wind charge from API and improve dispenser launch API
c7d6428f2 SPIGOT-7856, PR-1483: End platform not dropping items after replacing blocks
2a5572b52 SPIGOT-7780, PR-1482: Cannot edit chunks during unload event
527041ab5 SPIGOT-7902, PR-1477: Fix CraftMetaPotion#hasCustomEffects() does not check if customEffects (List) is empty
5529a1769 Implement base methods for tags
30fbdbaaf Improve Registry#getOrThrow messages
6b71a7322 PR-1475: Add tests for Minecraft registry <-> Bukkit fields
5f24c255c SPIGOT-7908: Mark junit-platform-suite-engine as test scope
e4c92ef65 PR-1473: Change tests to use suites, to run tests in different environments and feature flags
d25e1e722 PR-1481: Fix BeaconView#set[X]Effect(null)
d69a05362 PR-1480: Fix PerMaterialTest#isEdible test running for legacy materials
bb3284a89 PR-1479: Use custom #isBlock method in legacy init instead of the one in Material, since it relies on legacy being init
98c57cbbe SPIGOT-7904: Fix NPE for PlayerItemBreakEvent
f35bae9ec Fix missing hasJukeboxPlayable
8a6f8b6d8 SPIGOT-7881: CTRL+Pick Block saves position data into item
7913b3be7 SPIGOT-7899: Smithing recipes don't require inputs
2024-10-21 00:06:54 +02:00
Esoteric Enderman
96dde2d730 Add API for explosions to damage the explosion cause (#11180)
This intends to give plugin developers more control over explosions created using the World#createExplosion method, specifically by adding the option for explosions to damage the explosion cause (not the default behavior, and previously impossible to do, as far as I know). This is done by overloading existing methods with an extra `excludeSourceFromDamage` parameter.

Co-authored-by: Bjarne Koll <git@lynxplay.dev>
2024-09-28 20:32:56 +01:00
hyperdefined
dada30ee8a Fix setSendViewDistance's return (#11247) 2024-08-12 03:27:27 -04:00
Spottedleaf
bad7a89384 Make loadChunksForMoveAsync use new chunk system load calls
This is to allow the call to work properly when on Folia,
as Folia does not have a main thread.
2024-07-30 19:50:14 -07:00
Spottedleaf
5bb7bd0f66 Move TickThread changes from Moonrise patch to MCUtils
The common changes from Moonrise should be entirely in MCUtils
2024-07-30 05:32:20 -07:00
Spottedleaf
78866a364d Do not allow chunk unloading outside of the regular tick loop
Allowing chunk loading to occur at any point via purgeUnload()
introduces possible undesirable behavior to occur recursively
inside the chunk system.
2024-07-28 16:18:25 -07:00
Spottedleaf
3badc8385a Copy missed changes to chunk system from Folia 2024-07-28 15:34:07 -07:00
Spottedleaf
08e9cfb799 Remove Entity tracker field
Now the only tracker field is from the entity tracker
optimisations.
2024-07-28 15:28:28 -07:00
Nassim Jahnke
66dc0ac979 Call PlayerChunkUnloadEvent 2024-07-19 13:50:38 +02:00
Nassim Jahnke
dc136446fb Even more cleanup of mcutil patch 2024-07-18 16:50:16 +02:00