Commit Graph

280 Commits

Author SHA1 Message Date
e97234d420 Refactor Rail handling to allow LSP-complaint shape handling
the reason there hasn't been any API until now is because of how inconvenient it was to expose a LSP-compliant API _and_ use the same base class for handling all the connection logic. This commit fixes that problem by abstracting shape handling away from BaseRail entirely, so that now it deals exclusively with connections. Deciding the shape of rail to use is now the job of the subclasses.
2021-07-22 17:35:10 +01:00
2476f40cc6 Rail: store shape instead of connections
shape is what we'll eventually expose on the API.
2021-07-22 16:45:42 +01:00
309bed414f Implemented sweet berries (#4164)
this doesn't implement the server-side logic for the "stickiness" (slowdown) because we don't have the system needed for it yet.
It also doesn't have parity with vanilla on the damage.
2021-07-19 20:01:33 +01:00
f64ef50ce3 ShulkerBox: fixed incorrect block-picking behaviour 2021-07-19 18:08:13 +01:00
dcbc0bc2a6 BrownMushroomBlock: remove useless function 2021-07-19 17:58:24 +01:00
71df15b4cc Removed FlowerPot update_bit hack 2021-07-19 17:39:35 +01:00
5874ce582a Implemented bells 2021-07-19 17:00:56 +01:00
d35e818ea0 BlockLegacyMetadata: added constants for bell attachment types 2021-07-17 19:11:28 +01:00
19e81b0cd3 BlockFactory: Be aware of potential size changes to metadata bits
during testing I found the need to use more bits (for example, bells have 32 states in 1.12).
2021-07-17 19:06:49 +01:00
9afc5be0f5 Shulker open/close sounds != shulker box open/close sounds 2021-07-10 19:59:59 +01:00
fc090e238d Add Shulker Boxes (#3678)
this implementation is working, although incomplete:

- The shulker close sound should not be played until the end of the shulker closing animation, which takes approximately 1 second.
- An open shulker box has a different collision box than a closed one - it should be +0.5 in whichever direction the shulker is facing. (During the animation, the bounding box also dynamically changes size - you can see this in vanilla by shooting an arrow into the top of an open shulkerbox facing UP, and then closing it - the arrow will fall and collide with the lid multiple times.

However, resolving both of these issues requires significant internal changes which are beyond the scope of this PR.
2021-07-10 19:48:38 +01:00
4e731f61af BlockFactory: Remap double slab IDs with 0x8 bit set to their base DOUBLE state, instead of BOTTOM
this was causing problems with slabs in converted Java worlds, where the
0x8 bit means 'smooth', instead of 'double'. In MCPE it has no effect.

Since Slab doesn't retain the high/low flag for DOUBLE type slabs, this
caused BlockFactory to assume that those states were invalid, and
remapped them to their base state instead.

The following changes resulted in the consistency check:

Remap changed for 43:8 (44:0 (Smooth Stone Slab) -> 43:0 (Smooth Stone Slab))
Remap changed for 43:9 (44:1 (Sandstone Slab) -> 43:1 (Sandstone Slab))
Remap changed for 43:10 (44:2 (Fake Wooden Slab) -> 43:2 (Fake Wooden Slab))
Remap changed for 43:11 (44:3 (Cobblestone Slab) -> 43:3 (Cobblestone Slab))
Remap changed for 43:12 (44:4 (Brick Slab) -> 43:4 (Brick Slab))
Remap changed for 43:13 (44:5 (Stone Brick Slab) -> 43:5 (Stone Brick Slab))
Remap changed for 43:14 (44:6 (Quartz Slab) -> 43:6 (Quartz Slab))
Remap changed for 43:15 (44:7 (Nether Brick Slab) -> 43:7 (Nether Brick Slab))
Remap changed for 157:8 (158:0 (Oak Slab) -> 157:0 (Oak Slab))
Remap changed for 157:9 (158:1 (Spruce Slab) -> 157:1 (Spruce Slab))
Remap changed for 157:10 (158:2 (Birch Slab) -> 157:2 (Birch Slab))
Remap changed for 157:11 (158:3 (Jungle Slab) -> 157:3 (Jungle Slab))
Remap changed for 157:12 (158:4 (Acacia Slab) -> 157:4 (Acacia Slab))
Remap changed for 157:13 (158:5 (Dark Oak Slab) -> 157:5 (Dark Oak Slab))
Remap changed for 181:8 (182:0 (Red Sandstone Slab) -> 181:0 (Red Sandstone Slab))
Remap changed for 181:9 (182:1 (Purpur Slab) -> 181:1 (Purpur Slab))
Remap changed for 181:10 (182:2 (Prismarine Slab) -> 181:2 (Prismarine Slab))
Remap changed for 181:11 (182:3 (Dark Prismarine Slab) -> 181:3 (Dark Prismarine Slab))
Remap changed for 181:12 (182:4 (Prismarine Bricks Slab) -> 181:4 (Prismarine Bricks Slab))
Remap changed for 181:13 (182:5 (Mossy Cobblestone Slab) -> 181:5 (Mossy Cobblestone Slab))
Remap changed for 181:14 (182:6 (Smooth Sandstone Slab) -> 181:6 (Smooth Sandstone Slab))
Remap changed for 181:15 (182:7 (Red Nether Brick Slab) -> 181:7 (Red Nether Brick Slab))
Remap changed for 422:8 (417:0 (End Stone Brick Slab) -> 422:0 (End Stone Brick Slab))
Remap changed for 422:9 (417:1 (Smooth Red Sandstone Slab) -> 422:1 (Smooth Red Sandstone Slab))
Remap changed for 422:10 (417:2 (Polished Andesite Slab) -> 422:2 (Polished Andesite Slab))
Remap changed for 422:11 (417:3 (Andesite Slab) -> 422:3 (Andesite Slab))
Remap changed for 422:12 (417:4 (Diorite Slab) -> 422:4 (Diorite Slab))
Remap changed for 422:13 (417:5 (Polished Diorite Slab) -> 422:5 (Polished Diorite Slab))
Remap changed for 422:14 (417:6 (Granite Slab) -> 422:6 (Granite Slab))
Remap changed for 422:15 (417:7 (Polished Granite Slab) -> 422:7 (Polished Granite Slab))
Remap changed for 423:8 (421:0 (Mossy Stone Brick Slab) -> 423:0 (Mossy Stone Brick Slab))
Remap changed for 423:9 (421:1 (Smooth Quartz Slab) -> 423:1 (Smooth Quartz Slab))
Remap changed for 423:10 (421:2 (Stone Slab) -> 423:2 (Stone Slab))
Remap changed for 423:11 (421:3 (Cut Sandstone Slab) -> 423:3 (Cut Sandstone Slab))
Remap changed for 423:12 (421:4 (Cut Red Sandstone Slab) -> 423:4 (Cut Red Sandstone Slab))
2021-07-08 20:37:19 +01:00
1d8f0033af BlockBreakInfo: Expose hardness multipliers as constants 2021-06-30 19:47:11 +01:00
7a35fdb1bb Allow Blocks to specify their max stack size 2021-06-30 19:28:16 +01:00
91d54ff0ad Removed unnecessary and/or obsolete GC hacks
the intent of these hacks was to break cyclic references to avoid having objects lingering in memory. However, all of the stuff that's being removed in this commit no longer has any effect anyway, due to the fact that these things don't circularly reference each other anymore. Notably, Tile inventories now keep Position instead of a Tile ref.
2021-06-30 19:16:25 +01:00
c05f6db8d9 Bed and Skull items now return a correct block, with appropriate type information
I wanted to do the same for banners, but unfortunately banners are a tad more complicated.
2021-06-30 17:27:14 +01:00
12905d8c27 BlockFactory: remove some TODOs 2021-06-30 17:03:20 +01:00
2b4a1ffdfb Bed: use ColoredTrait 2021-06-30 16:07:46 +01:00
9e79d48aeb BaseBanner: use ColoredTrait 2021-06-30 16:07:45 +01:00
94e16f416d Added KnownTranslationKeys (generated) and start using it 2021-06-29 22:46:04 +01:00
9b30c2feda Extract a DelegateInventory from EnderChestInventory 2021-06-26 21:01:40 +01:00
0910054c41 NetworkSession: Fixed InventoryManager nullability disaster
fixes #4277
fixes #4275
fixes #3139
2021-06-26 17:44:42 +01:00
444d902990 Fix CS 2021-06-21 20:45:31 +01:00
2a6009f8bf Check consistency of block remaps 2021-06-21 20:45:30 +01:00
745f455bd2 Door: change thickness to match MCPE
since MCPE-19214 still hasn't been fixed after all these years, it's safe to say they won't fix it in the near future, and this causes placement glitches in PM.
2021-06-18 19:10:50 +01:00
ec6103d61e Leaves can now be silk touched, closes #3714 (#4240) 2021-06-17 15:37:02 +01:00
61c59be299 Replace hardcoded block metadata shifts and masks with constants
we might want to make these bigger than 4 bits in the future.
2021-06-16 12:48:09 +01:00
6fb364b16f Store ender chest viewer count on the tile, instead of relying on the inventory's viewer count (#4238)
Fixes #4021
2021-06-13 14:37:09 +01:00
0ebafbd224 .... adding the most important part would probably help 2021-06-12 20:46:53 +01:00
7dcc4891ca Block: added getDropsForIncompatibleTool() 2021-06-11 19:09:14 +01:00
e4ed7bc4ea Fixed Mushroom Stem blocks never dropping anything 2021-06-11 19:04:12 +01:00
f68b9e79e1 Use typed properties in block namespace 2021-05-22 23:52:31 +01:00
73c229a236 Block: fixed LSP violations in blocks using BlockIdentifierFlattened
a property's type can't be changed by a subclass
2021-05-22 23:40:54 +01:00
285ad25168 BlockFactory: use the vars we already have, instead of repeated method calls 2021-05-22 12:45:08 +01:00
f655d262be Added stripped all-sided-log variants
again, these should be dynamic; but right now it's not possible.
2021-05-22 12:43:07 +01:00
ac04911e88 BlockFactory: fix potential crash 2021-05-21 21:44:17 +01:00
24405b63c1 Coarse is now a state of Dirt, instead of a separate block 2021-05-21 21:36:49 +01:00
df260034cd BlockFactory: Fill default state for all variants covered by bitmask when mismatch occurs 2021-05-21 21:12:34 +01:00
7968a72f0e Eliminate some duplicated breakinfos 2021-05-20 23:18:33 +01:00
376d2c4cd4 Consistently declare BlockBreakInfo at the constructor call site
instead of inside the class
2021-05-20 22:49:51 +01:00
af678f985d All types of coral now have fully dynamic types 2021-05-19 22:49:44 +01:00
b2e806e2fa World: Harden chunk loading against bad data in entity/tile NBT 2021-05-12 12:26:41 +01:00
f909557529 Cleaned up implementations for EnderChestInventory/DoubleChestInventory
previously, these were forced to extend BaseInventory because of the amount of crap in Inventory's interface.
This meant that these inventories had their own slots storage, which would be _mostly_ unused because these inventories aren't real inventories, but rather just delegates.
This lead to a variety of bugs in the past, such as certain API methods on BaseInventory not working correctly for DoubleChestInventory in particular.

Now, BaseInventory just implements the functional part of the inventory implementation, leaving the storage system up to the implementation.
A SimpleInventory class is provided with a simple SplFixedArray storage backing, which is used by most inventories.
EnderChestInventory and DoubleChestInventory now extend BaseInventory directly, and implement custom methods for dealing with their delegates.
2021-05-09 20:51:16 +01:00
7b2c6c5ceb Avoid more $this refs on long-life closures 2021-05-06 14:27:56 +01:00
4ca5558ec1 Merge remote-tracking branch 'origin/stable' 2021-05-05 11:14:01 +01:00
b8645f5c15 Clean up EnderChestInventory implementation
now, EnderChestInventory is just a temporary window, much like anvil/enchanting windows. It provides a gateway to the player's PlayerEnderInventory.

This removes one of the remaining obstacles to disallowing null World in Position constructor.
2021-05-02 14:26:27 +01:00
988c976459 Remove unused import 2021-05-02 13:40:18 +01:00
f538440bce De-spaghettify the hierarchy for chest inventories 2021-04-30 13:44:39 +01:00
d37016f43b Vine: added API to get/set faces 2021-04-30 13:35:38 +01:00
726978b8f1 Migrate all coloured blocks (except glazed terracotta) to dynamic colours 2021-04-29 20:11:03 +01:00