Commit Graph

1374 Commits

Author SHA1 Message Date
5052b75565 Separate Level management functionality from Server, clean up a bunch of mess 2019-01-12 19:11:05 +00:00
2924303169 Sync NBT dependency 2019-01-07 22:38:04 +00:00
78cb6445a5 Introduce TileFactory 2019-01-07 00:20:24 +00:00
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
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
d8d04aeb53 fixup some imports 2019-01-04 23:49:32 +00:00
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00
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
7a4e2371e6 master-specific PHPStan nits 2019-01-04 00:40:09 +00:00
e1064a9e36 Merge branch '3.5' 2019-01-04 00:37:48 +00:00
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
39c0fa6103 Merge branch 'release/3.5' 2018-12-29 20:58:12 +00:00
3f5e83a322 Backport 23954c4cda to 3.5 branch 2018-12-29 16:39:56 +00:00
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
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
ac87319aed Introduce a "block write-batch" concept (#2555)
Make use of writebatch to generate trees, doors and double plants safely

- Fixes #2441 
- Fixes #2548 
- Closes #2498
2018-12-29 12:00:14 +00:00
10ac322b8f Merge branch 'release/3.5' 2018-12-29 00:04:33 +00:00
beb5d72299 RegionLoader: fix off-by-one bug with large chunks, closes #2615 2018-12-29 00:02:54 +00:00
23954c4cda RegionLoader: Remove dead/broken code
garbage collection does need to be implemented, but I was looking at this code and found so many fucking bugs I decided it wasn't worth the effort of fixing.
2018-12-28 23:03:24 +00:00
ab75e89d95 Fixed generation changes in recent builds compared to 3.x
this was caused by improper RNG sanitization and a recent cleanup refactor.
2018-12-27 17:36:41 -05:00
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
e5cb48bec2 Merge branch 'release/3.5' 2018-12-22 13:31:18 +00:00
42f8e061a5 Merge branch 'release/3.4' into release/3.5 2018-12-22 13:29:41 +00:00
75df6973df LevelDB: Account for 2D maps tag being missing
I don't know why this would be missing, but in some cases it is, as seen in the crash archive. Whatever the case, we shouldn't be shitting the bed because of this.
2018-12-22 13:13:14 +00:00
16ffd99005 Merge branch 'release/3.5' 2018-12-21 18:40:04 +00:00
2664a1b4d8 Merge branch 'release/3.4' into release/3.5 2018-12-21 18:39:42 +00:00
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
b709e21622 Merge branch 'release/3.5' 2018-12-21 17:27:02 +00:00
517c4e5143 Merge branch 'release/3.4' into release/3.5 2018-12-21 17:26:32 +00:00
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
2506947641 Merge branch 'release/3.5' 2018-12-20 20:01:02 +00:00
ea9f9aa250 Update some non-critical protocol magic numbers 2018-12-20 19:59:42 +00:00
20aaa8373a Sound no longer extends Vector3 2018-12-16 14:26:42 +00:00
3c520aa786 Particle no longer extends Vector3 2018-12-16 14:15:41 +00:00
e0558d2551 Merge branch 'release/3.5' 2018-12-14 10:03:36 +00:00
c05697f506 Merge branch 'release/3.4' into release/3.5 2018-12-14 09:39:21 +00:00
ed88684e71 Fixed invisible FloatingTextParticle crashing the server, closes #2560 2018-12-14 09:30:14 +00:00
ffa733fe0c Merge branch 'release/3.5' 2018-12-12 19:51:41 +00:00
ec4c61e113 fix extradata defaults for broadcastLevelSoundEvent
fixes TNT sounds not working, amongst other things
2018-12-12 17:42:52 +00:00
30f5a8fac6 Protocol changes for 1.8.0 release 2018-12-11 21:05:03 +00:00
a9dc447f8f Tile: make createFromData() retrieve the ID by itself 2018-12-11 14:56:25 +00:00
d72e4cb9a1 Tile: remove createNBT(), add create(), createFromData(), createFromItem() 2018-12-10 19:40:37 +00:00
7d594ac6d8 Merge branch 'release/3.4' 2018-12-09 19:28:52 +00:00
f704061618 Tree: fixed being able to overwrite other trees
this was observable by planting a sapling underneath an existing tree and punching it with bone meal.

This change will also prevent trees generating too close together.
2018-12-09 19:26:48 +00:00
cd5b81bdb9 ChunkManager: Remove getBlockIdAt()/setBlockIdAt()/getBlockDataAt()/setBlockDataAt(), add getBlockAt() and setBlockAt() 2018-12-04 22:27:00 +00:00
8dd2ea22b8 Level: make use of fromFullState() in getBlockAt() 2018-12-04 22:05:00 +00:00
47e62b1b38 Level: Add setBlockAt() which accepts integers instead of Vector3 2018-12-04 21:59:58 +00:00
8051fa4f6d Remove some direct Position->level accesses 2018-12-03 21:39:17 +00:00
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
c3623478c1 Merge branch 'release/3.4' 2018-12-03 18:33:44 +00:00