Commit Graph

5238 Commits

Author SHA1 Message Date
Aikar
4ae089597b
Fix collision checks on spawning hanging entities and null on async chunk loads
getCubes will now always load chunks
getChunk with gen false will now not throw error

Fixes #3368
Fixes #3364
2020-05-14 05:05:13 -04:00
Aikar
c2f8d1ef98
Protect Bedrock and End Portal/Frames from being destroyed
This fixes exploits that let players destroy bedrock by Pistons, explosions
and Mushrooom/Tree generation.

These blocks are designed to not be broken except by creative players/commands.
So protect them from a multitude of methods of destroying them.

A config is provided if you rather let players use these exploits, and let
them destroy the worlds End Portals and get on top of the nether easy.
2020-05-14 03:16:31 -04:00
Aikar
827cc63263
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears 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:
ffc8e4ca SPIGOT-5716: Clarify documentation of MultipleFacing

CraftBukkit Changes:
d07a78b1 SPIGOT-5716: Clarify documentation of MultipleFacing
46a13860 SPIGOT-5718: Block.BreakBlockNaturally does not reflect tool used
214ffea9 SPIGOT-5727: GameRule doImmediateRespawn cannot be set per-world

Spigot Changes:
2f5d615f SPIGOT-5730: Modernise inventory patch
a2bdb119 SPIGOT-5679: Add config option for end portal activation sound

Closes #3352
2020-05-12 01:27:07 -04:00
Aikar
92f680ed84
Fix Pathfinding and obscure glitchy buggy 0 tick farms
I swear the crap that stuff will abuse to make stuff happen is insane.

Hash codes apparently changing behavior of stuff based on its value, so
reverting 2d401d2dfb

Fixes #3346
Fixes #3341
2020-05-11 21:18:11 -04:00
Aikar
7a7c429260
Optimize Pathfinder - Remove Streams / Optimized collections
I utilized the IDE to convert streams to non streams code, so shouldn't
be any risk of behavior change. Only did minor optimization of the
generated code set to remove unnecessary things.

I expect us to just drop this patch on next major update and re-apply
it with the IDE again and re-apply the collections optimization.

Optimize collection by creating a list instead of a set of the key and value.

This lets us get faster foreach iteration, as well as avoids map lookups on
the values when needed.
2020-05-11 04:24:38 -04:00
Aikar
fc917d1687
Optimize Hoppers - Major performance improvement
Removed streams from hoppers and also fixed a mistake in the logic.
When this patch was ported to 1.14/1.15, a line of code was put in
the wrong place which disabled a significant portion of the improvement.

Replaced usages of streams in isEmpty and itemstack checks
Replaced usage of streams in pulling loop
Replaced usage of streams in Lootable Inventory isEmpty() check
Only check for refilling Lootable Inventory when accessing first slot, not all

All of these in general were pretty significant hits, so this single commit
is going to cause tacos to magically appear in front of you every day.

🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮

Nom Nom Nom
If you hate taco's, you're not allowed to use this improvement.

Also ignore the renames, pulled a lot of PR's.
2020-05-11 03:42:32 -04:00
Omer Uddin
14ad77c692
Fix PotionEffect API Ignoring Icon bug
Fixes #3142
2020-05-11 00:44:27 -04:00
Omer Uddin
eb3ce8a258
Fix EntityRaider picking up items when they shouldn't be able
Fixes #2205
2020-05-11 00:41:15 -04:00
Aikar
1ea9ada0da
Add a TELEPORT ticket when changing dimensions
This should fix any remaining issues around collision issues on
chunk edges when changing dimensions sending to Y 256
2020-05-11 00:19:40 -04:00
Aikar
8e9459eadc
Fix missing flag pass for isUrgent 2020-05-11 00:19:40 -04:00
Josh Roy
7befec4420
Potential bed api (#3339) 2020-05-11 00:19:04 -04:00
Spottedleaf
27945a6b1f
Optimize WorldBorder collision checks and air
Port part of leafs changes from Tuinity, will worry about rest later with larger changes coming
2020-05-10 22:52:20 -04:00
Aikar
55e17a8599
Wait for Async Tasks during shutdown
Server.reload() had this logic to give time for tasks to shutdown,
however shutdown did not...

Adds a 5 second grace period for any async tasks to finish and warns
if any are still running after that delay just as reload does.

Closes #3337
2020-05-10 22:17:55 -04:00
Aikar
b59052566b
Ensure Entity AABB's are never invalid
If anything used setPositionRaw, it left potential for an AABB
to be left stale at their old location, which could cause massive
AABB boxes if movement ever then got called on the new position.

This guarantees any time we set the entities position, we also
update their AABB.
2020-05-10 22:14:47 -04:00
Aikar
a054aa6f02
Properly remove Entities from current chunk
We store a reference to the chunk the entity is currently in, so use it
to more accurately unregister it in chunkCheck

Should maybe fix some entity loss issues.
2020-05-10 05:52:31 -04:00
Aikar
c894ddfd38
Fix teleporting onto a chunk line
Obscure detail in that if you teleport right on a chunk line, it
adds +1 to your collision check and will check the unloaded neighbor.

but the call to load the chunk then returned null if it was pending unload, such
as the load we did in Player List

However we want gen=true for players here anyways, so use getType
2020-05-10 05:52:26 -04:00
Aikar
57d6cc0158
Send LOGIN protocol packets immediately - Fix disconnect during async prelogin 2020-05-10 03:12:05 -04:00
Aikar
cd93e54df3
Don't use our modified chunk checks for collision in world gen
Fixes issues with errors in logs on generating chunks
2020-05-10 02:27:50 -04:00
Aikar
b4003ef1ca
Allow loading entities current chunk if needed to fix collision checks
Having trouble reproducing this myself, but this should do it.
2020-05-10 01:04:45 -04:00
Aikar
e5f6489602
Add Urgent API for Async Chunks API and use it for Async Teleport
This also cleans up the implementation of Async Chunks to get rid of most
Consumer callbacks and instead return futures.

This lets us propogate errors correctly up the future chain
(barring one isn't lost even deeper in the chain...)

So exceptions can now bubble to plugins using getChunkAtAsync
2020-05-10 00:57:03 -04:00
Aikar
ad8e59dc79
Ensure chunks loaded on respawn for suffocation check 2020-05-09 21:13:30 -04:00
Aikar
b1691e7b69
Remove some Streams usage in Entity Collision
While there is more down the collision system, remove some of the wrapping
Spliterator stuff as even this wrapper stream has shown up in profiling.

With other collision optimizations, we might also even avoid inner streams too.
2020-05-09 19:38:31 -04:00
JellySquid
d454bbd5e1
Implement JellySquid's Entity Collision optimisations patch
This patch replaces the vanilla collision code for both block and entity collisions with faster implementations by JellySquid, used originally in her Lithium mod.

Optimizes Full Block voxel collisions, and removes streams from Entity collisions

Original code by JellySquid, licensed under GNU Lesser General Public License v3.0
you can find the original code on https://github.com/jellysquid3/lithium-fabric/tree/1.15.x/fabric (Yarn mappings)

Ported by
Co-authored-by: Zoutelande <54509836+Zoutelande@users.noreply.github.com>

Touched up by Aikar to keep previous paper optimizations
2020-05-09 19:19:18 -04:00
Aikar
8e85f841d8
Optimize Collision to not load chunks
The collision code takes an AABB and generates a cuboid of checks rather
than a cylinder, so at high velocity this can generate a lot of chunk checks.

Treat an unloaded chunk as a collision for entities, and also for players if
the "prevent moving into unloaded chunks" setting is enabled.

If that setting is not enabled, collisions will be ignored for players, since
movement will load only the chunk the player enters anyways and avoids loading
massive amounts of surrounding chunks due to large AABB lookups.

Fixes #3321
2020-05-09 19:19:08 -04:00
Aikar
ceb824dbde
Fix ChunkCache .getXIfLoaded to use the local chunks in the cache
It was calling back out to world for it, we already have them.

Also use the nocache method for building the chunk cache too.
2020-05-09 14:58:08 -04:00
Aikar
f6f9157bd4
Don't toString block unless actually showing the message
This is causing MASSIVE performance issues with hoppers and block states
in general.
2020-05-09 13:55:41 -04:00
Aikar
b3f0527ac4
Add Spawn Entity SpawnReason API
So you can specify why an entity is spawning, ie NATURAL
2020-05-09 13:18:20 -04:00
Aikar
ec8d7387ad
MC-183249: Don't generate Carving Masks BitSet unless needed
This was using SIGNIFICANT amounts of memory allocating many
long[]'s for BitSets for every ProtoChunk in the cache that had
been unloaded and reloaded.

This will result in a nice memory reduction.
2020-05-09 12:13:29 -04:00
Aikar
2d401d2dfb
Improve BlockPosition hashCode/equals
Actually showed up in profiling as decent time spent here...

Noticed y/z was missing its final that it use to have, when x had it. some how
must of got messed up on some update. though people suggest this shouldn't of
mattered anyways, but lets put it back for safety.

Added cache of hashcode, as well as optimized the hash code using larger primes.
Also stored the long value of the x/y/z so that for equals we can compare a single long,
as well as have that long value cached for .asLong()
2020-05-09 10:59:29 -04:00
Aikar
2572bd017c
Fix world unload toLowercase - Fixes #3326 2020-05-09 10:59:10 -04:00
virustotalop
dda9680be5
Optimize brigadier child sorting performance
Use a TreeMap instead of a LinkedHashMap and then manually sorting

This will significantly reduce CPU usage on logging in and changing worlds.
2020-05-08 20:55:44 -04:00
Aikar
a71a4ec215
Fix CraftServer.unloadWorld Leak
The dimension manager was still registered which leaked the entire World
2020-05-08 20:40:42 -04:00
Aikar
f6fc0d4cd4
Don't create region files for chunk checks - mistake on upstream merge
Accidently handled a conflict wrong in a previous upstream merge and set wrong param.
2020-05-08 18:22:37 -04:00
Aikar
cfed00cf54
Fix Light Command
This lets you run /paper fixlight <chunkRadius> (max 5) to automatically
fix all light data in the chunks.

Permission node is same "bukkit.command.paper"
2020-05-07 19:44:33 -04:00
Aikar
a6ff84add7
Revert Nibble patch, causing issues still 2020-05-07 05:30:40 -04:00
Aikar
f1a8eb7fda
Use a finalizer for light packet instead of onPacketDone
Sadly sharing packets is breaking the ability to do this :(

We can prob still do a little better than this but will save that
for another commit.
2020-05-07 01:58:23 -04:00
Aikar
03c9bb05c1
Optimize NibbleArray to use pooled buffers
Massively reduces memory allocation of 2048 byte buffers by using
an object pool for these.
2020-05-07 01:32:02 -04:00
Aikar
d0a528b1cb
Move delayed init down later in tick, improve accuracy of startup time
Now tracks the full startup time for "Done" message at end, as apparently
Vanillas was done in a place that skipped tracking a lot of code too.

This fixes an issue with ViaVersion
2020-05-06 21:24:43 -04:00
Aikar
cc477e6abb
Force Plugins that use delayed tasks for init back in their place
Will now run those tasks just before we print "Done" so that startup
time is appropriately accounted for a plugin, as well as will no longer
trip the watchdog on startup.

Any plugin that tries to bypass this is just going to then trip watchdog
on Spigot too, so don't you dare.

Stop trying to cheat the delay your plugin added to startup time.

This isn't a behavior change because the first thing the tick does....
was run these tasks....

So it's just moving it slightly a few lines to be before a watchdog tick and
to account for it in "Done" time.

Fixes #3294
2020-05-06 20:18:31 -04:00
Aikar
597263fd55
Don't skip full player connection tick when dead
Still need to send keep alives and kick for idle

Fixes #3299
2020-05-06 19:30:47 -04:00
Spottedleaf
e2c23475b5
Revert loaded entity list (#3304) 2020-05-06 11:31:29 -05:00
Spottedleaf
fa87db6b91
Move another NetworkManager util into the inner class (#3303)
Those poor souls running outdated ProtocolLib.
2020-05-06 10:07:51 -05:00
Spottedleaf
841c7d1879
Make loaded entity list logic more consistent (#3301)
When adding/removing to a chunk, we need to also look at
editing the loaded entity list.

Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
2020-05-06 09:57:18 -05:00
Aikar
36f34f01c0
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears 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:
da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots
3abebc9f #492: Let Tameable extend Animals rather than Entity
941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent
4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME

CraftBukkit Changes:
933e9094 #664: Add methods to get/set ItemStacks in EquipmentSlots
18722312 #662: Expose ItemStack and hand used in PlayerShearEntityEvent
2020-05-06 06:05:22 -04:00
Aikar
5ca5f131bb
Rebuild all patches using the new rebuild pattern 2020-05-06 05:48:49 -04:00
Mariell Hoversholm
1ccff6fabb
Add villager reputation API 2020-05-06 05:48:06 -04:00
Minecrell
5c0bfffa09
Speed up rebuilding patches and reduce diff 2020-05-06 05:31:08 -04:00
Aikar
f37381ea8a
Optimize Network Manager to not need synchronization
Removes synchronization from sending packets
Makes normal packet sends no longer need to be wrapped and queued like it use to work.
Adds more packet queue immunities on top of keep alive to let the following scenarios go out
without delay:
  - Keep Alive
  - Chat
  - Kick
  - All of the packets during the Player Joined World event

Hoping that latter one helps join timeout issues more too for slow connections.

Removes processing packet queue off of main thread
  - for the few cases where it is allowed, order is not necessary nor
    should it even be happening concurrently in first place (handshaking/login/status)

Ensures packets sent asynchronously are dispatched on main thread

This helps ensure safety for ProtocolLib as packet listeners
are commonly accessing world state. This will allow you to schedule
a packet to be sent async, but itll be dispatched sync for packet
listeners to process.

This should solve some deadlock risks

This may provide a decent performance improvement because thread synchronization incurs a cache reset
so by avoiding ever entering a synchronized block, we get to avoid that, and packet sending is a really
hot activity.
2020-05-06 05:28:47 -04:00
stonar96
8f9df2ed43
Anti Xray cleanup
Undo the accidental renaming of a method in 0aad8bf
Aikar wanted to rename DataPalette#getDataBits(T object) to getOrCreateIdFor
in 0aad8bf but he also accidentally renamed
ChunkPacketInfo#getDataBitsIndex(int chunkSectionIndex) to
getOrCreateIdForIndex.

Remove chunk-edge-mode and chunk loading entirely from Anti-Xray
The chunk-edge-mode is broken since several versions.
Loading chunk neighbors for chunk edge obfuscation isn't needed anymore.
Unlike in previous versions, these are under normal circumstances already loaded
at the time we need them (plugins for example can bypass this).

Use the modified methods and constructors everywhere
Anti-Xray provides support for the default nms methods and constructors,
which where modified by Anti-Xray to avoid breaking stuff (plugins)
which somehow uses these methods.
However, the modified versions of those methods and constructors should be used
where possible.
2020-05-06 04:35:20 -04:00
Spottedleaf
878c66f116
No-Tick view distance implementation - Closes #3196
Implements world view distance getters/setters

Per-Player is absent due to difficulty of maintaining
the diff required to make it happen.
2020-05-06 03:50:52 -04:00