1
0
Commit Graph

241 Commits

Author SHA1 Message Date
Mat
5a2163d7e6
Don't send entity velocity for boats (#4488)
* Don't send entity velocity for boats
2020-03-07 13:56:02 +02:00
Mat
83a41c93e9
Attached entities can't enter portals (#4484)
* Attached entities can't enter portals

* Whitespace fixes
2020-03-05 21:33:43 +02:00
Mat
7d4934534e
Stabilise MoveToWorld (#4004)
* Stabilise MoveToWorld

* Fix comments and deprecate ScheduleMoveToWorld

* Enhanced thread safety for m_WorldChangeInfo

* Return unique_ptr from cAtomicUniquePtr::exchange

* cWorld now calls entity cEntity::OnAddToWorld and cEntity::OnRemoveFromWorld.

Allows broadcasting entities added to the world from the world's tick thread.
This also factors out some common code from cEntity::DoMoveToWorld and cEntity::Initialize.

As a consequence, cEntity::Destroy(false) (i.e. Destroying the entity without broadcasting) is impossible.
This isn't used anywhere in Cuberite so it's now deprecated.

* Update entity position after removing it from the world.
Fixes broadcasts being sent to the wrong chunk.

* Fix style

* cEntity: Update LastSentPosition when sending spawn packet

* Add Wno-deprecated-declarations to the lua bindings

* Kill uses of ScheduleMoveToWorld
2020-03-05 12:52:34 +02:00
peterbell10
d7a726a423
Update LastSentPosition when entity has no speed (#4487)
* Update LastSentPosition when entity has no speed

* Restructure BroadcastMovementUpdate and always process relmove
2020-03-04 16:47:51 +02:00
Mattes D
365cbc6e1c
Refactored more of Entities and BlockEntities to use Vector3. (#4403) 2019-09-29 14:59:24 +02:00
Mattes D
180a43d097 Fixed MSVC warnings (#4400) 2019-09-27 16:51:44 +01:00
Bond-009
e0ca4d8399 Fix building with clang 8.0 (#4346) 2019-08-11 10:39:43 +01:00
Aplaus228
466d986e5e Change TakeDamageInfo::FinalDamage from int to float (#4359)
Closes #4357
2019-08-08 11:51:38 +01:00
peterbell10
4727ed2084 Add a formatting function for Vector3 (#4282)
* Vector3: Add custom fmt compatible formatter.

* cLuaState: Add fmt version of ApiParamError

* Use vector formatting in manual bindings

* Always log vectors with FLOG
2018-09-24 21:33:39 +01:00
peterbell10
ee84197014
Force all headers other than "Globals.h" to be included with relative paths (#4269)
Closes #4236

CMake now creates a header file in the build directory under the path "include/Globals.h" which just includes "src/Globals.h" with an absolute path. Then instead of adding "src/" to the include directories, it adds "include/".

#include "Globals.h" still works by including the build generated file and any other src-relative path will not work.
2018-08-29 01:51:25 +01:00
bionext03
90d552a702 Add new flow direction calculating algorithm (#4160) 2018-07-27 10:01:53 +01:00
peterbell10
950aeffff8
CheckBasicStyle: Check number of empty lines between functions (#4267)
Add check for number of empty lines between functions and fix the corresponding failures
2018-07-26 22:24:36 +01:00
peterbell10
c94d7184eb Broadcast refactor (#4264)
* Move Broadcast functions from cChunkMap to cBroadcaster

- Remove cBroadcastInterface in favour of cBroadcaster.

- cChunk: Remove broadcast functions.

* resurect broadcast interface

* Absorb cBroadcaster into cWorld.
Removes the need for forwarding the function calls.

* Improve const-correctness

* Use Int8 instead of char

+ Comment `ForClients` functions

* Improve comments

* Broadcaster: Rename ForClients functions
2018-07-24 22:30:49 +01:00
changyong guo
01e72ddb65 Rewrite explosion knock back (#4251)
1. Base knockback on an entity's bounding box intersection with the explosion 
2. Armor blast protection reduces knockback
3. Don't apply knockback to players flying in creative mode

Fixes #4139
2018-07-23 10:24:00 +01:00
peterbell10
a4dbb5c582
Prefer static_cast to reinterpret_cast (#4223)
* Change reinterpret_cast -> static_cast wherever possible
* Remove more unnecessary `const_cast`s.

reinterpret_casts should be avoided for the same reason as c-style casts - they don't do any type-checking. reinterpret_cast was mainly being used for down-casting in inheritance hierarchies but static_cast works just as well while also making sure that there is actually an inheritance relationship there.
2018-05-02 08:50:36 +01:00
peterbell10
4bf160d596 Update m_LastSentPosition in TeleportToCoords and DoMoveToWorld. (#4211) 2018-04-11 08:39:24 +01:00
peterbell10
d3c1c626f5
Deal with covered switches consistently (#4161)
* Fixes a number of "<function>: not all control paths return a value" warnings on MSVC.

* Introduces the UNREACHABLE global macro and uses it instead of conditionally compiled switch defaults.

* Move cNBTParseErrorCategory from FastNBT.h into FastNBT.cpp to prevent bad calls to message()
2018-02-04 23:07:12 +00:00
Bond-009
ec9e0eecf6 Calculate crit damage properly (#4154) 2018-01-17 21:12:24 +00:00
Alexander Harkness
07619d932d
Exp Orbs and Pickups are destroyed instantly by cacti. (#4136)
* Cactus detection code follows pattern set in #3996

* Pickups are now destroyed on cactus contact

* Add cactus detection and destruction to Exp Orbs

Remove checks for IsExpOrb() in cEntity::Tick()

Exp Orbs do not call super::Tick() and so this condition was
pointless.
2018-01-16 19:13:17 +00:00
Alexander Harkness
ad22922393 Rename cEntity swim states (#3996)
* Replace cEntity:m_IsSubmerged with m_IsHeadInWater
* Replace cEntity:m_IsSwimming with m_IsInWater
* Add API documentation for new symbols
* Apply SetSwimState to all entities, not just mobs and players
* Pickups now use IsOnFire to check if they are on fire before destruction

Fixes #3987
2018-01-14 18:44:45 +00:00
Alexander Harkness
6309c6a97f
improve rain simulation (#4017)
* Uses vanilla logic to decide which blocks rain falls through.
 * Rain falls infinitely above the world, and stops at y=0.
 * Entities will now be extinguished if they are under rain-blocking
blocks, and fire will now be extinguished by rain similarly.
 * Create IsWeatherWetAtXYZ to identify wetness at a particular location. 
 * Use new code for enderman rain detection.
 * Fixes issue #916
 * Disable warnings for global constructors in the fire simulator.
2017-12-26 21:25:57 +00:00
bibo38
532731e6f4 Fixed Clang 5.0 compile errors (#4085)
* Fixed Clang 5.0 compile errors

* Fixed wrong comment

* Only disable warnings in Clang 5 or higher

* Added a CMake condition for the Clang 5 no-zero-as-null-pointer-constant warning

* Now using the use_nullptr branch of the Cuberite specific SQLiteCpp fork
2017-12-21 11:36:58 +00:00
Fabian
0dd172b80f Store Health as a float (#4073)
* Fix #4024

* Fix clang error

* Add comment

* Fix behaviour

* Save Health as float

* Changed m_Health to float

* Remove redundant static_cast

* Fix casts
2017-11-22 13:47:52 +00:00
Alexander Harkness
a4c07d2f98 Adjust lava damage values (#4020)
Fixes isue #2925
2017-09-12 09:02:17 +01:00
peterbell10
e225b7f826 Replace ItemCallbacks with lambdas (#3993) 2017-09-11 23:20:49 +02:00
Alexander Harkness
4e7325c9e2 Fix crash for players out of the world. Fixes #4006 (#4007) 2017-09-10 17:45:18 +01:00
Alexander Harkness
e33eb529ad Fire effect now shown for creative and spectator mode players (#3998)
* Fire effect now shown for creative and spectator mode players

Fixes #3989

* Add documentation for IsFireproof
2017-09-07 09:59:08 +01:00
peterbell10
ef1f371dab Add cWorld::RemoveEntity and use in cEntity (#4003)
* Add cWorld::RemoveEntity and use in cEntity

* cEntity: Remove uneeded asserts from Destroy and DoMoveToWorld
2017-09-05 15:11:35 +01:00
LogicParrot
49c443896d Revert "Replace ItemCallbacks with lambdas (#3948)"
This reverts commit 496c337cdf.
2017-09-02 08:50:23 +01:00
Alexander Harkness
700bbdabf5 SetSwimState now takes into account head height
This affects m_IsSubmerged and IsSubmerged() for entities of all
types.

Also prevent squids from suffocating in water.
2017-09-01 14:50:02 +01:00
peterbell10
496c337cdf Replace ItemCallbacks with lambdas (#3948) 2017-09-01 13:04:50 +02:00
Lane Kolbly
1f9788a801 Added ShouldSendRespawn parameter to ScheduleMoveToWorld (#3979) 2017-08-30 02:35:53 +03:00
Bond-009
3c8712d871 Gives all entities the default airlevel on creation (#3942)
* Guardians don't take damage on land
* Squids suffocate on land
2017-08-25 14:44:36 +01:00
mathiascode
02775e52c4 Minor changes (#3909) 2017-08-24 11:19:40 +02:00
Lane Kolbly
af6963f40f Added check in cEntity::TickBurning for whether the entity is planning to change worlds. (#3943) 2017-08-22 15:05:13 +01:00
Bond-009
a262bacc9d Give arthropods slowness IV when hit with bane of arthropods (#3932) 2017-08-21 10:51:26 +02:00
Pablo Beltrán
b18f6637b6 Fully implemented leashes (#3798) 2017-08-21 10:46:41 +02:00
Tiger Wang
72d7027861 Merge pull request #3489 from cuberite/EntityOwnership
* Changed entity ownership model to use smart pointers
2017-08-18 11:17:56 +01:00
Lane Kolbly
4dd2af27e0 Added knockback to arrows, fixed knockback enchantment handling (#3900)
* Added knockback for arrows, fixed knockback enchantment handling.
2017-08-13 12:40:23 +01:00
Tiger Wang
4ef47aed62 Changed entity ownership model to use smart pointers 2017-08-07 19:24:16 +01:00
Lane Kolbly
87af95b67c Updated armor cover calculation. (#3858)
* Updated armor damage calculation.

+ Added lua docs, added casts from float to int.

* Changed verbage in docstring and comment.
2017-07-23 10:46:38 +01:00
Lane Kolbly
647d9082b8 If entity is a player, send relmove packets. 2017-07-12 12:12:56 +02:00
Bond-009
cf22bc4e60 Players in creative and spectator aren't affected by cacti (#3824) 2017-07-02 07:39:19 +02:00
Mattes D
885d80ccdb Entity: Replaced a mutexed counter with a std::atomic. (#3773) 2017-06-15 16:06:50 +01:00
peterbell10
360d8eade0 FastRandom rewrite (#3754) 2017-06-13 21:35:30 +02:00
Pablo Beltrán
2b699dc749 Avoid pickups to sink into blocks and disappear (#3739)
* Avoid pickups to sink into blocks and disappear
2017-06-04 06:35:02 +02:00
Mattes D
0551d78dff Fixed tracer usage in Entity physics handling. (#3720) 2017-05-28 20:56:17 +02:00
Mattes D
2c3c1f1527 Tracer replacement (#3704)
* Replaced cTracer usage with cLineBlockTracer.

* Exported new cLineBlockTracer utility functions to Lua API.
2017-05-11 13:34:36 +01:00
Marvin Kopf
dbdcb85346 Added a nullptr check to cEntity::IsA (#3659)
Fixes #3603
2017-04-01 23:15:08 +02:00
Bond-009
6fe863c2ad Fixed cactus detection and zombie pigman sword (#3584)
Fixes for issues #902 and #2917
2017-02-25 19:14:08 +01:00