90 Commits

Author SHA1 Message Date
Dylan K. Taylor
be37236c76 Deduplicate code for general classpath registries 2018-07-26 15:21:03 +01:00
Dylan K. Taylor
d305a1342f Make Tile::registerTile() and Entity::registerEntity() throw exceptions instead of returning false 2018-07-26 14:55:55 +01:00
Dylan K. Taylor
f315aca4c3 Tile: make saveNBT() return a CompoundTag
I don't know why I made it take a parameter for this...
2018-06-16 17:59:41 +01:00
Dylan K. Taylor
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
Dylan K. Taylor
c4c6c58615 Added some missing typehints 2018-06-10 17:18:55 +01:00
Dylan K. Taylor
14914781fc Added exception throws when a closed tile or entity attempts to schedule itself for updating
I can't believe it took so long to find what was causing these stdClass bugs.
2018-06-07 12:37:26 +01:00
Dylan K. Taylor
fa21cd96c5 Tiles no longer store their NBT at runtime
This is a significant breaking change for anything utilizing Tiles as they now do not store their NBT at runtime anymore.
This is another step in the process of ridding PocketMine-MP of runtime NBT.

It can be noticed that all tiles are now using class fields to store properties instead of NBT, which is much faster, uses less memory and is also more concise when written in code.

Highlights:
- Tile->namedtag has been removed.
- Tile->saveNBT() now accepts a CompoundTag() parameter. Typically it's expected that this will be fed a newly-created CompoundTag (this part may be improved in the future).
- New internal methods Tile->readSaveData() and Tile->writeSaveData() have been added. Instead of overriding __construct() and saveNBT() to load and save properties from NBT, you should now implement these methods instead.

This is not final and will see further changes before it's done.
2018-06-03 18:29:08 +01:00
Dylan K. Taylor
febba6e3a6 Tile: call parent constructor instead of duping code 2018-05-18 16:49:14 +01:00
Dylan K. Taylor
1648fff916 Replaced Position->getLevel() null checks with isValid() 2018-03-20 11:10:36 +00:00
Dylan K. Taylor
73e09392b6 Timings: Clean up some terrible code, move namespaces 2018-03-19 19:05:51 +00:00
Dylan K. Taylor
596c8a7b4f Tile: Removed cyclic dependence on Chunks
Chunks were used by tiles for a couple of things:
- 1. for coordinates - which can be gotten using bitshifts
- 2. setChanged() - which is unnecessary as seen in the previous commit

Removing this circular dependency was actually remarkably easy to do.
2018-03-15 10:21:42 +00:00
Dylan K. Taylor
28e601bbb9 Tile: added handling for PC 1.11 save IDs 2018-02-28 19:58:18 +00:00
Dylan K. Taylor
0ad8ea6e92 Remove unused imports 2018-02-24 19:01:09 +00:00
Dylan K. Taylor
ce4e0bf69c Tile: fixed copying of custom block data 2018-02-15 11:47:12 +00:00
Dylan K. Taylor
c747c7d025 Throw exceptions when entities/tiles are created on chunks that don't exist
These assertions don't make sense. Since the chunk field is used below in both cases, the chunk should **never** be null no matter what.
2018-01-02 13:12:54 +00:00
JackNoordhuis
686e1c4470 Implement ender chest (#1462) 2017-11-22 14:25:21 +00:00
Dylan K. Taylor
8d59843020 Order tile constants alphabetically 2017-11-22 14:00:41 +00:00
Dylan K. Taylor
74b074753f Bulk addition of constant visibilities
thanks PhpStorm inspections plugin for annoying the shit out of me until
I did this.
2017-11-21 14:44:10 +00:00
Dylan K. Taylor
e0654b85ba get rid of dynamic field assignments
nearly there now... eventually
2017-11-17 10:43:51 +00:00
Sandertv
2794df34ab Basic implementation of banners, including API to modify them with ease. (#1331)
Banner crafting is NOT implemented yet.
2017-11-15 11:10:46 +00:00
Dylan K. Taylor
827ee5ff33 more constants in Tile 2017-11-08 10:49:15 +00:00
Dylan K. Taylor
18e4e5364f Fixed getBlock() performance degradation caused by 781de3efabcd526281fd1adc8ce881d408471563, added Level->getBlockAt() to avoid creating vectors everywhere 2017-10-20 13:22:49 +01:00
Dylan K. Taylor
20b86bdea8 Cleaned up tile NBT handling, use new CompoundTag API methods 2017-10-16 16:48:24 +01:00
Dylan K. Taylor
0b1a9ba062 Added more typehints to Tile namespace 2017-10-16 16:14:44 +01:00
Dylan K. Taylor
af85659c63 Remove redundant property from Tile 2017-10-16 12:35:32 +01:00
Dylan K. Taylor
95fa1824c8 Use a trait for nameable tiles instead of repeating code 2017-10-16 12:32:10 +01:00
Dylan K. Taylor
b7a9e10d49 Some cleanup to how tiles are created 2017-10-11 18:08:08 +01:00
Dylan K. Taylor
cef9c4621c added som PhpDoc to Tile 2017-10-09 17:27:34 +01:00
Dylan K. Taylor
151681bd80 Remove some dead properties from Tile 2017-10-09 17:25:10 +01:00
Dylan K. Taylor
23752548fe Address several LevelDB related crashdumps in the crash archive 2017-08-30 15:42:31 +01:00
Muqsit Rayyan
7d3fca83f0 Tile NBT usage enhancements (#1259)
* Do not create new NBT objects on Tile::getSpawnCompound()

* PocketMine's string formatting

* Remove more useless array indices and create lesser new NBT objects.

* Remove unused imports and type-hint Sign::setText() params

* Do not mess with Sign::setText() params due to #1204

* Fix formatting

* Make getSpawnCompound() final and add abstract addAdditionalSpawnData()

* Make the same changes for Bed tile

* Fix a missing "->" and remove some unneeded int casting.
2017-08-06 12:35:37 +01:00
Dylan K. Taylor
1f4e6535bb Added Bed tile and support for coloured beds 2017-07-30 19:34:06 +01:00
Dylan K. Taylor
c3b8be3f60 and more typehints 2017-07-14 10:56:51 +01:00
Dylan K. Taylor
a73c6f1861 Fixed some unnecessary FQNs in docs 2017-06-25 12:43:04 +01:00
Dylan K. Taylor
a365c831a8 Fixed some doc problems 2017-06-25 12:07:28 +01:00
Dylan K. Taylor
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
Dylan K. Taylor
6ece57e23e Merge changes from master 2017-04-21 22:48:18 +01:00
Sandertv
1c7773c5f1 Visibility keyword before final or abstract keyword. (#814) 2017-04-13 20:58:53 +08:00
Dylan K. Taylor
3e76c3a6dd Added handling for tile picking, added API for setting item lore
worked almost out of the box (some W10 equipment bugs though)
2017-03-28 18:47:51 +01:00
Dylan K. Taylor
cbb003bf29 Guard against leaked closed tiles leaking chunks and NBT trees
Once again, this does not fix the actual issue, only reduces the impact of it.
2017-03-18 11:50:05 +00:00
Dylan K. Taylor
c21197ef17 Removed entanglement between chunks and providers. WARNING: BREAKING API CHANGES.
- All entity and tile constructors now require a \pocketmine\level\Level instead of a \pocketmine\level\format\Chunk.
- Chunk->getProvider() and Chunk->setProvider() have been removed.
- Chunk::__construct() has had the $provider parameter removed.
- Chunk->unload() has had the unused $save parameter removed.
- ChunkEvents now take a Level parameter instead of going through the Chunk

API bump to 3.0.0-ALPHA4
2017-02-21 17:08:45 +00:00
Dylan K. Taylor
9004417456 Fixed file headers (#255) 2017-01-13 16:57:05 +00:00
Dylan K. Taylor
55791e0819 Fix doc formatting from FullChunk -> Chunk mass-replace 2017-01-03 22:24:28 +00:00
Dylan K. Taylor
2987c7a80c Remove unnecessary duplication 2016-12-20 12:59:27 +00:00
Dylan K. Taylor
4063bc4ffb Relocated Server->registerTiles() to Tile::init() 2016-12-20 12:59:27 +00:00
Dylan K. Taylor
90957cd908 Some tile improvements and added ItemFrame tile 2016-12-20 12:59:26 +00:00
Dylan K. Taylor
4c49db6036 New generic in-memory chunk format, fixed 0.17.0.1 chunk loading
Terrible performance, needs profiling. TODO: fix this.
2016-11-27 21:57:59 +00:00
Dylan K. Taylor
995d0847f9 Fix tile derp 2016-11-27 13:06:11 +00:00
SOFe
58ff381557 PhpStorm automated formatting (#11)
* PhpStorm reformatting

* Tuned PhpStorm reformatting

* Improved ItemIds and BlockIds formatting

* Tuned more PhpStorm reformatting

* Improved string concatenation
2016-10-03 19:05:48 +08:00
SOF3
6fc435da0e
Imports rearrangement 2016-10-03 00:43:46 +08:00