Commit graph

5784 Commits

Autor SHA1 Nachricht Datum
Nassim
31d7686d26
Add item slot helper methods for various inventories (#3221) 2020-05-05 19:49:16 -04:00
MiniDigger
75e1e3b3e1 Mob Goal API 2020-05-05 18:05:27 +02:00
Aikar
c7bc393a87
Revert "Don't flush packet queue off main thread"
This reverts commit 1abd2bd279.

Sadly not gonna work due to server pings
2020-05-04 04:50:08 -04:00
Aikar
1abd2bd279
Don't flush packet queue off main thread
Increases risk of deadlock if a plugin using protocollib sends a packet
async, and then a listener then reads world state, and main thread is then
blocked waiting for the queue to flush.

This will break out of the synchronized block when it jumps to the netty event loop.

See: https://gist.github.com/aikar/e7abb2ba7059149d0a91f7a226e98590
2020-05-04 03:07:04 -04:00
Aikar
a4ed58a9ab
Clean up Direct Memory Region Files Fix for different Java versions
Java 9+ doesn't allow using the exposed cleanup method, but added
a new method on Unsafe to do it.

So have to detect java version and use the appropriate strategy.
2020-05-04 02:19:38 -04:00
Aikar
55e3501967
Set cap on JDK per-thread native byte buffer cache
See: https://www.evanjones.ca/java-bytebuffer-leak.html

This is potentially a source of lots of native memory usage.

We are clearly seeing native usage upwards to 1-4GB which doesn't make sense.

Region File usage fixed in previous patch should of tecnically only been somewhat
temporary until GC finally gets it some time later, but between all the various
plugins doing IO on various threads, this hidden detail of the JDK could be
keeping long lived large direct buffers in cache.

Set system properly at server startup if not set already to help protect from this.
2020-05-04 01:14:10 -04:00
Aikar
b5101f4f97
Cleanup Region Files Direct Memory on close
Mojang was semi leaking native memory here by relying on finalizers
to clean up the direct memory.

Finalizers have no guarantee on when they will be ran, and since this is
old generation memory, it might be a while before its called.
2020-05-04 01:08:51 -04:00
Aikar
81e655d7fa
Optimize Voxel Shape Merging
This method shows up as super hot in profiler, and also a high "self" time.

Upon analyzing, it appears most usages of this method fall down to the final
else statement of the nasty ternary.

Upon even further analyzation, it appears then the majority of those have a
consistent list 1.... One with Infinity head and Tails.

First optimization is to detect these infinite states and immediately return that
VoxelShapeMergerList so we can avoid testing the rest for most cases.

Break the method into 2 to help the JVM promote inlining of this fast path.

Then it was also noticed that VoxelShapeMergerList constructor is also a hotspot
with a high self time...

Well, knowing that in most cases our list 1 is actualy the same value, it allows
us to know that with an infinite list1, the result on the merger is essentially
list2 as the final values.

This let us analyze the 2 potential states (Infinite with 2 sources or 4 sources)
and compute a deterministic result for the MergerList values.

Additionally, this lets us avoid even allocating new objects for this too, further
reducing memory usage.
2020-05-03 23:02:52 -04:00
Aikar
ed9fc11fe3
Sync position on teleportation
We've seen many a cases where the "last good" x/y/z is desynced from
the x/y/z that is checked for moving too fast.

Theory is that when you have multiple movement packets queued up,
and the player is teleported after the first then the 2nd and 3rd come in,
it is triggering a massive movement velocity.

This will ensure that the servers position is synchronized anytime player is te

Fixes #3258
2020-05-03 15:29:53 -04:00
Aikar
9c326fceda
Nanothing to see here 2020-05-03 03:38:19 -04:00
Aikar
3e9fc24b66
Attempt to fix FastLogin maybe 2020-05-03 02:20:56 -04:00
Aikar
932e97f345
Rename to AsyncPlayerSendSuggestionsEvent to be consistent in naming
It was still technically read correctly in what it was doing, but
all our Player events begin with Player.

Nothing uses this event yet so safe to rename.

If you are some rapid adopter of this event, sorry :P
2020-05-02 15:29:03 -04:00
Aikar
0dd1907568
AsyncSendPlayerSuggestionsEvent Brigadier Event
Going to be used for ACF to be able to send Tooltips to client :)

This is after completions are calculated, to control what is sent to the client.
2020-05-02 14:17:17 -04:00
Aikar
a9e20e5f62
Fix being kicked in survival for block picking - Fixes #3277 2020-05-02 13:32:03 -04:00
MiniDigger
4d20537e6e
Expose game version (#3274) 2020-05-02 04:56:08 -04:00
Aikar
85fb00152a
Validate PickItem Packet and kick for invalid - Fixes #3256 2020-05-02 03:10:26 -04:00
Aikar
5729bc716e
Special case Keep Alive packets from Anti Xray
If a server enables Anti Xray, packet sending can be delayed until the
chunk has been obfuscated, blocking the entire queue from going out.

On a busy server, considering Anti Xray can only operate on a single
thread, it is quite possible the obfuscation backlog can get quite behind
resulting in a delay of sending packets.

And logging in is a clear area where lots of chunks are going to be queued
for obfuscation....

We should probably special case a few more than this (such as chat),
but this will hopefully help the keep alive issues some people run into.
2020-05-02 01:01:50 -04:00
Spottedleaf
a76b774070
Improved oversized chunk data packet handling
Now target all TE data, except for TE's that do not have
update packets.
2020-05-02 00:31:24 -04:00
Aikar
a6f78170db
Use Vanilla Bed Search for non players (Villagers)
Should help #2959
2020-05-01 21:56:50 -04:00
Aikar
68fb98b50f
Fix 2 plugin specific issues with loot drop and pathfinders
Based on what that collection does, won't really cause any real issue for UC.
So let it silently be ignored.

Fixes #3269
Fixes #3255
2020-05-01 21:48:43 -04:00
Aikar
6e41f7b79a
Update Activation Range 2.0 with more villager controls
Now has separate configs to control Villager immunities a bit.

whether or not they wake up due to panic situations (raids)
and when should they wake up when work is available after being
inactive for so long, and for how long.

This work config may make the 'wake up inactive' feature for villagers
useless in most scenarios, but if there is a situation where the villager
does go without needing to work for a long period of time, it would kick
in then.

This also removes movement based immunities, so now villagers should only move
if they trigger a work immunity, panic immunity, or inactive wake up immunity.

Fixes #3263
2020-05-01 21:48:33 -04:00
Aikar
57dd397155
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:
b999860d SPIGOT-2304: Add LootGenerateEvent

CraftBukkit Changes:
77fd87e4 SPIGOT-2304: Implement LootGenerateEvent
a1a705ee SPIGOT-5566: Doused campfires & fires should call EntityChangeBlockEvent
41712edd SPIGOT-5707: PersistentDataHolder not Persistent on API dropped Item
2020-05-01 18:03:57 -04:00
Shane Freeder
a6a197b11f
Bump API ASM version to follow server 2020-04-30 22:04:30 +01:00
MiniDigger
5ab48ad901
Fix commodore (#3264)
fixes #3262
2020-04-30 18:05:20 +01:00
Aikar
87e7ee7e79
Improve Async Login to avoid firing in middle of Entity Ticking
If a sync load was triggered, it would process pending join events,
causing them to be added to the world in the middle of the entity ticking
process.

This caused their add to be queued instead of immediate, causing
"Illegal Tracking" errors.

This schedules it to fire at the players next Connection Tick, which
is exactly where this entire process use to run anyways.

Also added missing tab complete and syntax for syncloadinfo debug command
2020-04-29 05:40:40 -04:00
Aikar
8ce3dd5f71
[CI-SKIP] Fix Mojang API Brigadier dep - THIS IS NOT A NEW BUILD
Needs to be compile to expose it

Nothing to download here.
2020-04-28 03:27:45 -04:00
Aikar
00d760a537
Fix build due to spigot changing the build timestamp process 2020-04-27 04:03:00 -04:00
Aikar
842e040c19
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:
220bc594 #486: Add method to get player's attack cooldown
21853d39 SPIGOT-5681: Increase max plugin channel size
5b972adc Improve build process
b55e58d9 Note which custom generator is missing required method

CraftBukkit Changes:
893ad93b #650: Add method to get player's attack cooldown
ef706b06 #655: Added support for the VM tag jansi.passthrough when processing messages sent to a ColouredConsoleSender.
e0cfb347 SPIGOT-5689: Fireball.setDirection increases velocity too much
94cb030f SPIGOT-5673: swingHand API does not show to self
b331a055 SPIGOT-5680: isChunkGenerated creates empty region files
e1335932 Improve build process
a8ec1d60 Add a couple of method null checks to CraftWorld
ce66f693 Misc checkstyle fixes
8bd0e9ab SPIGOT-5669: Fix Beehive.isSedated

Spigot Changes:
2040c4c4 SPIGOT-5677, MC-114796: Fix portals generating outside world border
ab8f6b5a Rebuild patches
e7dc2f53 Rebuild patches
2020-04-27 03:34:45 -04:00
nick
c03260a280
Add getter and setter for villager's numberOfRestocksToday (#3231) 2020-04-27 02:13:41 -04:00
Aikar
fe366fbe77
null check tracker for entity metadata update - Fixes #3070 2020-04-27 01:57:42 -04:00
Aikar
fdf41b742d
Implement Brigadier Mojang API
This is the start of a new module for Paper to add support for API's
that interface Mojang API's directly.

This allows us to version properly by MC version incase Mojang makes any major breaking changes.

It also lets us separate Mojang API's from Paper-API so our downstream friends at Glowstone
will not have to worry about Mojang code.

Adds AsyncPlayerSendCommandsEvent
  - Allows modifying on a per command basis what command data they see.

Adds CommandRegisteredEvent
  - Allows manipulating the CommandNode to add more children/metadata for the client
2020-04-27 01:42:12 -04:00
Aikar
e0ea2e0e14
Entity Activation Range 2.0! Major improvements to restoring behavior
Calling this 2.0 as it's a pretty major improvement with more knobs to twist.

This update fixes many things. The goal here is to restore vanilla behavior to some degree.
Instead of permanent inactive pools of animals, let them show some signs of life some....

Yes this may reduce performance compared to before, but I hope it is minimal. Got to find a balance.
Previous EAR logic really compromised vanilla behavior of mobs. This tries to restore it.

Changes:

1) All monsters are now classed as Monster. Mojang has an interface, we should use it.
   - This now includes Shulker, Slimes, see #2 for Phantom and Ghast
2) Villagers and Flying Monsters now have their own separate activation range configs.
   - Villagers will default to your Animals config
3) Added a bunch of more immunities
   - Brand new entities are immune for a few seconds
   - Entities that recently traveled by portal are immune for few seconds
   - Entities that are leashed to a player are immune
   - Ender Signals are immune
   - Entities that are jumping, climbing, dying (lol) are immune
   - Minecarts are now always immune to the movement restriction
4) Villagers immunity received major overhaul...
   - Now has many immunities for Villager activities to let them
     do their work then go back inactive
   - Such as interacting with doors and workstations should be more normal now
   - Raids will trigger immunities, in that villagers will run and hide when bell rings.
   - Raid should keep the entire village immune during the raid to keep gameplay mechanics
     You can disable raids by game rule if you dont want raids

Then the big one.....

Wake Up Inactive Entities:
One issue plagueing "farms" is that we no longer even let entities move now.
Entities become lifeless.

A new system has been introduced to wake up inactive entities every so often, to let
them stretch their legs, eat some food, play with each other and experience the good entity life.

Animals, Villagers, Monsters (Includes Pillagers), and Flying Monsters will now wake up every
so often after staying inactive for a very long. This grants them a temporary immunity, that
the goal is they will then find "stuff to do" by having a longer activity window.

How many to wake up, how often they wake up, and for how long they wake up are all configurable.

Current EAR Immunities really don't give some entities enough of a window to find work
to then keep them immune for the work to even start. This system should help that.

We will only wake up a few entities per tick on the first wave, restoring 1 per type per world per tick.

So say you have 10 monsters qualify for inactive wake up, all 8 will wake up on the first eligible tick,
and then the 9th will wake up on next tick, 10th on next tick.

If for 5 ticks no more inactive wake up, our buffer will have built back up to 5, and then 5 can go next needed tick.

This basically incrementally wakes them up, preventing too many from waking up in a single tick, to reduce impact to TPS.
2020-04-27 01:22:44 -04:00
Aikar
10396d28e1
Fix Tracking Range mismatch on Vehicle/Passenger checks
This was missing Entity Tracking Range support, creating different
values in this section vs normal section.

Concerned this might of caused some carnage on tracker if this code says
"Yes you should track this player 500 blocks away from you on a horse" and then
the other check uses the normal value.
2020-04-27 00:33:14 -04:00
Aikar
68994c64ec
Add a config to turn off Optimized TickList #3145
Set:

settings:
  - use-optimized-ticklist: false

If you are having issues with block updates and want to see if this fixes it.

Please report confirmations on #3145 ticket
2020-04-26 04:01:03 -04:00
Aikar
d847d33684
Improve blocking players from opening inventories while sleeping
This is friendlier to plugins as far as the plugin is concerned,
the inventory did open and immediately closed.

We avoid sending the packet to client so they don't see the window
flash either.

If a plugin wants to avoid wasteful fake opens, they should check
that the player is not sleeping before opening the inventory.
2020-04-26 03:26:21 -04:00
Aikar
ac4f6b5022
Clean up Timings and Async Chunk Configs
Renames a bunch of timings to be more appropriate for the new environment.

Many things dealt with sync loads which wasn't correct anymore.
adjusted timings to be a little bit more accurate here.

Also cleaned up old 1.13 async chunks configs so people won't keep
thinking they can change some of those configs when they can't.
2020-04-26 02:19:43 -04:00
Aikar
fcf89e852e
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.

Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.

This guarantees that your chunk will load with at most around 1ms delay.

Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...

Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.

Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.

This is now fixed.

Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.

Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".

This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.

It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.

We solve this by ensuring new additions do not enter the currently iterated queue.

Each depth level will have its own queue.

Fixes #3220
2020-04-26 01:14:52 -04:00
Spottedleaf
ab36835ca0
Improve random ticking behaviour - Fixes #3181 2020-04-25 18:43:13 -04:00
Aikar
a6ac47e502
Fix numerous item duplication issues and teleport issues
This notably fixes the newest "Donkey Dupe", but also fixes a lot
of dupe bugs in general around nether portals and entity world transfer

We also fix item duplication generically by anytime we clone an item
to drop it on the ground, destroy the source item.

This avoid an itemstack ever existing twice in the world state pre
clean up stage.

So even if something NEW comes up, it would be impossible to drop the
same item twice because the source was destroyed.

This should make us more forward proof on preventing dupes.

These dupes have been in for years at this point, they aren't new...
Everyone knows about them and are mitigating with plugins atm breaking gameplay.

so better to make it clear its fixed in the messaging.

I am submitting this to Mojang.
2020-04-25 16:38:14 -04:00
BillyGalbreath
b7402f11c3
Add phantom creative and insomniac controls (#3222) 2020-04-25 16:33:18 -04:00
Wesley Smith
75819fac2d
Fix Potion#toItemStack swapping the extended and upgraded constructor values (#3216) 2020-04-25 00:01:45 +01:00
Aikar
cb15cfa4f8
Improve Async Login so pending connections dont get exposed
We still keep vanilla process of waiting for existing session to be removed before logging in
by storing a separate map of pending.

also fire the callback using executor incase further recursion causes any trouble
2020-04-24 05:48:51 -04:00
Aikar
f275e9cb9c
Optimize Hoppers - Major Boost - Got2GoFast!
* Don't check for Entities with Inventories if the block above us is also occluding (not just Inventoried)
* Remove Streams from Item Suck In and restore restore 1.12 AABB checks which is simpler and no voxel allocations (was doing TWO Item Suck ins)
* Restore missing application of previous optimization to getEntities for Inventoried Entities from CullanP
* Use getChunkIfLoadedImmediately for getting loaded entities (faster/simpler, no risk of sync loads)
2020-04-24 03:01:17 -04:00
Aikar
0106485ccb
Improvements to watchdog changes
catch a thread death, fix invalid watchdog timeouts

<= 0 seconds will now change to 5 minutes.
2020-04-24 00:27:50 -04:00
Aikar
65934b1fec
Fix build for last commit. 5am commits are great 2020-04-23 04:53:20 -04:00
Aikar
3f4360296c
Don't process watchdog until server has fully started and ticked.
I think adjusting watchdog settings may of caused instant crashes.

Fixes #3209
2020-04-23 04:49:41 -04:00
Aikar
938bd97255
Don't fire BlockFade on worldgen threads - Fixes #3208
Caused a deadlock
2020-04-23 01:37:30 -04:00
Aikar
509a828e06
Fix loading spawn chunks when async chunks is off
I feel sorry for those who need to do this, and now feel sorry more
since back to slow startups again.

There is keep-spawn-loaded-range in paper.yml to reduce the range to
mitigate this if you must keep async chunks off.
2020-04-22 05:47:35 -04:00
Aikar
8a91bfd240
Improvements to async login
Bump chunk priority to ensure chunks load fast
Handle case where client disconnects before they even fire PlayerJoinEvent
  - no longer call PlayerQuitEvent or print quit message.
  - don't save the player data file if never joined. Nothing has changed.
    CraftBukkit has a bug here that if you do save it, you will lose
    any horse that the player logged off on because the horse hasn't
    been resummoned yet.
2020-04-22 05:40:06 -04:00
Ytnoos
bf698865f7
Revert "Re-track players that dismount from other players" 2020-04-22 03:16:31 -04:00