Commit Graph
47 Commits
Author SHA1 Message Date
Spottedleaf b10550736e Resolve memory leak involving TileEntities
Their chunk is set to null before removal, so we kept them around.
2019-05-14 14:54:32 -07:00
Spottedleaf 8ff0f5c10d Fix CraftServer#isPrimaryThread
md_5 changed it so he could shut down the server asynchronously
from watchdog, although we have patches that prevent that type
of behavior for this exact reason.
2019-05-13 21:13:31 -07:00
Spottedleaf ecafb51908 Fix MC-151674 Close RegionFiles when they get evicted from cache
https://bugs.mojang.com/browse/MC-151674
2019-05-12 19:30:57 -07:00
Spottedleaf 6635ae643e Review EntityPathfindEvent
Add missing target forward
2019-05-12 18:39:06 -07:00
Spottedleaf e36079cf6f Remove TODO on Add more Zombie API
Testing in game verified the zombie's arms raise and fall correctly
when using the API.
Renamed the OBFHELPER since the method is placed on EntityInsentient
(since we want to conflict on changes).
2019-05-12 18:04:29 -07:00
Spottedleaf 1936613b92 Remove TODO on Add ray tracing methods to LivingEntity
Note: The entity parameter stays 'this' since we want the block the
entity is targetting. This can change based on the block the player
has in their hand (see scaffholding). With a scaffhold in hand, the
scaffhold blocks in the world become solid 1x1x1 cubes, and without they
follow their model's shape.
2019-05-12 17:23:21 -07:00
Spottedleaf 79a43cd2a2 Fix TODOs in Optional TNT doesn't move in water
Turns out the doWaterMovement method was never called.
Moved the tracker updates into tick() and delete doWaterMovement
2019-05-12 16:42:49 -07:00
Spottedleaf 8d7a074503 Resolve TODO on PlayerNaturallySpawnCreaturesEvent
- Add missing isCancelled check

We don't need to worry about going out of range of int
since the value is clamped to view distance, and view
distance is clamped to 33
2019-05-12 15:34:42 -07:00
Spottedleaf 396186a950 Fix patch "Faster redstone torch rapid clock removal" (#2014)
Tux pointed out the patch still has O(n^2) time complexity since
the sublist class in arraylist does not override clear() from
AbstractList, which uses a forward moving iterator to clear
the list.

Resolved by using a peek and poll from ArrayDeque.

This patch also removes the useless WeakHashMap which holds
the list (it mapped world->list) and replaces it with a
field on World.
2019-05-10 08:48:58 -07:00
Spottedleaf c0f92870ab Use WorldServer#entitesById for entity iteration
WorldServer#globalEntityList is not the actual list of entities in a world
2019-05-07 18:49:41 -07:00
Spottedleaf 54388d8715 Fix legacy checks for plugins 2019-05-07 18:43:07 -07:00
Spottedleaf 665bb10aaa Actually write to the tracker field on entity
perhaps we can also look into removing this modification altogether
2019-05-07 18:13:24 -07:00
Spottedleaf e052a9deff Fix foxes not dropping items 2019-05-07 08:20:32 -07:00
Spottedleaf f1e494aba9 Fix tracking dead entities 2019-05-07 06:50:02 -07:00
Spottedleaf 71b1db46b1 Fix entities refusing to die and portal search not working 2019-05-07 05:00:51 -07:00
Spottedleaf 5a6ef6ed50 Update upstream 2019-05-06 17:33:26 -07:00
Spottedleaf 96b32aa6bc Fix more runtime stuff
Remove chunk neighbour system until we can figure out the chunk system
2019-05-06 17:05:41 -07:00
Spottedleaf b372f891aa Fix some runtime issues 2019-05-06 13:45:02 -07:00
Spottedleaf b64ce880b7 It compiles 2019-05-06 12:30:27 -07:00
Spottedleaf 6281fc8f11 Fix some more compile errors 2019-05-05 20:53:47 -07:00
Spottedleaf f9f71eb14e Update Upstream 2019-05-05 19:58:04 -07:00
Spottedleaf 52cd8744e0 More compile error fixes 2019-05-05 17:57:14 -07:00
Spottedleaf fad9f189b6 Fix some compile errors 2019-05-05 16:24:37 -07:00
Spottedleaf e80bd49c80 Fix some issues on the list 2019-05-05 14:39:51 -07:00
Spottedleaf d42c203adc Shove decompile fixes into the proper patch 2019-05-05 11:09:29 -07:00
Spottedleaf 670fbcd29e More 1.14 patches
now we can rebase
2019-05-05 10:19:34 -07:00
Spottedleaf 70e4947867 Correct patches 2019-05-05 04:32:20 -07:00
Spottedleaf be2fdf029f More 1.14 patches 2019-04-30 15:51:03 -07:00
Spottedleaf cab9529fe8 More 1.14 patches 2019-04-28 20:14:31 -07:00
Spottedleaf 567bd0fcac More 1.14 patches 2019-04-28 10:59:47 -07:00
Spottedleaf 9c7e369607 More 1.14 work 2019-04-26 23:26:04 -07:00
Spottedleaf f7dfbc078c More 1.14 updates (#1995) 2019-04-26 20:05:36 -07:00
Spottedleaf 8ee42908e1 Add Heightmap API (#1724)
Resolves #1672 
This API is intended to expose useful heightmaps found in the server to API. This exposes all of the live world heightmaps currently in the server. 
If a heightmap becomes impossible to implement, api spec allows the implementation to throw UnsupportedOperationException (far better than returning some weird unexpected value).

Tested via:
https://gist.github.com/Spottedleaf/5d47f67c55a9fb870251ff344bfeb6b3
2019-04-10 20:36:31 -07:00
Spottedleaf 5040cddd28 Add static encode/decode for block long keys (#1712)
Should make this API easier to use.
2019-04-08 21:08:14 -07:00
Spottedleaf 6719e61704 Only flush to disk on chunk saves if paper.flush-on-save is true (#1942)
The cost of a call to sync() adds up quickly and especially for
HDDs. Playing around generating chunks for a while warranted a
3 min save time on a HDD. This is unacceptable default behaviour
and now the behaviour is hidden behind a flag for server owners
who are OK with taking a hit on saves (although SSDs will not have
this issue remotely as bad, since most of the time was spent seeking).
2019-04-06 02:59:42 -07:00
Spottedleaf 0891f63203 Optimize GameRules to use LinkedHashMap
Previously TreeMap was used which has poor get(K) performance.
2019-04-04 18:13:49 -07:00
Spottedleaf 5d5e321bf8 Make region files more reliable to write to
Previously we would write to header before writing our chunk data,
which opens a window for corruption (or we would overwrite entirely).
Now the saving process has been changed to follow this chain of events:

1. We always allocate a new space to write so we do not potentially
overwrite and corrupt the current data
2. Write the chunk data first (the order of the fields in
the chunk data isn't relevant though)
3. Flush to disk
4. Write to the region header last
5. Flush to disk
6. Then we free the previous space allocated

With this chain of events it is impossible for a chunk write to corrupt
a region file, unless the operating system has lied and we have NOT flushed
to disk.

However server administrators are still recommended to continue performing
regular backups.

Note that when Mojang finally decides to change their region format
to deal with oversized chunks this patch must be changed to deal with
whatever system they decide to impose.

We also make use of two flushes to disk per chunk save (to ensure
ordering and ensure data has gone to disk), so this will negatively
affect save performance.
2019-04-01 18:58:55 -07:00
Spottedleaf 7e58932043 Allow login events to fire only after the server has loaded
Plugins that rely on the async login event to fire can miss the event
if a player tries to log in before the server has loaded.

The solution is to simply block the event threads from executing until
the server has loaded. This will not have an adverse affect on logins
since the event threads are cached and are only used for executing events
asynchronously.
2019-03-31 22:18:39 -07:00
Spottedleaf e98c779a36 Fix World#getChunkAtAsync(Location) variants incorectly calculating chunk x
The blockX needs to be floored before converted to int, as float -> integer
operations are truncation. (i.e -0.5 -> 0, we want -0.5 -> -1)
2019-03-02 15:45:42 -08:00
Spottedleaf b20fb55df3 Disable watchdog early timeout for CraftServer#reload() invocations (#1718)
Fixes GH-1381
2018-12-12 17:41:11 -08:00
Spottedleaf 4742d47392 Add PlayerConnectionCloseEvent (#1552)
* Add PlayerConnectionCloseEvent

This event is invoked when a player has disconnected. It is guaranteed that,
if the server is in online-mode, that the provided uuid and username have been
validated.

The event is invoked for players who have not yet logged into the world, whereas
PlayerQuitEvent is only invoked on players who have logged into the world.

The event is invoked for players who have already logged into the world,
although whether or not the player exists in the world at the time of
firing is undefined. (That is, whether the plugin can retrieve a Player object
using the event parameters is undefined). However, it is guaranteed that this
event is invoked AFTER PlayerQuitEvent, if the player has already logged into
the world.

This event is guaranteed to never fire unless AsyncPlayerPreLoginEvent has
been invoked beforehand, and this event may not be called in parallel with
AsyncPlayerPreLoginEvent for the same connection.

Cancelling the AsyncPlayerPreLoginEvent guarantees the corresponding
PlayerConnectionCloseEvent is never called.

The event may be invoked asynchronously or synchronously. As it stands,
it is never invoked asynchronously. However, plugins should check
Event#isAsynchronous to be future-proof.

On purpose, the deprecated PlayerPreLoginEvent event is left out of the
API spec for this event. Plugins should not be using that event, and
how PlayerPreLoginEvent interacts with PlayerConnectionCloseEvent
is undefined.
2018-12-12 17:17:38 -08:00
Spottedleaf 9857d5a9b4 Fix MaterialTagTest deterministic ordering
Tacos > Burritos
2018-10-08 01:33:25 -04:00
Spottedleaf 2375f1fef2 Make CraftWorld#loadChunk(int, int, false) load unconverted chunks (#1407) 2018-09-02 20:40:14 -07:00
searchndstroy 612bf465f2 Allow Blocks to be accessed via a long key (#1335)
The key can be retrieved via methods Location#toBlockKey() and
Block#getBlockKey()

World provides lookup for blocks by long key via method World#getBlockAtKey(long)

The formatting for the key is as follows:

10 bit y|27 bit z|27 bit x

The y value is considered unsigned while z and x are considered two's complement

Y range: [0, 1023]
X, Z range: [-67 108 864, 67 108 863]


Checked encoding and decoding via https://gist.github.com/Spottedleaf/74f4e241012ca2fa67d8f1c7e8e34722
2018-08-17 14:55:01 -07:00
searchndstroy 93e3a60a2f Optimize BlockPosition helper methods (#1339)
Resolves #1338
2018-08-17 14:51:56 -07:00
searchndstroy 093dd0a9b9 Fix watchdog restarting on short timeout (#1344) 2018-08-17 09:09:08 -07:00
Spottedleaf 19fa8bcffc Use invokeinterface for methods defined in interfaces in the ASM executor 2017-02-14 03:04:20 -08:00