800 Commits

Author SHA1 Message Date
Dylan K. Taylor
4c9ca53b32 Merge branch 'release/3.0' into release/3.1 2018-06-22 17:47:33 +01:00
Dylan K. Taylor
484d34fe04 Living: Reset attack cooldown before applying post damage effects
this fixes things causing damage during post-damage calls coming back and being able to do even more damage
2018-06-22 17:47:11 +01:00
Dylan K. Taylor
a5a236084f Living: don't applyPostDamageEffects() for dead mobs
this has already been seen to cause duplication bugs when thorns is used. Anything else that modifies inventory during applyPostDamageEffects() when the mob is possibly dead will also cause duplication issues.
2018-06-22 14:31:48 +01:00
Dylan K. Taylor
390db976e5 Arrow: allow controlling pickup mode (like PC)
This allows controlling how arrows are picked up:
- by anything
- by only creative players
- by nothing

This adds new API methods to Arrow:
- getPickupMode()
- setPickupMode()

This adds new public constants to Arrow:
- PICKUP_NONE
- PICKUP_ANY
- PICKUP_CREATIVE
2018-06-22 13:40:32 +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
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
Dylan K. Taylor
f6481eab8f
Implemented an InventoryEventProcessor, fixes #1986 (#2176)
* Implemented InventoryEventProcessor, fixes #1986
Event processors can now be registered and unregistered at will. Entity inventory/armor change events are now handled by event processors instead of the inventories themselves, which allows enabling/disabling the calling of these events at will.
This now avoids stupid things happening when initializing inventory contents, since the callers for those events are now registered _after_ the contents are initialized.
2018-06-09 17:37:10 +01:00
Dylan K. Taylor
8e5aca70b4 Entity: Avoid using close() during initEntity()
this simply conceals bugs and will cause astonishing behaviour.
2018-06-09 17:06:15 +01:00
Dylan K. Taylor
85136b7b4a Entity: Attach to level & chunk after initEntity() call, not before
this avoids leaving garbage entities attached to chunks when exceptions are thrown during initEntity().
2018-06-09 16:59:22 +01:00
Dylan K. Taylor
37b445f210 Updated Math dependency 2018-06-09 13:05:25 +01:00
Dylan K. Taylor
fb484087a8 Entity: Remove unnecessary scheduleUpdate() call from initEntity()
this is already done by the constructor
2018-06-07 12:53:59 +01:00
Dylan K. Taylor
14914781fc Added exception throws when a closed tile or entity attempts to schedule itself for updating
I can't believe it took so long to find what was causing these stdClass bugs.
2018-06-07 12:37:26 +01:00
Dylan K. Taylor
fdd5b7b9c9 Entity: Fixed despawn flagging not kicking in until scheduling updates on entities 2018-06-07 12:34:23 +01:00
Dylan K. Taylor
c83c0eb935 Entity: Move responsibility of checking for despawn to Level
this ensures that flagging for despawn will always work as intended, including when onUpdate() is overridden.
2018-06-07 12:31:21 +01:00
Dylan K. Taylor
0d177d5219 Entity: Clear dirty properties at the end of the constructor
this prevents sending duplicate properties immediately after entity spawn (due to properties getting set in the constructor).
2018-06-04 11:18:42 +01:00
Dylan K. Taylor
0a50b8cb9b Removed imports left over from 4f8f334436c69336d1bc2811717983544eda41e8 2018-05-29 11:42:12 +01:00
Dylan K. Taylor
4f8f334436 Replaced usages of Math::floorFloat() with (int) floor() and Math::ceilFloat() with (int) ceil()
Once upon a time, these userland functions were faster than calling builtins, but not anymore. According to my test the Math functions are twice slower in PHP 7.2 with typehints and 50% slower without typehints.

Inlining is slightly faster than using builtins, but the difference is very small - not worth making the code look any more ugly than it does already.
2018-05-28 18:54:35 +01:00
Dylan K. Taylor
74c0863905 Living: fixed preventing effect expiry using events, closes #2208 2018-05-28 17:14:18 +01:00
Dylan K. Taylor
c18ba38b74 Entity: avoid astonishing behaviour with motion vector modifications 2018-05-26 10:40:04 +01:00
Dylan K. Taylor
02b53785be Entity: added some new ID constants 2018-05-24 12:39:44 +01:00
Dylan K. Taylor
9dd0ee7f05 Entity: replaced motion and lastMotion fields with vectors 2018-05-24 12:11:41 +01:00
Dylan K. Taylor
595f1f58da Living: added knockback resistance attribute checks 2018-05-24 11:49:18 +01:00
Dylan K. Taylor
fbf760bafe Enchantment: implemented Vanishing 2018-05-23 17:23:56 +01:00
Dylan K. Taylor
acf29711c2 Implemented Totems, close #2198
Totem usage can be detected using the MODIFIER_TOTEM constant of EntityDamageEvent.

This does not currently support using the totem in the offhand because offhand is not implemented yet.
2018-05-23 10:06:35 +01:00
Dylan K. Taylor
faa88a55e4 EntityDamageEvent: break API
The general purpose of this is to split up base damage from modifiers.

- Added methods getBaseDamage(), setBaseDamage(), getOriginalBaseDamage(), getModifiers(), getOriginalModifiers()
- setDamage() renamed to setModifier() and type is now mandatory
- getDamage() renamed to getModifier() and type is now mandatory
- getOriginalDamage() renamed to getOriginalModifier() and type is now mandatory
- Removed MODIFIER_BASE constant
- Constructors now accept: float baseDamage, float[] modifiers instead of just float[] modifiers
2018-05-22 19:05:25 +01:00
Dylan K. Taylor
adb9390b53 Entity: Rename isInsideOfWater() to isUnderwater() 2018-05-19 18:10:43 +01:00
Dylan K. Taylor
6111ce7df1 Human: don't hardcode max food 2018-05-19 16:48:21 +01:00
Dylan K. Taylor
1f73c08762 Human: fix possible bug with food ticking
it updates it but doesn't take note of the updated value, which could cause the code below to be erroneously triggered.
2018-05-19 16:47:04 +01:00
Dylan K. Taylor
2900167ffa Human: removed redundant isSprinting() check from doFoodTick()
this is checked in setSprinting() anyway.
2018-05-19 16:33:13 +01:00
Dylan K. Taylor
11cc9f19ad Human: replace hardcoded difficulty values with constants in doFoodTick() 2018-05-19 16:32:30 +01:00
Dylan K. Taylor
807af2e6fb Human: change doFoodTick() visibility to protected 2018-05-19 16:30:41 +01:00
Dylan K. Taylor
0bb5e88b5c Hinting up Entity API to PHP 7.2 standards 2018-05-19 10:46:47 +01:00
Dylan K. Taylor
389990e0a8 Entity: remove useless functions
these may be TODOs but I have no idea why or where they need to be implemented, so until they do they are useless clutter.
2018-05-18 20:09:55 +01:00
Dylan K. Taylor
d8dc89e7c8 EnderChestInventory: Removed unnecessary owner parameter 2018-05-18 16:46:48 +01:00
Dylan K. Taylor
c285295037 Merge branch 'release/alpha12' 2018-05-17 18:40:24 +01:00
Dylan K. Taylor
5c66c615bf Living: fix possible crash in getTargetBlock()
ArrayOutOfBoundsException is not thrown by SPL anymore since the exception handler throwing it was removed by @shoghicp. Regardless, it seems cleaner to to check it properly.
2018-05-09 17:11:37 +01:00
Dylan K. Taylor
dd1dfefd83 ItemEntity: remove unnecessary damage types restrictions
Invalid damage types are all restricted by other means anyway. This fixes items not getting killed by fire (close #2143) and cacti.
2018-05-04 22:57:28 +01:00
Dylan K. Taylor
8b225fc4ef New entity metadata flags and properties 2018-05-02 12:03:29 +01:00
Dylan K. Taylor
646455f6e8 fixed painting particles, removed DestroyParticle
it didn't last long because they changed how this works... yuk
2018-04-09 16:26:15 +01:00
Dylan K. Taylor
05a1e61e5b Painting: polyfill height and width 2018-04-09 16:20:46 +01:00
SleepSpace9
47faf5a994 Human: Add support for 128x128 skins in isValidSkin() (#2140) 2018-04-07 09:00:08 +01:00
Dylan K. Taylor
c06c1c7ce0 Human: Added a hack for nametags
Apparently NAMETAG metadata is useless in AddPlayerPacket now, so it has to be sent separately.
2018-04-05 11:56:44 +01:00
Dylan K. Taylor
a889a0e517 Workaround for player hitbox bug on respawn
this happens when a player respawns before their death animation ends. I don't know why, but their bounding box height suddenly becomes zero. This solves the bug by simply resending the height and width properties to viewers on respawn.

Closes #2135.
2018-04-04 20:11:16 +01:00
Dylan K. Taylor
9ed0d9d36f added some data properties 2018-04-04 19:40:12 +01:00
Dylan K. Taylor
5b7b2dd0e2 Merge changes from ALPHA11 for 1.2.13 2018-04-04 11:31:39 +01:00
Frago9876543210
42d04a4418 Allow use of 128x128 skins for last beta build (#2123) 2018-04-04 11:03:51 +01:00
Dylan K. Taylor
526f05631e fix metadata properties for new beta
there are more things than this, but I don't have time to figure them all out.
2018-04-04 11:03:05 +01:00
Dylan K. Taylor
5ce55bd3b0 duct tape for block ID remapping 2018-04-04 11:00:39 +01:00
Dylan K. Taylor
1fc388d6de DataPropertyManager: fix an unnecessary FQN 2018-04-02 12:34:05 +01:00
Dylan K. Taylor
d4d57aa9ea Merge branch 'feature/xp-event' 2018-03-30 12:46:53 +01:00