802 Commits

Author SHA1 Message Date
Dylan K. Taylor
bb27c76d13 Merge branch '3.5' 2019-01-25 17:12:00 +00:00
Dylan K. Taylor
5bf7350ee5 Level: change some stupid var names 2019-01-25 17:10:44 +00:00
Dylan K. Taylor
8a0f5cd7c9 Merge branch '3.5' 2019-01-25 13:19:40 +00:00
Dylan K. Taylor
636cc1c199 Level: some mitigations for #2675
this reduces the performance impact by using smaller keys, which reduces the key distance for nearby blocks.
2019-01-25 13:17:33 +00:00
Dylan K. Taylor
469b24b0a5 Remove built-in spawn protection
Users should use the new BasicSpawnProtection plugin instead.
2019-01-24 16:56:15 +00:00
Dylan K. Taylor
4ae6428641 Level: rename getCollisionCubes() -> getCollisionBoxes()
these aren't cubes! shoghi, please read the dictionary.
2019-01-20 18:11:20 +00:00
Dylan K. Taylor
9d8a70d5cf Level: use appropriate exceptions 2019-01-19 14:55:09 +00:00
Dylan K. Taylor
e341f3dce2 Level: rename getName() to getDisplayName() 2019-01-17 16:46:56 +00:00
Dylan K. Taylor
76f1ee1827 Add restrictions on packet send directions with interfaces
This prevents plugins sending wrong packets at the compiler level (or would, if we had a compiler). It's more robust than a getter for client/server and throwing an exception since a static analysis tool can detect faults created by sending wrong packets from the server. This is also used to deny service to dodgy clients which send wrong packets to the server to attack it.
2019-01-17 12:51:24 +00:00
Dylan K. Taylor
b82e00ffdf Extract a Packet interface from DataPacket
this is in preparation for clientbound/serverbound packet separation. I did this already on another branch, but the changeset was dependent on a massive refactor to split apart packets and binarystream which i'm still not fully happy with.
2019-01-17 12:21:56 +00:00
Dylan K. Taylor
1dca9074d5 Remove hacks for triggering adjacent light refill 2019-01-13 14:17:56 +00:00
Dylan K. Taylor
82788774b0 Level: Queue all block updates until the end of tick
this allows deduplicating block updates when lots of adjacent blocks are set on a tick, which has beneficial effects on performance. It also fixes #2659.

Future scope:
- Use this mechanism to deal with explosions properly.
- Don't execute block updates for air blocks.
2019-01-13 13:24:02 +00:00
Dylan K. Taylor
5052b75565 Separate Level management functionality from Server, clean up a bunch of mess 2019-01-12 19:11:05 +00:00
Dylan K. Taylor
7d827a1c65 Introduce EntityFactory
This contains all of the static stuff that was previously embedded in the Entity static root. This solves a bunch of problems like circular dependencies between parent and child classes, encapsulating logic and reducing the size of the enormous Entity.php.
2019-01-06 23:54:29 +00:00
Dylan K. Taylor
b1cef8509a Revamp Entity construction
This is a similar refactor to the one I recently did for tiles.

- Entity::createEntity() is removed. In its place are Entity::create() (runtime creation, use where you'd use a constructor, accepts a ::class parameter, throws exceptions on unknown entities) and Entity::createFromData() (internal, used to restore entities from chunks, swallows unknown entities and returns null).
- Entity::registerEntity() is renamed to Entity::register().
- Added Entity::override() to allow overriding factory classes without touching save IDs. This allows more cleanly extending & overriding entities. This method only allows overriding registered Entity classes with children of that class, which makes code using the factory much more sane and allows to provide safety guarantees which make the code less nasty.
- Entity::getKnownEntityTypes() is renamed to Entity::getKnownTypes().
- ProjectileItem::getProjectileEntityType() now returns a ::class constant instead of a stringy ID.
- Cleaned up a bunch of nasty code, particularly in Bow.
2019-01-06 23:33:36 +00:00
Dylan K. Taylor
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00
Dylan K. Taylor
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
Dylan K. Taylor
e1064a9e36 Merge branch '3.5' 2019-01-04 00:37:48 +00:00
Dylan K. Taylor
d71a543d10 Fixed a bunch of things PHPStan finds unpalatable
close #2614, fix a bunch of docs bugs, fix sendCreativeContents() crash on Human holders, move some inline variable declarations
2019-01-04 00:23:09 +00:00
Dylan K. Taylor
39c0fa6103 Merge branch 'release/3.5' 2018-12-29 20:58:12 +00:00
Dylan K. Taylor
5ecc5ed7e0 Get rid of catch-all on chunk unload
god only knows what the fuck is going on in here that warrants this catch-all... so let's remove it and find out!
2018-12-29 16:37:59 +00:00
Dylan K. Taylor
cd80ae00d4 Handle errors properly on chunk load
Only CorruptedChunkException and UnsupportedChunkFormatException are expected. Anything else should crash the server.
2018-12-29 16:37:10 +00:00
Dylan K. Taylor
a6cd9ae029 Implemented #2556: don't send tile NBT updates until the end of tick
this eliminates spam when tile spawn NBT changes a lot during a tick, for example the lines of a sign being updated.

closes #2556
2018-12-26 22:18:52 +00:00
Dylan K. Taylor
16ffd99005 Merge branch 'release/3.5' 2018-12-21 18:40:04 +00:00
Dylan K. Taylor
2664a1b4d8 Merge branch 'release/3.4' into release/3.5 2018-12-21 18:39:42 +00:00
Dylan K. Taylor
4249c00c3e Level: Fixed generation/send race condition causing blocks to be missing on the client
this FINALLY fixes the remaining occurrences of half-trees.
2018-12-21 18:39:33 +00:00
Dylan K. Taylor
b709e21622 Merge branch 'release/3.5' 2018-12-21 17:27:02 +00:00
Dylan K. Taylor
517c4e5143 Merge branch 'release/3.4' into release/3.5 2018-12-21 17:26:32 +00:00
Dylan K. Taylor
69c343bb9b Level: fix setChunk() deleting tiles when replacing a chunk with the same chunk
this can be desirable to trigger events related to chunks changing, such as chunk sending.
2018-12-21 17:24:08 +00:00
Dylan K. Taylor
20aaa8373a Sound no longer extends Vector3 2018-12-16 14:26:42 +00:00
Dylan K. Taylor
3c520aa786 Particle no longer extends Vector3 2018-12-16 14:15:41 +00:00
Dylan K. Taylor
e0558d2551 Merge branch 'release/3.5' 2018-12-14 10:03:36 +00:00
Dylan K. Taylor
c05697f506 Merge branch 'release/3.4' into release/3.5 2018-12-14 09:39:21 +00:00
Dylan K. Taylor
ed88684e71 Fixed invisible FloatingTextParticle crashing the server, closes #2560 2018-12-14 09:30:14 +00:00
Dylan K. Taylor
ffa733fe0c Merge branch 'release/3.5' 2018-12-12 19:51:41 +00:00
Dylan K. Taylor
ec4c61e113 fix extradata defaults for broadcastLevelSoundEvent
fixes TNT sounds not working, amongst other things
2018-12-12 17:42:52 +00:00
Dylan K. Taylor
30f5a8fac6 Protocol changes for 1.8.0 release 2018-12-11 21:05:03 +00:00
Dylan K. Taylor
cd5b81bdb9 ChunkManager: Remove getBlockIdAt()/setBlockIdAt()/getBlockDataAt()/setBlockDataAt(), add getBlockAt() and setBlockAt() 2018-12-04 22:27:00 +00:00
Dylan K. Taylor
8dd2ea22b8 Level: make use of fromFullState() in getBlockAt() 2018-12-04 22:05:00 +00:00
Dylan K. Taylor
47e62b1b38 Level: Add setBlockAt() which accepts integers instead of Vector3 2018-12-04 21:59:58 +00:00
Dylan K. Taylor
8051fa4f6d Remove some direct Position->level accesses 2018-12-03 21:39:17 +00:00
Dylan K. Taylor
9fb365306a Make Block->position() accept Level,x,y,z instead of Position
since this is an internal method, it doesn't make sense to force a single parameter that requires potentially constructing a separate object just for the parameters, so we pass primitives instead, which are also easier to typehint against.
2018-12-03 21:18:22 +00:00
Dylan K. Taylor
c3623478c1 Merge branch 'release/3.4' 2018-12-03 18:33:44 +00:00
Dylan K. Taylor
e4223bb7dc Level: Duct tape fix for crashy trees at the top of the world
this doesn't fix shit but it at least doesn't crash. Fixing this properly can't be effectively done any other way without backwards compatibility breaks. Fortunately it's not common practice to grow trees at the top of the world.
2018-12-03 18:30:27 +00:00
Dylan K. Taylor
16006f9175 Make Tile constructors non-dependent on NBT 2018-11-30 17:05:36 +00:00
Dylan K. Taylor
0fec58730b Level: fixed recursion bug when reading dynamic states
calculating dynamic states in some cases requires getting properties from neighbouring blocks, but getting these blocks also causes their dynamic states to be calculated, leading to a bouncing recursion.
This change allows retrieving blocks without calculating dynamic state information, if the call was generated by calculating dynamic state information.
Since these blocks are incomplete, they should not be cached and are only used to allow another adjacent block to complete its state. It is therefore not possible for a block's dynamic states to depend on another block's dynamic states.

This recursion bug was observable by running /gc and walking into a door, which would cause the server to freeze and crash.
2018-11-24 19:44:31 +00:00
Dylan K. Taylor
1170b66fd5 Automate creation of tiles when they are used to store block properties 2018-11-24 19:44:31 +00:00
Dylan K. Taylor
3af293f024 Added a mechanism for blocks to detect dynamic state properties from surroundings 2018-11-24 19:43:02 +00:00
Dylan K. Taylor
b2201c8c59 Further cleanup to general AABB handling 2018-11-24 19:17:03 +00:00
Dylan K. Taylor
98efd27543 Remove ability to set blockID and blockdata independently
This was the cause of many inconsistency and broken world bugs. In the future (once we switch to paletted chunks) this won't be possible anyway. For now, some temporary API is provided to allow modifying chunkdata directly, but it is required that **both** must be provided.
2018-11-22 16:53:22 +00:00