6621 Commits

Author SHA1 Message Date
Dylan K. Taylor
67a576722c Fixed item frames placed on invalid blocks, close #1804 2017-12-13 09:46:18 +00:00
Dylan K. Taylor
b9b50dd5dc Added Block->getDropsForCompatibleTool(), removed lots of boilerplate code from subclasses
The function name is a little long-winded, but that can always be refactored later if needed. This provides a way for blocks requiring specific tools to override drops with non-standard stuff without needing to worry about what tool type was used.

It's also possible that passing the Item used here is actually entirely redundant, but again that can be fixed later.
2017-12-12 20:02:50 +00:00
Dylan K. Taylor
da3640357c Rename Block->canBeBrokenWith() to isCompatibleWithTool() and add documentation
This name better describes it. "can be broken with" implies that items which this returns false for cannot destroy the block at all, which is incorrect. What this actually returns is whether the item is the best tool to use to break the block.
2017-12-12 19:51:31 +00:00
Dylan K. Taylor
0004e7429f Added some documentation on harvest level properties 2017-12-12 16:55:00 +00:00
Dylan K. Taylor
e2e6b7516a Removed WoodenTool classes
These were only needed for their fuel properties, which are the same for all tools of the wooden tier anyway.
2017-12-12 13:55:38 +00:00
Dylan K. Taylor
b903161a5d Refactored tool efficiency handling
This fixes lots of bugs with things like wool, cobwebs, swords.
2017-12-12 13:55:36 +00:00
Dylan K. Taylor
99fe63b2a3 Added harvest level properties to applicable blocks
this fixes block-breaking animations with wrong tools, and also finally resolves the long-standing hierarchy problem in Stair.
2017-12-12 13:54:17 +00:00
Dylan K. Taylor
dbc180315e Declare tool harvest level as a property 2017-12-12 13:54:16 +00:00
Dylan K. Taylor
45983acc0d Fixed too-fast break times with wrong tool types 2017-12-12 13:54:16 +00:00
Dylan K. Taylor
a02af1053f Remove redundant overrides from WoodenTools 2017-12-12 13:54:16 +00:00
Dylan K. Taylor
7de88b9040 Tool tier efficiency should still apply if the block can't be harvested
If you use an iron pickaxe on obsidian, it still mines faster because the tool types are compatible, even though the tool is not high enough.
2017-12-12 13:54:06 +00:00
Dylan K. Taylor
58327d0514 Change block tool types to bitflags
This allows specification of multiple tool types for a block, such as cobwebs.
2017-12-12 13:51:33 +00:00
Dylan K. Taylor
db31d13f96 Added Item->getBlockToolType() 2017-12-12 13:45:52 +00:00
Dylan K. Taylor
55d0684565 Move block-breaking tool-type constants to a BlockToolType interface 2017-12-12 13:45:52 +00:00
Dylan K. Taylor
7e3cd24444 Added TieredTool->getTier() 2017-12-12 13:45:51 +00:00
Dylan K. Taylor
2088a43c56 Refactored tool hierarchy 2017-12-12 13:45:51 +00:00
Dylan K. Taylor
3beccc47cd SlotChangeAction: Remove superfluous >= 0 inventorySlot check
This is done by slotExists() anyway.
2017-12-12 10:36:53 +00:00
Dylan K. Taylor
dfc2d1dfe6 Stop hardcoding src/pocketmine/resources everywhere 2017-12-11 19:52:49 +00:00
Dylan K. Taylor
1f1531810d Added \pocketmine\RESOURCE_PATH and Server->getResourcePath() 2017-12-11 19:52:20 +00:00
Dylan K. Taylor
98cb7f2e10 Removed redundant filePath from Server constructor
This parameter is hardcoded to \pocketmine\PATH in PocketMine.php. Additionally, it does not make sense for the server source path to not be the server source path. \pocketmine\PATH is accessible from the Server context, therefore it should be used and does not need to be stored.
2017-12-11 19:25:06 +00:00
Dylan K. Taylor
e58db75396 Level: Remove redundant null checks from useBreakOn()
These checks are not needed as of 3eae7a187524233f35deae028b01cf58ccd48157.
2017-12-11 16:31:43 +00:00
Dylan K. Taylor
a94c669730 Fixed sword efficiency on anything that's not cobwebs 2017-12-11 12:57:18 +00:00
Dylan K. Taylor
45ee115b67 Player: Fixed bad effects killing creative players
Players aren't supposed to take magic damage in creative... I don't know who added this, but it's wrong.
2017-12-10 20:50:50 +00:00
Dylan K. Taylor
44e06f6a32 Player: Stop abusing getItemInHand() when we already have it stored 2017-12-10 17:08:56 +00:00
Dylan K. Taylor
7c8a29151c MemoryManager: Remove unused field (leftover from 59d9d6a7df92a986ef5896dc0f2afbbe4606114f) 2017-12-10 12:12:43 +00:00
Dylan K. Taylor
8a90d159fe Cleanup unused imports 2017-12-10 12:09:46 +00:00
Dylan K. Taylor
bf4076766e Living: Fixed passing FloatTag to setHealth() when HealF tag is present, close #1784 2017-12-09 20:31:14 +00:00
Dylan K. Taylor
49dbd8b2c8 Living: Remove superfluous fire resistance check from dealFireDamage()
This is already checked in Living->attack(). It's preferable to allow it to be cancelled there since plugins can then un-cancel EntityDamageEvent to bypass the effect.
2017-12-07 17:32:50 +00:00
Dylan K. Taylor
502dd14c67 Entity: Remove excess whitespace in doOnFireTick() 2017-12-07 17:28:37 +00:00
Dylan K. Taylor
74239eec69 Living: Remove nonsensical >0 condition on boolean
Maybe this once returned integers, but it doesn't anymore.
2017-12-07 16:49:16 +00:00
Dylan K. Taylor
3c936e1be8 Entity: removed dead maxFireTicks property 2017-12-07 16:37:32 +00:00
Dylan K. Taylor
16fd37a039 Entity: Add getter & setter for fireTicks 2017-12-07 16:37:01 +00:00
Dylan K. Taylor
d80f711d18 CommandReader: Removed redundant else branch 2017-12-07 13:50:24 +00:00
Dylan K. Taylor
ebd3d207e4 Fixed server not accepting commands after pressing ctrl+D (non-readline) 2017-12-07 13:42:34 +00:00
Dylan K. Taylor
31f0437c96 fix readline crash when user presses ctrl+D 2017-12-07 13:41:58 +00:00
Dylan K. Taylor
b06ca6eb0b Rename Living->callDeathEvent() to Living->onDeath() 2017-12-07 12:26:49 +00:00
Dylan K. Taylor
67a09a9b16 Bump versions for 1.2.6
No changes. Mojang sucks.
2017-12-06 18:12:45 +00:00
Dylan K. Taylor
51cec525ee Added methods for calculating sun angle and sky light level reduction by day time
Use real sky light level in Level->getFullLightAt()

close #1471
2017-12-06 12:40:52 +00:00
Dylan K. Taylor
a5f4dda918 Added documentation for Level->addChunkPacket()
this method is confusingly named
2017-12-06 11:15:17 +00:00
Dylan K. Taylor
e2d66ac96d Use Player->isBanned() instead of repeating code 2017-12-06 10:38:02 +00:00
Dylan K. Taylor
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
Dylan K. Taylor
990a48d858 Better error message when a level is unloaded during its level tick
Plugins may cause this issue unexpectedly by unloading levels directly during events such as EntityDamageEvent. This adds a better error message to allow developers to understand what is going on and create appropriate workarounds.
2017-12-04 10:01:55 +00:00
Dylan K. Taylor
af68125872 Make Level->getName() less volatile
this resolves problems with crashes when getName() is called on an unloaded level. This obviously doesn't solve the root cause of the issue (level being accessed after unload) but since many things use the level name without checking if it's unloaded first, it's a bad idea for it to be volatile.

This resolves the server crash issue noted in #1527, where an exception is raised due to level unload during a tick, which subsequently causes a crash when trying to log the exception.
2017-12-04 09:57:53 +00:00
Dylan K. Taylor
5a0afa9f88
Fixed broken logic in EntityEffectEvents, close #1767 (#1768) 2017-12-03 16:14:20 +00:00
Dylan K. Taylor
c301788864 API bump 2017-12-02 17:22:05 +00:00
Dylan K. Taylor
472bf1a1ef Kill off the JSON garbage in commands
kill it with fire!
2017-12-02 16:33:19 +00:00
Dylan K. Taylor
1a4b653d07 Color: Fixed a confusing inconsistency in documentation 2017-12-02 16:17:27 +00:00
Dylan K. Taylor
d9f0546cb3 Added Color::mix() 2017-12-02 16:17:12 +00:00
Muqsit
92a1f45175 Make Living::addEffect() return bool (#1755) 2017-12-01 16:56:37 +00:00
Dylan K. Taylor
0afe20c382 Remove redundant overridden meta property from Air 2017-11-30 11:10:07 +00:00