Commit Graph

58 Commits

Author SHA1 Message Date
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
78a80a6958 Tighten validity checks for block metadata
This filters out over 200 invalid states which were previously considered just fine, including zero-width cakes, buttons with broken facing values, furnace/chest with crazy values, and more.
2018-12-28 14:33:09 +00:00
c53d3c28fb Register a couple of simple missing redstone blocks 2018-12-05 19:11:54 +00:00
281d8fd813 Redstone torch is lit by default 2018-12-05 15:07:18 +00:00
2014ebccd8 Make state setters fluent, clean up some BlockFactory noise 2018-12-05 15:03:59 +00:00
8051fa4f6d Remove some direct Position->level accesses 2018-12-03 21:39:17 +00:00
a2253e9e7d Flatten still liquid blocks into a liquid block property 2018-11-30 16:06:35 +00:00
328ee40d5d Bring back support for all-sided logs, properly this time 2018-11-25 19:52:45 +00:00
a7eaec13b9 Merge branch 'release/3.4' 2018-10-24 15:53:13 +01:00
09985c5763 Fixed async light population producing garbage when generator isn't registered, closes #2488 2018-10-24 15:49:00 +01:00
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
742fbc25c3 BlockFactory: fixed 0 being assumed to be default if used
this defeated the whole point of adding this code ...
2018-10-20 21:42:34 +01:00
f671da99a6 BlockFactory: fix failing test 2018-10-12 21:40:45 +01:00
7af7783cc8 BlockFactory: Register block to id|variant without setting state to allow non-zero default states
This will be needed to deal with things like chest/furnace which don't use 0 as a valid state (these both use facing horizontal for rotation, and vertical is invalid, so 0 would mean downwards facing which is invalid.
2018-10-12 20:05:44 +01:00
0520598584 BlockFactory: skip blockstates which corrupt the metadata
if the metadata doesn't match what was inputted when reading back, it's an invalid state and should not be registered.
2018-10-12 19:49:26 +01:00
a430f7f4f7 Allow static properties and state masks to vary based on variant 2018-10-06 17:33:28 +01:00
2600cf5977 Split some block variants into their own classes where behaviour differs 2018-09-28 16:21:03 +01:00
ed1c511c3c Hacks for dealing with negative item IDs... 2018-09-23 14:14:58 +01:00
56d9943b0d Nuke Block->meta, split into variant and state properties, lots of cleanup
This is a major change to the way block metadata is handled within the PM core. This separates variant metadata (which really ought to be part of the ID) from state metadata, and in a couple of cases flattens separate states of blocks together.

The result of this is that invalid variants can be much more easily detected, and additionally state handling is much cleaner since meta is only needed at the serialize layer instead of throughout the code.
2018-09-21 19:28:10 +01:00
9b4d82630b BlockFactory: remove $solid
this is premature optimization and will run into problems once we enter the flattening.
2018-09-20 16:26:15 +01:00
dbe0ee2d44 BlockFactory: don't pre-populate gaps with UnknownBlock objects
this produces a minor reduction in memory usage.
2018-09-19 15:17:39 +01:00
48a5eeb3a4 BlockFactory: remove some useless static arrays 2018-09-19 15:06:58 +01:00
986077e03c Protocol changes for 1.6.0.1 2018-08-21 17:14:53 +01:00
d8cf835f92 BlockFactory: better handling for dodgy IDs
I thought I'd already dealt with this, but it seems not.
2018-07-13 12:31:22 +01:00
41a179e6e1 BlockFactory: fix bug in light filters which could result in negative light levels (and therefore wraparounds) 2018-06-05 18:12:45 +01:00
ec28612a12 BlockFactory: partial revert of 515e4aabc4
it's necessary to register these to fill the static property arrays. Someday these won't be necessary I hope...
2018-06-01 17:08:58 +01:00
d535fe20a3 BlockFactory: split up static ID mapping registration from other things
this is actually HUGELY WASTEFUL on memory. An average of 3 MB is wasted per AsyncWorker on this.
2018-06-01 10:28:53 +01:00
515e4aabc4 BlockFactory: minor reduction in memory usage
removing useless array and don't pre-populate with UnknownBlock objects
2018-06-01 10:15:20 +01:00
aa6666872a BlockFactory: added a hack for weird air blocks with non-zero damage values
I don't know what causes this to occur, but they should never have non-zero damage values, so we discard the metadata.
2018-04-09 16:35:31 +01:00
5b7b2dd0e2 Merge changes from ALPHA11 for 1.2.13 2018-04-04 11:31:39 +01:00
a1cf5dbd1e fix doc inconsistency 2018-04-04 11:01:14 +01:00
c86132028e BlockFactory: add new "dynamic" fake runtime IDs for unknown legacy ID/meta combinations
This is basically how blockstate discovery would actually work in the full-blown system. This maps blocks with unrecognized blockstates to static runtimeIDs not known to the client.

This means that all blocks which don't have corresponding runtimeIDs in the new system will translate to update! blocks instead.

Mojang do this differently: they try to a) match id+meta, if that fails b) match id+0, and if that fails, then replace with update! block runtime ID. I can't do that here because I need to be able to convert both ways. They only need to be able to convert from legacy -> new.
2018-04-04 11:00:58 +01:00
5ce55bd3b0 duct tape for block ID remapping 2018-04-04 11:00:39 +01:00
af2435f199 Removed redundant checks from ItemFactory::init() and BlockFactory::init()
These are never called accidentally, or at least it's highly unlikely to do so. It might be reasonable to throw exceptions for this, but for the meantime they are redundant - extra indentation for no good reason.

This also removes the $force parameter from BlockFactory::init().
2018-02-15 17:42:03 +00:00
a84aba5517 Replaced some bad usages of Vector3 get*() with their respective getFloor*() 2018-02-14 18:45:10 +00:00
4f8e4f0522 Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00
686e1c4470 Implement ender chest (#1462) 2017-11-22 14:25:21 +00:00
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
5c92c8a9d3 added red sandstone and red sandstone stairs 2017-10-18 19:42:12 +01:00
d2dc49cd9c Refactor Slab logic away from WoodenSlab, added StoneSlab2 and its double 2017-10-18 19:27:54 +01:00
eeea4fa06a Added some new blocks 2017-10-13 11:51:38 +01:00
3eb73ab468 Abstracted Fence code away from wooden fences 2017-10-12 17:04:49 +01:00
d8b1757ebc added some nullable and void typehints to Block API 2017-10-11 18:45:40 +01:00
2be8b576ef Changed constructor of ItemBlock to allow handling blocks with different item IDs, added more doors 2017-10-09 11:58:58 +01:00
c79a5509f6 Implemented concrete powder
this is a little buggy with water updating due to a hack for liquids to fix a CPU leak (210bdc2436), but everything works fine when a block nearby gets updated.
2017-09-26 18:56:43 +01:00
f5b0cbb337 Generated some TODOs for BlockFactory & ItemFactory 2017-09-26 16:15:35 +01:00
5aba87b250 Added brown and red mushroom blocks 2017-09-21 14:07:51 +01:00
07268e4b37 Added API methods to determine if a block or item is already registered 2017-09-11 16:22:55 +01:00
6abef6b22d Made block and item factory lists private to stop people doing stupid things with them 2017-08-29 10:53:01 +01:00