6f82942c64
Block: document onInteract() clickVector
2023-06-21 16:57:39 +01:00
9c6d4093ae
Fixed crash when getting an item from a block which came from an item which came from a block
...
had a stroke yet?
2023-06-02 16:16:54 +01:00
07225df936
Block: fixed tile-stored properties sticking to the item in asItem()
...
this was enabling duplication of items, since the dropped item object would contain a Block which still referenced the framed Item.
2023-05-31 21:48:06 +01:00
8744032ab6
Fixed empty block handling after blockstate ID XOR change
2023-05-29 18:26:23 +01:00
cc77f18ff0
ÂBlock: added a TODO for getStateId()
2023-05-25 17:38:39 +01:00
ffe3556be1
Block: XOR state data with type ID, improve hash distribution
...
since most blocks have no state data, their lower 8 bits of state data were all zero.
This makes state IDs a bit more distributed for minimal cost.
I considered flipping these around and using type ID in the lower bits directly, but this worsened distribution for walls.
In the worst case, largest number of collisions drops from 11 to 5 with this change, and the number of states with unique hash keys increased from 3518 to 4461 (out of 7638). This is still a long way from perfect, but it's a decent improvement, improving the overall load factor from 1.6 to 1.3.
related to #5604
2023-05-25 16:35:45 +01:00
015c668885
Change confusing 'type data' and 'state data' terminology for blocks and items
...
For blocks, we now use 'block-item state' and 'block-only state', which should be much clearer for people implementing custom stuff.
'block-item state', as the name suggests, sticks to the item when the block is acquired as an item.
'block-only state' applies only to the block and is discarded when the block is acquired as an item.
'type data' for items was also renamed, since 'type' is too ambiguous to be anything but super confusing.
2023-05-16 14:07:29 +01:00
d4ca566fd0
Move block permutation generation into Block
...
this allows sealing off a whole bunch of internal APIs.
2023-04-21 20:38:28 +01:00
6c0ad9589b
Block: rename isSameType() to hasSameTypeId()
...
this should remove any ambiguity about its behaviour.
2023-04-21 20:25:21 +01:00
6acabf7a1b
Block: add clarifying note about isSameType()
...
I'm still not happy with this method though...
2023-04-13 13:40:53 +01:00
e40774d62f
Block: make internal methods private (they are no longer used outside of Block)
2023-04-13 13:06:56 +01:00
5950707267
Block: simplify required type data / state data bits code
2023-04-13 12:55:09 +01:00
874fdf5adb
ItemBlock: reference blocks directly (take 2)
...
This was first attempted in f64dc01bd1
, but reverted, since I hadn't considered how to handle stripping state data from blocks.
This removes the abusable API RuntimeBlockStateRegistry::fromTypeId() and related methods. These were only used to allow ItemBlocks to magically start referencing other blocks if the blocks were overridden by a plugin, but this was never a well-supported use-case anyway.
Instead of relying on RuntimeBlockStateRegistry, we remember the state that the block had during its constructor, and use that to normalize the non-item properties for asItem().
closes #5609
2023-04-13 12:44:54 +01:00
b9d62de29d
Pack wall connections into 7 bits for runtime data encoding
2023-03-04 15:47:34 +00:00
95c18ef99a
Block: change confusing naming of decode/computeStateData
...
these actually accept a combination of type and state data, so it's a bit inconsistent with other references to 'state data'.
2023-03-02 17:42:44 +00:00
972f107972
Block: added documentation for describeType() and describeState()
2023-03-02 17:31:52 +00:00
e15e53859f
tidy
2023-03-02 17:25:48 +00:00
4692552fdc
Block: improve documentation of type ID and state ID
2023-03-02 16:32:33 +00:00
cbb58d3e0d
Block: reduce method placement chaos
2023-03-02 16:23:40 +00:00
7c974a12e1
Revert "ItemBlock: drop the charade about overriding built-in block types"
...
This reverts commit f64dc01bd1
.
I forgot that the ItemBlock constructor implicitly strips off any states
of the origin block, which is something that we unfortunately can't do
any other way right now, since the blocks don't remember their default
states.
2023-03-02 15:51:55 +00:00
f64dc01bd1
ItemBlock: drop the charade about overriding built-in block types
...
this allows cleaning up a whole lot of abusable mess from the API, and we never properly supported overriding built-in block types anyway.
2023-03-02 15:50:18 +00:00
55a48e0c84
Block: specifying required type/state data bits is no longer required
...
RuntimeDataSizeCalculator allows calculating the number of required bits from describeType directly, which considerably reduces boilerplate code.
2023-02-16 16:45:19 +00:00
c2f6d8139a
Added interface RuntimeDataDescriber
2023-02-16 16:23:32 +00:00
f56339c306
Fix build
2023-01-26 14:48:43 +00:00
0a3ecfdae9
Clean up terminology around block state IDs and their handling
2023-01-25 19:01:15 +00:00
3a13f5cf5f
Merge branch 'next-minor' into next-major
2023-01-16 19:56:51 +00:00
6c0254c1eb
Block: document parameters of place()
2023-01-16 19:49:24 +00:00
4d79aced07
Merge branch 'next-minor' into next-major
2022-12-15 19:50:27 +00:00
99996b62d6
Align PhpDoc @param tags according to PHP-CS-Fixer
2022-12-06 13:21:20 +00:00
ab0202ba29
Block: correct documentation for getIdInfo() on PM5
2022-09-24 18:14:18 +01:00
9295afe8b9
Merge branch 'next-minor' into next-major
2022-09-24 18:12:38 +01:00
a7dfa0907c
Merge branch 'stable' into next-minor
2022-09-24 18:07:56 +01:00
f448b2e685
Block: Improve documentation for a whole bunch of methods
2022-09-24 18:06:46 +01:00
6a0c54f850
Block: Relocate and document addVelocityToEntity()
...
maybe we should consider merging this with onEntityInside(), since they are both called for the same reasons? ...
2022-09-24 17:32:02 +01:00
77a18d0aea
Block: add documentation for getFrictionFactor()
...
has no one ever questioned the fact that a higher _friction_ factor _reduces_ the block's friction???
2022-09-24 17:05:38 +01:00
140a809c40
Block: improve documentation of hasEntityCollision() and onEntityInside()
2022-09-24 17:04:42 +01:00
d9b050fb68
First look at using (very) basic tags for dynamic block properties
...
this allows plugins to, for example, add their own custom dirt-like blocks which support having flowers placed on them.
2022-07-24 00:08:02 +01:00
6a2315a63d
Accept BlockTypeInfo in Block constructor, instead of BlockBreakInfo
...
this will allow more stuff to be passed via the constructor without having to change dozens of classes to do it.
2022-07-23 20:42:54 +01:00
f6c9bf5cd1
Merge branch 'next-minor' into next-major
2022-07-20 20:55:33 +01:00
2940547026
Eliminate repeated calls to Position->getWorld()
...
as well as improving readability, it also improves performance in some areas.
2022-07-20 20:44:05 +01:00
6d4279671e
A giant hack to cut down code needed for runtime block serialization by 50%
...
this also avoids repeated information and inconsistencies.
2022-07-18 18:25:41 +01:00
4f2f9b4352
Block::readStateFromWorld() now returns the block object that should be used for the target position
...
this enables changing the block type completely if the situation calls for it.
2022-07-16 20:04:08 +01:00
d0ff6d2e36
Enable various types of interaction to return items to the player, without needing to have a bunch of boilerplate creative mode and held item checks
...
it became glaringly obvious that this was needed because of #4827 and #4868 .
this is further needed with the addition of cauldrons.
2022-07-16 19:50:33 +01:00
ba2baba7cc
Added netherite blocks and items
2022-07-14 20:39:09 +01:00
20cb67461f
Block: add the current class to the exception messages for block runtime data serialization
2022-07-13 19:50:35 +01:00
c67e42a723
Add a hook to enable blocks to react to projectiles colliding with them
...
this enables implementing blocks such as the target block.
2022-07-07 01:44:13 +01:00
88a5a95479
Block: mark new functions as @internal
2022-07-06 17:26:15 +01:00
325f1cf82e
Generalize runtime block data serialization
...
we want to reuse this code for item type data
2022-07-05 14:13:37 +01:00
c7ba791ff8
Block: remove obsolete note from Block::isSameType()
2022-07-03 00:49:57 +01:00
b125d4d25f
Strip all remaining legacy item ID/meta stuff from blocks
...
the doors are now finally open, we can:
- make all the wood types dynamic
- fix glazed terracotta
- add all the new blocks
LET'S GOOOOOOOOOOOO
2022-07-02 17:48:11 +01:00