Commit Graph

92 Commits

Author SHA1 Message Date
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
323c563684 Break Block's dependence on ItemFactory, and item legacy IDs
let's GOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
2022-07-02 17:29:28 +01:00
3792ef5a50 Move blockstate data runtime serialization to a more appropriate package 2022-07-02 16:48:41 +01:00
2a0b500010 Block: Separate encoding of type and state data
the terminology of this needs improvement, but...

the basic concept here is that 'type' data will persist on an itemstack, while 'state' data will not.

Type data consists of things like:
- Colour
- Coral type
- Wet/dry (sponges)
- Live/dead (coral)
- Wood type

State data consists of things like:
- Facing
- Axis
- Powered/unpowered
- Open/closed

In the past, with the old system, this information was separated by way of getStateBitmask(). This solution was fraught with problems, but achieved the basic goal: removing unwanted block properties from items.
2022-06-30 18:08:34 +01:00
dd63681f94 Assign auto-generated runtime type IDs to all items 2022-06-29 13:50:58 +01:00
7deee31502 Block: make decodeStateData() and computeStateData() final 2022-06-27 15:40:39 +01:00
0afb67be7d Improve BlockFactory initialization performance
as expected, expanding data range unconditionally resulted in some performance issues ...
2022-06-27 15:37:05 +01:00
1da4c45979 Add runtime support for wall connections
this doesn't match the 1.16+ behaviour yet, but it at least recognizes walls that are already in the post-1.16 way and doesn't break them if not interacted with.
2022-06-25 15:59:38 +01:00
f24f2d9ca9 Hit block legacy metadata with the biggest nuke you've ever seen
This commit completely revamps the way that blocks are represented in memory at runtime.

Instead of being represented by legacy Mojang block IDs and metadata, which are dated, limited and unchangeable, we now use custom PM block IDs, which are generated from VanillaBlocks.
This means we have full control of how they are assigned, which opens the doors to finally addressing inconsistencies like glazed terracotta, stripped logs handling, etc.

To represent state, BlockDataReader and BlockDataWriter have been introduced, and are used by blocks with state information to pack said information into a binary form that can be stored on a chunk at runtime.
Conceptually it's pretty similar to legacy metadata, but the actual format shares no resemblance whatsoever to legacy metadata, and is fully controlled by PM.
This means that the 'state data' may change in serialization format at any time, so it should **NOT** be stored on disk or in a config.

In the future, this will be improved using more auto-generated code and attributes, instead of hand-baked decodeState() and encodeState(). For now, this opens the gateway to a significant expansion of features.
It's not ideal, but it's a big step forwards.
2022-06-24 23:19:37 +01:00
1ff69136a3 Merge branch 'next-major' into modern-world-support 2022-06-07 20:01:40 +01:00
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
bd8dd48dee Assign new IDs to every block 2022-05-27 18:07:31 +01:00
6482aa7c64 Block: introduce logic for face support types (#4886)
fixes #4856
fixes #458
fixes #4529
fixes #3299

Added API method Block::getSupportType(Facing) : SupportType
Added SupportType enum
fixes torch, lantern, door etc. placement on slabs and upside-down stairs
2022-05-20 15:18:34 +01:00
09778e3f1b Fixed build failure 2022-04-25 12:56:16 +01:00
79d1feff9c Replace disallowed operators in src/block/ 2022-01-20 16:57:09 +00:00
0bc578b8fc Block: added getTypeId() 2022-01-07 21:03:19 +00:00
e34364412b Replace InvalidStateException usages with InvalidArgument or LogicException 2021-11-02 16:05:54 +00:00
fd2df637b6 Block: rename getPositionOffset() -> getModelPositionOffset()
this gives a better idea of what the function does, and is also much less annoying for auto complete.
2021-10-10 22:35:38 +01:00
8e3772ceef Block: fixed incorrect behaviour of isSameState() for multi-ID blocks
fixes #4492
2021-10-06 23:16:03 +01:00
4111d92b98 Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
ded778f422 Implemented bed bouncing 2021-09-05 20:11:49 +01:00