Commit Graph

60 Commits

Author SHA1 Message Date
6c0254c1eb Block: document parameters of place() 2023-01-16 19:49:24 +00:00
99996b62d6 Align PhpDoc @param tags according to PHP-CS-Fixer 2022-12-06 13:21:20 +00: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
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
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +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
7fd712c1ff Refactor Block & Tile: getPos() to getPosition() (#4395)
this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
2021-08-23 14:01:32 +01:00
bdac98beaf Block: get rid of getNonPersistentStateBitmask(), add writeStateToItemMeta()
this is more flexible and less confusing.
2021-08-02 19:17:24 +01:00
7a35fdb1bb Allow Blocks to specify their max stack size 2021-06-30 19:28:16 +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
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
f68b9e79e1 Use typed properties in block namespace 2021-05-22 23:52:31 +01:00
6ccfe21d57 Block: improved accuracy of isFullCube() 2021-02-04 23:10:13 +00:00
5cc2a9c3dd World: rename getChunkAtPosition() to getOrLoadChunkAtPosition()
this more accurately reflects what it does.
2020-11-03 14:12:47 +00:00
a01c086481 Introduced VanillaEnchantments registry 2020-10-23 20:48:19 +01:00
388a19ef5d Persistent block metadata may now have mutable parts
Not allowing this makes stuff like anvil damage, colour, wood type, live/dead bit, wet/dry etc all too much hassle to deal with.
Naturally I want to get rid of this shit altogether, but first it's necessary to construct a new system that we can shift into before all this bullshit can be addressed fully, so for now we have to work within the bounds of the old system.
This change will permit dynamic colours for concrete/concrete powder etc, dynamic wood types where the wood type isn't embedded in the legacy ID, and so forth. Allowing full flexibility requires either more old system hacks or completing the migration to a new system which doesn't have these limitations. I prefer to do the latter, but this change will make it somewhat easier to do.
2020-10-04 11:40:05 +01:00
8e12693494 Entity: Invalid blocksAround cache when something happens during onEntityInside()
this fixes TNT spawning multiple entities when lit by flaming arrows.
The problem here is a bit more complex (entities aren't immediately notified when local block updates happen, so they cache stuff that becomes unusable). The simplest option would be to just lose the cache, but that would have some impacts on performance.
Barring a rethink of the block updating mechanism, this solution seems usable for now.
2020-09-25 16:35:59 +01:00
c7070788f9 Rename and repurpose Block->diffusesSkyLight to blocksDirectSkyLight
this new form allows skipping some useless checks during sky light calculation and also allows getting rid of the last hard dependency on core Block classes.
We're getting real close to native light now.
2020-09-08 22:40:05 +01:00
bf401421fa Implemented bamboo (#3762) 2020-08-16 20:39:51 +01:00
2b044195a5 Update for pocketmine/math Axis refactor 2020-08-06 14:38:54 +01:00
909f3f39de Block: get rid of getRuntimeId()
the runtime ID mapping should be non-global in case of multiple protocols.
2020-07-06 11:18:29 +01:00
2cd67aed72 Block: fixed crash on block factory clone 2020-06-29 22:40:35 +01:00
da3f0752a6 Block: make getAllSides() and getHorizontalSides() use underlying Vector3 generators 2020-06-29 22:13:07 +01:00
670ad9eb9d Position: rename getWorldNonNull() to getWorld(), remove original getWorld() 2020-06-29 21:19:46 +01:00
fc22fd80d8 Eradicate remaining usages of Position->getWorld() 2020-06-29 21:03:55 +01:00
43ae1a5cb4 Block: make getAllSides() and getHorizontalSides() return generators 2020-06-29 20:54:51 +01:00
01d221b794 imports cleanup 2020-06-28 17:50:49 +01:00
f1048aeaa3 Block: rework addVelocityToEntity() to avoid vector3 mutation 2020-06-27 21:38:24 +01:00
1ef6e5e17b TileFactory now only manages loading tiles from NBT, not direct creation
my objective is to make this use proper constructors like entities, but there's a couple of obstacles to get around first.
2020-06-21 00:47:02 +01:00
8e2b9b686b Block: Invert default behaviour of silk touch (more logical)
Now, blocks do not respond to silk touch unless specifically opted into. Since this always involves custom drops in one way or another, it's easy enough to figure out which blocks need to be marked for silk touch - anything that overrides getDrops, getDropsForCompatibleTool or getSilkTouchDrops is a block which _might_ need to be flagged. Using these criteria to reduce the number of blocks needing to be checked, I was able to manually invert the behaviour as needed.

This fixes reoccurring bugs with blocks erroneously dropping themselves whenever new blocks are added and someone forgot to set that flag, granting players access to internal blocks with strange behaviour.
2020-05-21 13:02:36 +01:00
3f1f135a59 remove a couple more Position->getWorld() usages 2020-05-19 21:38:51 +01:00
8a8b1b0b97 Remove Position->setWorld() 2020-05-19 18:33:16 +01:00
6b037d6a4c RuntimeBlockMapping: these IDs are not static any more 2020-05-11 12:40:55 +01:00
ac5cf2443e convert TileFactory to singleton 2020-04-26 01:11:30 +01:00
287bf4274f move RuntimeBlockMapping to convert package 2020-04-24 12:42:43 +01:00
5a94af40e2 Convert ItemFactory to singleton 2020-04-24 00:18:31 +01:00
aa1828aa98 RuntimeBlockMapping is now a singleton instead of static class
this prepares for a fully dynamic block mapper, as well as allowing a small performance improvement to chunk encoding by eliding the constant lazy-init checks.
2020-04-23 21:09:58 +01:00