66 Commits

Author SHA1 Message Date
Dylan K. Taylor
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
max
f3b2bcfd13 Added Conduit Power effect 2018-08-06 21:30:15 +01:00
Dylan K. Taylor
2d3ce9e8b0 Remove some fully qualified function calls
PhpStorm can't see these or understand how they are being called, which is very annoying for bug hunting. Additionally, we already have the CodeOptimizer for this.
2018-06-18 12:23:19 +01:00
Dylan K. Taylor
74cff89df3 Instant Damage splash potions now deal knockback 2018-03-09 12:52:09 +00:00
Dylan K. Taylor
2e9bf7e93b Implemented Splash Potions 2018-03-09 12:25:02 +00:00
Dylan K. Taylor
dc3bf8546e Refactored effects handling, split up concerns of effect types and instances
Removed json insanity for effects

Split up effect types and effect instances

Saturation is an instant effect
2018-03-07 12:42:31 +00:00
Muqsit
beb5bf6dda Add API methods: Entity::isInvisible(), Entity::setInvisible() (#1930)
* Make use of the API function in Effect class
2018-01-17 09:56:59 +00:00
Dylan K. Taylor
547833ae23 Effect: Add constants with vanilla names where missing 2017-12-23 14:48:56 +00:00
Dylan K. Taylor
329fe7d844 Effect: Implement Saturation effect
I thought I did this months ago, but apparently not. Whatever, it's here now.
2017-12-23 11:35:01 +00:00
Dylan K. Taylor
b7aaf54a6f Effect: Fixed mistake in bitshifting with effect level in instant effects
This should be the amplifier, otherwise the effect will have double-effect on level 1.
2017-12-23 11:32:58 +00:00
Dylan K. Taylor
6332814a04 Effect: Minor cleanup on Instant Health/Damage effect amplification 2017-12-23 11:23:29 +00:00
Dylan K. Taylor
9d4818d360 Effect: Hunger is supposed to apply every tick
This fixes oddities in the behaviour noticeable with higher effect levels.
2017-12-23 11:15:23 +00:00
Dylan K. Taylor
e75fbd7fb4
Changed Effect colours to use Color objects instead of arrays (#1814) 2017-12-14 10:21:07 +00:00
Dylan K. Taylor
4c7038f941 Effect: Added proper documentation on "ambiency" 2017-12-14 09:57:20 +00:00
Dylan K. Taylor
f5ebfc3418 Effect: Added Fatal Poison effect
This is identical to normal Poison, except that it kills the victim. Parrots receive this effect when they are fed cookies.
2017-12-13 18:59:49 +00:00
Dylan K. Taylor
dfc2d1dfe6 Stop hardcoding src/pocketmine/resources everywhere 2017-12-11 19:52:49 +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
74b074753f Bulk addition of constant visibilities
thanks PhpStorm inspections plugin for annoying the shit out of me until
I did this.
2017-11-21 14:44:10 +00:00
Dylan K. Taylor
21f09d5fdb Cleaned up Effect handling and replacement 2017-08-30 12:53:41 +01:00
Dylan K. Taylor
456ddd3fb3 Removed obsolete parameters from Entity->attack() and Entity->heal() 2017-08-21 13:25:11 +01:00
Dylan K. Taylor
e825ebd8fa Added some wrapper methods to make data flags less of a pain in the ass to work with 2017-08-17 16:52:17 +01:00
Dylan K. Taylor
6320a63ca5 Use standard format for color hex, some minor name alteration 2017-08-17 13:08:18 +01:00
Dylan K. Taylor
77376d3e33 No idea how this happened 2017-08-17 11:15:42 +01:00
Dylan K. Taylor
741394dab1 Typehinted up entity API
Did you guys think ALPHA7 changes were done?!
Sone stuff still needs some work, most notably data-properties can't be typed yet because they are just mushed into a couple of methods.
2017-08-16 19:04:30 +01:00
Dylan K. Taylor
313fdb9e87 Added INT32_MIN and INT32_MAX constants and an exception throw for out-of-range effect amplifiers 2017-06-14 19:38:39 +01:00
Dylan K. Taylor
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
Dylan K. Taylor
54453d0b0a Refactored entity IDs in packets for consistency and to clarify on types 2017-06-05 15:41:27 +01:00
Dylan K. Taylor
ad4659365a Use default amplifier 0 instead of implicit null
(how did nobody ever notice this?!)
2017-06-03 11:06:22 +01:00
smarticles101
8a7259aa73
Merge #826: use getEffectLevel() instead of getAmplifier() + 1
Closes #412
2017-05-05 19:01:04 +08:00
Dylan K. Taylor
1c2895eb12 Fixed absorption application logic, close #518 2017-04-05 21:16:40 +01:00
Dylan K. Taylor
9a35b4fbc8 Removed redundant TODO comment 2017-03-21 14:03:53 +00:00
Dylan K. Taylor
940b20c191 Implemented Absorption effect
This is a little buggy due to a client-sided bug. https://bugs.mojang.com/browse/MCPE-20520
TODO: add attribute save/restore
2017-03-21 13:23:57 +00:00
Dylan K. Taylor
c21768df26 Updated Effect constants, removed incorrect/misleading SWIFTNESS constant
So what? I'd rather crash plugins than have them suddenly behave strangely because SWIFTNESS is now an alias for SPEED instead of HASTE.
2017-03-21 11:49:18 +00:00
Dylan K. Taylor
2d927db264 Implemented Instant Health and Instant Damage effects 2017-03-21 11:38:08 +00:00
Dylan K. Taylor
78278a0b93 Fixed a mistake in old effect handling 2017-03-12 20:15:21 +00:00
Dylan K. Taylor
955dc38be4 Fixed botch-job implementation of Health Boost, will now actually work and not crash the server 2017-03-12 20:06:39 +00:00
Dylan K. Taylor
f58ee2028e Moved effects stuff to json 2017-03-12 19:52:57 +00:00
Dylan K. Taylor
6c5dbd7359 Merge branch 'master' into api3/network 2017-03-12 12:22:11 +00:00
Dylan K. Taylor
7fb3c7343f Fit attribute value to range when applying slowness, close #410
According to http://minecraft.gamepedia.com/Status_effect#Slowness, anything higher than slowness 7 will cause the player to be unable to move. Therefore this value should be clamped to a minimum of 0, not crash.
2017-03-09 21:01:10 +00:00
Dylan K. Taylor
56990eb28b MCPE protocol gets its own namespace 2017-03-08 20:28:39 +00:00
Dylan K. Taylor
1ee689e759 Fixed mess of entity ID 0 for players, fixed emeralds 2017-03-02 11:04:00 +00:00
Dylan K. Taylor
10c8632417 Fixed effect amplifier overflow crash, close #147 (#191) 2016-12-27 21:30:54 +00:00
JackNoordhuis
5d16ecc003 Entity Effect Events (#141)
Add EntityEffectEvent class that the EntityEffectAddEvent and
EntityEffectRemoveEvent classes extend. Add event calls to Effect class.
2016-12-06 11:59:49 +00:00
Dylan K. Taylor
ce72f634b0 Update some old code 2016-10-27 10:55:04 +01:00
PEMapModder
09ce8fab82 Fixed speed and slowness potions 2016-03-07 18:12:54 +08:00
PEMapModder
e79976bdac Added events 2016-02-11 22:07:04 +08:00
PEMapModder
52e8781d36 Implemented hunger-related regen and damage 2016-02-11 01:53:51 +08:00
PEMapModder
329a525ea1 Implemented food and hunger 2016-02-10 22:49:48 +08:00
Shoghi Cervantes
31ef7721b1 Removed network channels, bumped protocol 2015-08-12 14:59:48 +02:00
Shoghi Cervantes
3e2cce3c2c use cleanup 2015-08-07 21:26:24 +02:00