Commit Graph

46 Commits

Author SHA1 Message Date
c0962a47be Block: Use parent::place() instead of setBlock() directly 2018-09-13 12:54:03 +01:00
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
5f48433c95 Bucket: Added sounds for bucket fill/empty 2018-01-03 14:27:41 +00:00
33352638a9 Bucket: Fixed appearing empty when picking up still liquids
Buckets already affected by this bug will still appear empty until used. After that they'll work fine.
2018-01-03 14:22:53 +00:00
d03fdd5f72 Liquids refactor, bug fixes and performance improvements (#1753)
* Added Liquid->getLiquidLevelDecreasePerBlock()

* Fixed lava turning into cobblestone when flowing over water

* Cache liquid flow vectors for faster entity movement

* Removed a condition that made lava impossible to get rid of
In the PC code, the equivalent code makes the delay between scheduled ticks 4 times longer. Here, it just breaks the code. I don't know what the 4x stuff is about, but this code does not produce the expected behaviour and lava works fine regardless.

* Fixed strange behaviour with liquids trying to flow into other liquids
Liquids should consider other liquids as a path of least resistance. However, they should not actually flow into them. This fixes a variety of CPU leak issues with falling water in large water bodies such as oceans.
This also fixes the plus-shape effect that liquid is supposed to produce when a source is placed above ground.

* Removed a bad optimization making liquids flowing down slopes behave undesirably

* Optimize performance of slope searching by limiting recursion depth based on previous path lengths
If we already found a step down on a previous run after 2 blocks, it doesn't make sense to continue allowing checking 4 blocks because the results will just be ignored. This allows limiting the number of recursion steps, which significantly improves the performance when flowing down slopes.
However, this will still be just as bad for performance on flat terrain as it was to start with.

* Make some Liquid methods only accept Blocks as parameters
these are only ever passed blocks anyway, doesn't make sense to allow vectors.

* Moved some things to local variables
these are each only used in one function, so it doesn't make sense for them to be class members.

* Fixed water flow down slopes going everywhere, but degraded performance again

* Lava should only search 2 blocks for a slope

* Stop wasting CPU calculating optimal flow directions for liquids with too-high decay
It calculates the flow directions and THEN doesn't use them when it
realizes the flow decay is too high. This is completely pointless.

* Use a less hacky method to handle lava flowing into water

* Doubled flow performance on flat terrain
Since calculateFlowCost() usually ends up visiting the same blocks about 6 times when on flat terrain, it makes sense to cache some stuff for when blocks get revisited so expensive dumb checks don't need to keep on being done. On my machine this produces a 50-60% performance improvement when flowing on flat terrain.

* Fixed missing return values in Liquid->onUpdate()
these return values aren't used anywhere, but we should be consistent

* Don't allow flowing back in the same direction we just came from
This reduces the recursions by about 30%, providing about the same percentage performance improvement.

* Remove Liquid's temporalVector (it's not used anymore)
primitive types for the win!

* Move liquid collide to its own method

* add sound for lava/water mix
2017-12-04 10:09:35 +00:00
d1db27016e s/facePos/clickVector/
clickVector better describes this
2017-10-27 19:05:26 +01:00
d8b1757ebc added some nullable and void typehints to Block API 2017-10-11 18:45:40 +01:00
6d5620606e Block->place() parameter refactor to make things clearer 2017-08-26 14:41:49 +01:00
456ddd3fb3 Removed obsolete parameters from Entity->attack() and Entity->heal() 2017-08-21 13:25:11 +01:00
e1d894057c Changed face position floating-point params to Vector3s 2017-08-20 10:23:34 +01:00
83af4dcd59 Block API typehints 2017-08-17 13:50:19 +01:00
6b5c0af161 Separation of effect handling from Entity, fixes #886 2017-08-07 16:03:54 +01:00
561d8e7a39 Regenerated block/item id lists and refactored some names for consistency with MCPE 2017-08-04 12:17:24 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
f3ab45e7d5 Merged in 1.0.6 changes, added autogenerated data for 1.1.0.3 (doesn't work yet) and deliberately made the same merge error as Mojang 2017-04-14 13:00:43 +01:00
9004417456 Fixed file headers (#255) 2017-01-13 16:57:05 +00:00
26c9eed82e Added all block hardness 2015-07-27 20:31:55 +02:00
d66a2d7105 Merge branch 'master' into mcpe-0.11 2015-03-19 09:18:39 +01:00
d34499e67b Revert "Implemented proportional armor modifier, applied armor in other damage types and consume armor when player is damaged" 2015-03-18 17:26:06 +01:00
8169803bb4 Updated Water/Lava to use new methods 2015-03-17 21:22:51 +01:00
5a35e7b058 Removed damage reduction by armor for lava 2015-03-17 21:10:54 +01:00
1b25cd6ffa Merge branch 'master' into mcpe-0.11 2015-03-17 19:12:03 +01:00
8aa8ae5094 Implemented proportional armor modifier, applied armor in other damage types and consume armor when player is damaged 2015-03-17 20:04:59 +08:00
4383e272eb Added Effects base, /effect and methods 2015-03-15 23:15:54 +01:00
747f7685e7 Fix formatting issues due to bad IDE settings 2014-12-07 16:30:04 +01:00
a0d4bff385 Block creating and property handling rewrite, part1 2014-12-07 01:53:27 +01:00
b3c3f896a3 Implemented light population, added Level->getFullLight() 2014-11-28 14:44:27 +01:00
8601405a88 Fixed CPU leak 2014-10-31 21:07:00 +01:00
8a768cea33 EntityDamageEvent and children now only fire if the attack is possible, moved event trigger to Entity->attack() 2014-10-29 16:02:40 +01:00
350cee3d41 Added Event allocation pool, updated SPL with Class::onClassLoaded() 2014-10-28 10:47:40 +01:00
4299ebebcc Bump API version to 1.6.1 2014-10-28 00:55:07 +01:00
1eec333501 Save block bounding boxes, improves block cache 2014-10-13 18:38:00 +02:00
0af3dfedd5 Improved Living entity ticking 2014-10-11 17:35:13 +02:00
62af784d37 Removed unused imports 2014-10-08 17:00:23 +02:00
4346773e25 Added EntityDamageByBlockEvent (child of EntityDamageEvent) 2014-10-08 16:13:18 +02:00
b0c314526d Added EntityCombustEvent and childs 2014-10-08 15:51:27 +02:00
5e03e157ad Fixed #2153 2014-10-04 23:16:35 +02:00
b0bd927545 Improved entity base ticks 2014-09-29 12:55:10 +02:00
48bc919a33 Added Liquid flow 2014-09-26 16:56:10 +02:00
ae6f532b1d Partial Liquid flow 2014-09-26 13:25:52 +02:00
e9a2f88847 Added Fire, Lava damage 2014-09-16 10:42:29 +02:00
ac4b4b08fd Fixed Level::setBlock() old calls 2014-09-05 11:00:13 +02:00
c47e359262 Updated blocks bounding boxes 2014-08-24 16:30:56 +02:00
ed90d58e32 Fixed crash when placing water or lava 2014-07-28 12:18:17 +02:00
c1546aac9c Updated Position to use Weak / strong references for Level objects 2014-05-22 04:14:06 +02:00
dd17652aca Fixed wrong paths 2014-04-01 05:06:12 +02:00