847 Commits

Author SHA1 Message Date
Dylan K. Taylor
50592dc269
Merge branch 'stable' into minor-next 2023-11-09 18:05:38 +00:00
ace
c1ed182112
Fix loading of sign text from vanilla world (#6122) 2023-11-09 14:22:37 +00:00
Dylan K. Taylor
d09af2e30d
World: don't assume that random Vector3 are int vectors
we can safely assume this for blocks (though the type info doesn't reflect it) but this is not safe to assume for random APIs that might be used by plugins.
2023-11-06 17:15:17 +00:00
Dylan K. Taylor
bbe66e8e09
Block: Improve performance of encodeFullState()
if there's no state data to encode, we can avoid useless calls and object allocations.
For the best cases (blocks which don't use state data at all) this improves the performance of getStateId() by more than 10x.
Blocks which use one or the other benefit by a smaller but still significant margin.
2023-11-06 17:04:39 +00:00
Dylan K. Taylor
457660235e
Crops must have access to a light level of at least 9 2023-11-06 16:02:57 +00:00
ipad54
9fc9609694
Fix ancient debris not being fireproof (#6138) 2023-11-06 15:01:43 +00:00
ipad54
3385087c56
Fix Iron & Gold ores not affected by fortune (#6134) 2023-11-04 10:57:53 +00:00
Dylan K. Taylor
a6b36d6c3c
CropGrowthHelper: avoid unnecessary checks 2023-11-02 15:32:22 +00:00
Dylan K. Taylor
109673382d
Implemented modifiers for crop growth speed
closes #6070

there are some unresolved questions about the growth speed of beetroots, pitcher plants and torchflower crops, but that's a topic for another commit.
this change also doesn't account for the light levels.
2023-11-02 15:16:11 +00:00
Dylan K. Taylor
1e4a1565bb
Stem: fixed not attaching to grown pumpkin/melon
no idea how this got missed ...
2023-11-02 14:48:45 +00:00
Dylan K. Taylor
8aaa6dd176
Stem: do not disable ticking when the stem is not attached to a pumpkin
fixes #6131
2023-11-02 14:47:55 +00:00
Dylan K. Taylor
8491d3c6c0
Merge branch 'stable' into minor-next 2023-10-24 11:56:51 +01:00
Dylan K. Taylor
d637370b83
Wipe internal block AABB cache only for specific blocks that need it
the vast majority of blocks don't need this cache erasing, so it's costing performance for no good reason.
2023-10-23 17:38:04 +01:00
Dylan K. Taylor
8e17aed4f4
Fix build 2023-10-20 17:43:04 +01:00
Dylan K. Taylor
1f461977d4
Block: Avoid useless Vector3 allocations in getHorizontalSides and getAllSides 2023-10-20 17:28:19 +01:00
Dylan K. Taylor
eb935ca80f
ÂLeaves: use a constant for max distance from wood 2023-10-20 11:20:30 +01:00
Dylan K. Taylor
dbb5a32a96
Liquid: eliminate unnecessary Position allocations and getSide() calls 2023-10-19 17:09:13 +01:00
Dylan K. Taylor
9474324f75
Liquid: simplify code 2023-10-19 17:02:40 +01:00
Dylan K. Taylor
ada37899aa
Liquid: improve code legibility and fix a bunch of PHPStan errors 2023-10-19 17:02:22 +01:00
Dylan K. Taylor
f868c1d8c6
Liquid: Update legacy code with Facing::OFFSET 2023-10-19 16:38:34 +01:00
Dylan K. Taylor
19a1792184
Fixed behavioural change on invalid Facing introduced by previous commit
while this shouldn't be given invalid facings anyway, Vector3::getSide() accepts them and just returns itself.
2023-10-19 13:27:44 +01:00
Dylan K. Taylor
6a3ec70c72
ÂBlock: use Facing::OFFSET in getSide()
instead of the comically inefficient getBlock() + throwaway Position->getSide()
This improved the function's performance by 2.3x.
2023-10-19 13:25:32 +01:00
Javier León
b4d55e4384
Fixed dirt and grass block interactions when clicking on sides other than the top (#6071) 2023-10-18 10:40:01 +01:00
Hugo_
7b5c30bc2c
WoodenDoor can be a fuel (#6101) 2023-10-17 22:10:08 +01:00
Hugo_
c14eb63f9b
Wooden Button can be a fuel (#6099) 2023-10-17 16:30:35 +01:00
Dylan T
48dcf0e32c
Farmland: Remember relative location of nearby water in blockstate data (#6090)
Farmland can end up scanning up to 162 blocks looking for water in the worst case. This is obviously not great for huge farms where there are thousands of blocks of the stuff.

In most farms, the water won't be moved, and nor will the farmland. This means that we can avoid this costly search on random updates.

This PR implements a cache using blockstate data (only possible in PM5) which stores an index mapping to a coordinate offset where water was previously found by this farmland block. This allows the farmland to avoid water searching entirely in most cases.

This is a colossal improvement as compared to scanning the whole 9x2x9 area every time, which, on average, scans about 40 blocks to find water if the water is at the same Y coordinate. In real terms this translates into about a 8x performance improvement for farmland (see timings below).
2023-10-17 16:25:13 +01:00
Dylan K. Taylor
7f3de835e4
Block: private internal function 2023-10-17 15:23:39 +01:00
Dylan K. Taylor
63fcf9879a
Block: Use xxhash'd XOR mask to improve state data lower bits distribution
xxhash is generally well known for its hash key properties, so this is a suitable use case.
We XOR the state data with a partial hash of xxh3(typeID), which provides sufficient hash distribution regardless of the size of state data.
The previous method started to break down as the number of bits exceeded the number of significant bits of type ID (about 10 currently).

As well as being better for hash distribution regardless of state data size, this also reduces the load factor of RuntimeBlockRegistry to 1.08 (previously around 1.24), which is a nice bonus.
2023-10-17 15:21:22 +01:00
Hugo_
224a69b11a
Sign can be a fuel (#6095) 2023-10-17 12:22:20 +01:00
Dylan K. Taylor
d0d16cdeb7
RuntimeDataDescriber: Introduce boundedIntAuto, replacing boundedInt
closes #6096
boundedIntAuto automatically calculates the correct number of bits to use based on the given bounds. The bounds must be constant, of course.
2023-10-17 12:03:43 +01:00
Dylan K. Taylor
18b711aca8
Apparently this function is no longer needed 2023-10-17 11:34:02 +01:00
Dylan K. Taylor
b0936a50c1
Block: split generateStatePermutations into type and state parts
this makes it marginally faster, since we can skip all permutations containing invalid type data.
I measured a performance improvement of about 20% across all blocks.
In addition, this makes it easier to locate where a problem is coming from if invalid inputs are accepted.
2023-10-17 11:28:58 +01:00
ace
82d6fc3890
Fix loading of Chiseled Bookshelf tile from vanilla world (#6084)
Co-authored-by: Dylan T <dktapps@pmmp.io>
2023-10-17 11:10:36 +01:00
Dylan K. Taylor
3c614b505d
Merge branch 'stable' into minor-next 2023-10-16 21:28:59 +01:00
Dylan K. Taylor
7d200247f8
Cactus: do not update if only age changed
I'd prefer a smarter solution for this that automatically disables updates depending on which type of property was changed, but for now, this will significantly improve the performance of cactus farms.
The newly placed cactus block at the top cannot have updates disabled, though, since it needs to check its surroundings in case it grew into a space with a solid block next to it.

Thanks @KingOfTurkey38 for bringing this to light.
2023-10-13 12:45:11 +01:00
ace
8b52a5cd9e
Fix book placed in wrong slot in Chiseled Bookshelf (#6085) 2023-10-10 12:35:50 +01:00
ace
c9163a1505
ChiseledBookshelf: Fix duplication bug (#6086)
Also fixes being able to put more than 1 book in the slot
2023-10-10 10:59:39 +01:00
Dylan K. Taylor
55cc5a6651
NetherVines: optimize condition order 2023-09-29 12:45:55 +01:00
Dylan K. Taylor
390cc3060a
Disable random ticking for some blocks depending on their states
we don't need to waste CPU time attempting to tick fully grown crops.
2023-09-29 12:45:37 +01:00
Dylan K. Taylor
ca69f08da0
ChorusFlower: move ticksRandomly() to a more appropriate place 2023-09-29 12:44:27 +01:00
Dylan K. Taylor
eac0564792
Fix CS 2023-09-29 12:31:11 +01:00
Dylan K. Taylor
628d77f8d7
Implemented pitcher plants, crops and pods 2023-09-29 12:30:52 +01:00
Dylan K. Taylor
fe543a4789
AgeableTrait: fixed incorrect number of bits
the original method breaks if MAX_AGE is 0 or any power of 2.
2023-09-29 12:05:39 +01:00
Dylan K. Taylor
31cd096b4b
Implement torchflower, its seeds and its crop 2023-09-28 17:13:33 +01:00
Dylan K. Taylor
4b9d170954
RuntimeDataDescriber: added dynamic method for reading and writing enum sets
this was previously only needed for brewing stands, but it's now become needed for chiselled bookshelves too.
2023-09-28 16:06:17 +01:00
HimmelKreis4865
d94391af57
Implement Chiseled Bookshelf (#5827) 2023-09-28 15:56:46 +01:00
Dylan K. Taylor
a6b030f2b3
Fix CSÂ 2023-09-27 17:07:02 +01:00
Dylan K. Taylor
56d7039086
Implemented budding amethyst and amethyst clusters 2023-09-27 17:02:37 +01:00
Dylan K. Taylor
6ec340359b
Implemented crimson and warped roots 2023-09-27 13:07:46 +01:00
Dylan K. Taylor
e9169cfa67
ChorusPlant: change stupid code 2023-09-08 17:34:47 +01:00