238 Commits

Author SHA1 Message Date
Dylan K. Taylor
f638845ef6 Merge branch '3.7' 2019-03-29 15:16:27 +00:00
Dylan K. Taylor
8e9f787d33 Implement runtimeID table randomization, closes #2841 2019-03-29 14:35:06 +00:00
Dylan K. Taylor
2a3e6dcf00 Rename BlockIds -> BlockLegacyIds 2019-03-23 19:46:31 +00:00
Dylan K. Taylor
79ef8e0803 Replace all legacy blockID references with BlockIds:: 2019-03-23 19:44:33 +00:00
Dylan K. Taylor
765c5963a8 Block: move a function 2019-03-23 15:01:35 +00:00
Dylan K. Taylor
5830ca958b Further out-phasing of legacy ID/meta
this paves the way for making internal IDs fully dynamic.
2019-03-17 16:01:04 +00:00
Dylan K. Taylor
6c8fa8ae28 More nullable and void typehints 2019-03-02 10:29:11 +00:00
Dylan K. Taylor
d961b272c7 Remove Tool <-> Block circular dependency in efficiency calculation 2019-03-01 18:18:56 +00:00
Dylan K. Taylor
d679fb7546 Block: Rename onActivate() -> onInteract() 2019-02-28 17:35:30 +00:00
Dylan K. Taylor
9ad0ea85c7 Rename two misleadingly-named functions 2019-02-27 12:59:12 +00:00
Dylan K. Taylor
6124f93cb4 Player: Clean up item frame drop-item hack
This is now re-routed through a newly-created attack-block handler.
Closes #339
2019-02-25 18:40:04 +00:00
Dylan K. Taylor
0f7f5362b8 Revert "Block: Get rid of state bitmasks"
This reverts commit b7b05e729e4fcfbe74786342882d011f004658fa.

Apparently this was premature, because we still need these things to deal with default state remapping.
2019-02-24 18:30:18 +00:00
Dylan K. Taylor
b7b05e729e Block: Get rid of state bitmasks
This story dates back to the days when getVariantBitmask() was introduced. The purpose of this function was to allow the variant info to be extracted from the metadata, for use with item drops. This was later changed to state bitmask for reasons I don't clearly recall.
In the great 4.0 refactor, we now store variant magic numbers separately, so we don't need any generic bitmask to split up variant and state information anymore. Variant is now only ever serialized and never deserialized. The same thing goes for blockIDs. States are read from the world by matching the full stateID against a table of prefilled known blocks, so the variant doesn't need to be deserialized - only the state does, and the state metadata readers already do bit fuckery by themselves and don't need this mask - notice how little actual changes were required to get rid of this?
2019-02-24 14:42:53 +00:00
Dylan K. Taylor
0bd1c1529e Block: Rename getItem() to asItem()
this has clearer meaning and is less likely to collide with other things.
2019-02-24 10:23:40 +00:00
Dylan K. Taylor
a5c260352d Infect remaining places with PHP 7.1 nullable typehints 2019-02-22 12:16:45 +00:00
Dylan K. Taylor
0120585aee Block: name is no longer nullable 2019-02-21 11:37:21 +00:00
Dylan K. Taylor
635fb5dde4 Clean up ID flattening hacks 2019-02-21 10:38:29 +00:00
Dylan K. Taylor
89fce7712a Block: Clean up internal constructor inconsistencies
I don't dare look how big this commit is or how many bugs it introduced...
2019-02-20 19:21:51 +00:00
Dylan K. Taylor
7170d9009d Enchantment: more static getters, firehose magic numbers
This is similar in nature to 646fea5a4ecbbdf3f0cbfc590d874dedc1a7bfc0.

On a side note: Migrating this way is a pain in the ass due to lack of types. What the heck is int supposed to mean?!?!?!?! At least if we wanted to go _back_ to magic numbers, it would be easy to locate everything with an Enchantment typehint...
2019-02-20 13:45:50 +00:00
Dylan K. Taylor
12dd6adfcc Block: Derive light filter level based on isTransparent() return
this might be dynamic.
2019-02-18 13:27:22 +00:00
Dylan K. Taylor
65ce1a7581 Block: fixed correct-type tiles getting overwritten
this manifested by crashing the server whenever someone used a furnace.
2019-02-15 13:37:57 +00:00
Dylan K. Taylor
7b6d76871c Block: add face and clickVector to onActivate() parameters, closes #267
this is an old old old issue, i don't know why it wasn't addressed sooner.
2019-02-13 14:29:59 +00:00
Dylan K. Taylor
01e7ebeb5c Automate creation and deletion of Tiles for appropriate blocks
closes #880
2019-02-13 12:27:13 +00:00
Dylan K. Taylor
c9f9f551f4 Merge branch '3.5' into master-rollback 2019-02-04 19:47:21 +00:00
Dylan K. Taylor
ddbb5363ef Block->getBreakTime() now throws InvalidArgumentException on items with bad efficiency values 2019-01-30 19:10:24 +00:00
Dylan K. Taylor
425ad6101f Block: rename onEntityCollide() -> onEntityInside()
this better describes what the hook is for.
2019-01-20 18:09:47 +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
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
Dylan K. Taylor
f60d13548e Fix another stupid recursion bug 2018-12-05 20:10:00 +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
7399e9036a Block: add method isSameState() to allow black-box comparison of blockstates 2018-11-25 14:53:57 +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
35d51570be Add and make use of Block->isSameType() 2018-09-27 17:59:06 +01:00
Dylan K. Taylor
75f364fcf2 Level: Remove obsolete \$direct parameter from setBlock()
this parameter was previously used to send blocks with a different set of flags, immediately, to players. However, the flags have been demonstrated useless and the direct sending is pointless now since packets are buffered now per session, so we might as well take advantage of the batched block update sending.
2018-09-27 16:15:07 +01:00
Dylan K. Taylor
0b989925d7 whitespace 2018-09-23 18:41:57 +01:00
Dylan K. Taylor
c501c740a1 Get rid of Block->canPassThrough()
This is only implemented in 1 place where the collision box should just be zero anyway, so there's no point this existing.

There's a lot of other blocks which should have bounding boxes without collision boxes as well, but that's outside the scope of this commit.
2018-09-23 17:05:03 +01:00
Dylan K. Taylor
1427da0aeb Clean up item handling of blocks 2018-09-23 14:21:37 +01:00
Dylan K. Taylor
ed1c511c3c Hacks for dealing with negative item IDs... 2018-09-23 14:14:58 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
caca097300 Merge branch 'release/3.3' 2018-09-19 16:18:53 +01:00
Dylan K. Taylor
4bc0d850b1 Added Block->getRuntimeId(), clean up some mess 2018-09-19 16:16:10 +01:00
Dylan K. Taylor
c0962a47be Block: Use parent::place() instead of setBlock() directly 2018-09-13 12:54:03 +01:00
Dylan K. Taylor
778eb5fb33 Block: Make getId(), getDamage(), setDamage() non-final
In the future, these methods will be used to derive ID/meta on the fly from properties instead of using them internally.
2018-09-12 19:40:19 +01:00
Dylan K. Taylor
f218868338 Separate facing/bearing handling from Vector3, deobfusticate a ton of @shoghicp old code 2018-09-05 19:56:14 +01:00
Dylan K. Taylor
99a0c2a188 Block: Make recalculation of BB non-dependent on block position
This now computes BBs relative to 0,0,0 and then offsets them as appropriate. This requires less boilerplate code and also furthers the goal of separating block types from instances.
2018-06-21 19:58:28 +01:00
Dylan K. Taylor
532269a484 Implemented block break XP drops 2018-04-15 19:03:18 +01:00
Dylan K. Taylor
9a1d3aec6b Flammable blocks adjacent to fire now burn away
There are some strange bugs with blockupdating causing invisible client-side-only fires that need to be investigated.
2018-04-10 09:59:10 +01:00