1417 Commits

Author SHA1 Message Date
Dylan K. Taylor
7b3993730a Block: Replace Color and WoodType magic numbers with type-safe objects
this provides automatic type safety without the need for magic number value checking everywhere.
2019-02-12 13:52:59 +00:00
Dylan K. Taylor
923b1ad9a6 Split up ChunkLoader and ChunkListener 2019-02-04 19:53:03 +00:00
Dylan K. Taylor
3e58708130 Add some missing @throws annotations 2019-02-04 19:50:43 +00:00
Dylan K. Taylor
8387c08db2 Level: remove unused variable 2019-02-04 19:50:24 +00:00
Dylan K. Taylor
c9f9f551f4 Merge branch '3.5' into master-rollback 2019-02-04 19:47:21 +00:00
Dylan K. Taylor
0f92ec6d2a Level: Record a debug message when chunks are loaded without loaders 2019-02-03 16:24:10 +00:00
Dylan K. Taylor
0b7ff6f2e7 Level: properly mark some functions as @internal
this ensures these functions won't appear in the documentation.
2019-02-01 14:33:06 +00:00
Dylan K. Taylor
5fe1d2e396 Level: fixed setChunk() bug introduced by eebd90ec4245abbcdddfc11fe3f4dc36a008f19e
Anyone who is using getChunkPlayers() should probably check that their code is actually doing what they think it's doing.
2019-01-31 18:28:42 +00:00
Dylan K. Taylor
c124aae219 Merge branch '3.5' 2019-01-30 13:09:43 +00:00
Dylan K. Taylor
331ae5498f Crash the generator when encountering invalid presets
this is a partial fix for #2717, but still not ideal because it'll spam whenever a chunk is attempted to be generated. However, fixing this properly requires potentially breaking API changes.
2019-01-30 12:29:04 +00:00
Dylan K. Taylor
5c24ac604a Merge branch '3.5' 2019-01-30 11:14:47 +00:00
Dylan K. Taylor
eebd90ec42 Level: fixed setChunk() leaking memory when not copying tiles/entities
closes #2719
2019-01-30 10:58:35 +00:00
Dylan K. Taylor
8e47a40b4c Level: rename poorly-named parameter of setChunk()
this now has a mouthful of a name. I'd like to invert it, but I can't do that without silently breaking backwards compatibility, which is unacceptable.
2019-01-30 10:26:18 +00:00
Dylan K. Taylor
c5f0665853 Merge branch '3.5' 2019-01-29 14:05:00 +00:00
Dylan K. Taylor
5364e4de68 Explosion: fix chest unpairing (root cause of #2701)
not ready to call this "fixed" yet because any chests that were already affected by the bug will still be affected. This change will prevent the creation of more broken chests like this.
2019-01-29 13:58:47 +00:00
Dylan K. Taylor
a6237958e8 Level: fix another crashy edge case in chunk ticking
this also removes a bias towards the chunk that the player is on, because this makes such chunks tick faster than adjacent chunks.
2019-01-27 20:41:47 +00:00
Dylan K. Taylor
729ae8bab7 Level: fixed adjacent chunk loading check 2019-01-27 16:20:38 +00:00
Dylan K. Taylor
eac8f639a7 Level: Simplify internal chunk ticking handling 2019-01-26 13:48:43 +00:00
Dylan K. Taylor
939f3efa3b Merge branch '3.5' 2019-01-25 19:44:08 +00:00
Dylan K. Taylor
c66dc7b273 Level: Optimize blockticking coordinate selection
generating 1 large bounded random costs the same as generating 4 small ones, so it makes more sense to do it like this instead.

Note that prior to 7.1 this code would not work due to it not handling 64-bit appropriately.
2019-01-25 19:43:16 +00:00
Dylan K. Taylor
6ee484e401 ChunkLoader: remove getLoaderId() (take 2) 2019-01-25 18:58:01 +00:00
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
6277787e0a Convert Particle to interface 2019-01-23 12:18:24 +00:00
Dylan K. Taylor
d2284d5c47 Move Particle IDs to protocol namespace 2019-01-23 12:16:01 +00:00
Dylan K. Taylor
23a18a8eb6 Convert Sound into interface 2019-01-23 12:10:24 +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
6df983da3e Merge branch '3.5' 2019-01-19 16:24:41 +00:00
Dylan K. Taylor
41fd7545e3 RegionLoader: Account for unexpected EOF when reading chunks, closes #2676 2019-01-19 15:49:19 +00:00
Dylan K. Taylor
9d8a70d5cf Level: use appropriate exceptions 2019-01-19 14:55:09 +00:00
Dylan K. Taylor
179fb9c7cb Fixed tree trunk generation bug introduced by ac87319aed4d556d85a8aeba0ea6da6667a5408f
Blocks were being overwritten in the writebatch which hadn't yet been set, so reading them from the world yielded air blocks instead of trunk, allowing the generation to overwrite blocks which should have been logs.
2019-01-19 13:41:28 +00:00
Dylan K. Taylor
6b7710e62b Introduce dedicated NBT data exceptions, fix up some corrupted chunk handling 2019-01-19 12:43:47 +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
f647b1b7a5 Some cleanup to internal sounds handling 2019-01-15 21:32:41 +00:00
Dylan K. Taylor
d2082c0383 Explosion: Recalculate light on destroyed blocks
this has been a bug for a long long time. I think the reason it was never addressed is because of the performance impact associated with it. However, that performance impact is now gone thanks to light update batching.
2019-01-13 14:22:35 +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
d2768188e8 LevelManager: remove unnecessary message 2019-01-12 19:52:28 +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
2924303169 Sync NBT dependency 2019-01-07 22:38:04 +00:00
Dylan K. Taylor
78cb6445a5 Introduce TileFactory 2019-01-07 00:20:24 +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
d8d04aeb53 fixup some imports 2019-01-04 23:49:32 +00:00
Dylan K. Taylor
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00