Commit Graph

79 Commits

Author SHA1 Message Date
2a3e6dcf00 Rename BlockIds -> BlockLegacyIds 2019-03-23 19:46:31 +00:00
79ef8e0803 Replace all legacy blockID references with BlockIds:: 2019-03-23 19:44:33 +00:00
80ac0180b3 Remove redundant isAffectedBySilkTouch() overrides
this was needed previously to prevent dropping blockitems when these blocks were destroyed. Now the item form is always yielded instead.
2019-03-01 13:34:32 +00:00
d679fb7546 Block: Rename onActivate() -> onInteract() 2019-02-28 17:35:30 +00:00
0f7f5362b8 Revert "Block: Get rid of state bitmasks"
This reverts commit b7b05e729e.

Apparently this was premature, because we still need these things to deal with default state remapping.
2019-02-24 18:30:18 +00:00
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
a5c260352d Infect remaining places with PHP 7.1 nullable typehints 2019-02-22 12:16:45 +00:00
635fb5dde4 Clean up ID flattening hacks 2019-02-21 10:38:29 +00:00
22a21ecfd6 BlockTransaction: Take world in constructor 2019-02-16 19:57:55 +00:00
0794c94b4b Rename BlockWriteBatch -> BlockTransaction 2019-02-16 19:53:15 +00:00
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
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
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
20aaa8373a Sound no longer extends Vector3 2018-12-16 14:26:42 +00:00
8dbeda69a7 Make use of Facing::rotateY() to reduce boilerplate 2018-12-07 10:49:12 +00:00
39e383a175 Entity: add getHorizontalFacing(), clean up some boilerplate code 2018-12-05 20:27:43 +00:00
1170b66fd5 Automate creation of tiles when they are used to store block properties 2018-11-24 19:44:31 +00:00
3af293f024 Added a mechanism for blocks to detect dynamic state properties from surroundings 2018-11-24 19:43:02 +00:00
b2201c8c59 Further cleanup to general AABB handling 2018-11-24 19:17:03 +00:00
101de7adda Update Math dependency, obliterate some nasty code from Block 2018-11-23 19:41:52 +00:00
d011fc518e Fixed wooden doors not dropping when removing supporting block, closes #2436 (#2496) 2018-10-29 16:16:57 +00:00
35d51570be Add and make use of Block->isSameType() 2018-09-27 17:59:06 +01:00
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
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
1bb4daa7d1 Fixed mess of rotations being inverted 2018-09-16 17:37:36 +01:00
65684eec99 Door: fixed bad rotation when no player is specified 2018-09-13 18:36:50 +01:00
c0962a47be Block: Use parent::place() instead of setBlock() directly 2018-09-13 12:54:03 +01:00
f218868338 Separate facing/bearing handling from Vector3, deobfusticate a ton of @shoghicp old code 2018-09-05 19:56:14 +01:00
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
ac5a91b67e Cleaned up bool comparison mess 2018-03-19 14:10:55 +00:00
86eee429bb Block: Split onUpdate() into several functions, removed Level::BLOCK_UPDATE_* constants
This allows the removal of lots of ugly code, and also exposes lots of similarities with how this update type was handled. This can be further improved in the future to more generically handle cases.

I realized in the process of changing this, that it might actually be simpler to treat to treat scheduled updates and neighbour updates as one and the same. They use the same mechanism for being saved on chunks (TileTicks),
and doing that would make updating only require one queue instead of two.

RedstoneOre: use onActivate() to trigger glowing
this is not technically correct behaviour, but this preserves the current behaviour.
2018-03-13 17:29:46 +00:00
73a5788774 Door: remove unused local variable 2018-03-07 18:53:38 +00:00
8d7c65585c Enchantment: Implement Silk Touch (#1912) 2018-01-14 13:37:27 +00:00
3a0cbd1cd4 Block: Cleaned up double-block break handling, close #1862, close #1525
This now removes the need for recursing around for structures comprised of multiple blocks. Instead, override getAffectedBlocks() to return all blocks that need to be deleted when the current block is deleted, and make sure that only one half of the block drops something. When a player breaks one of the blocks, all the blocks affected by that block will also be destroyed, creating particles and sounds where appropriate.

This fixes creative drops for double plants and beds.
2018-01-03 13:01:05 +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
d1db27016e s/facePos/clickVector/
clickVector better describes this
2017-10-27 19:05:26 +01:00
d8b1757ebc added some nullable and void typehints to Block API 2017-10-11 18:45:40 +01:00
6d5620606e Block->place() parameter refactor to make things clearer 2017-08-26 14:41:49 +01:00
8ce833bf74 Stripped redundant trailing commas 2017-08-25 12:41:49 +01:00
b8ade18888 Fixed double plants and beds sometimes dropping in creative 2017-08-21 19:25:04 +01:00
02f42eba48 Move block registration to its own class 2017-08-20 18:05:01 +01:00
c394aea803 Replaced more literal ints with Vector3 constants 2017-08-20 10:43:48 +01:00
e1d894057c Changed face position floating-point params to Vector3s 2017-08-20 10:23:34 +01:00
0e24596aed Changed block construction calls to Block::get() 2017-08-19 13:46:17 +01:00
41c6cb6f97 Added Block->getVariantBitmask(0 to cut down on getDrops() boilerplate, fixed several blocks incorrectly retaining meta when broken 2017-08-18 19:49:28 +01:00
83af4dcd59 Block API typehints 2017-08-17 13:50:19 +01:00
2103c981a9 Replaced literal ints with Vector3 constants for Block->getSide() calls 2017-08-04 13:33:23 +01:00
6ae24c5c19 Removed unnecessary methods Block->canBeActivated() and Item->canBeActivated() (needless extra confusion) 2017-07-30 18:14:43 +01:00
6e4b8ba677 Removed some useless code 2017-07-30 17:24:33 +01:00
2a7b736f18 Heap of bugfixes, cleanup and PHP 7 upgrades 2017-07-13 19:18:56 +01:00