1
0
Commit Graph

5396 Commits

Author SHA1 Message Date
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
86a8fdf3fe tolua++ bindings use nullptr. (#4219)
Fixes compilation with -Wzero-as-null-pointer-constant.
2018-04-27 23:22:41 +02:00
peterbell10
319b30eec6
Fix fishing timer (#4217)
Fixes ["Fishing Speed Too Slow"](https://forum.cuberite.org/thread-3175-post-29000.html#pid29000).

Interestingly, the constants @NiLSPACE points out are actually correct:
```cpp
(Random.RandInt(100, 900) - static_cast<int>(a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100))
```
100 to 900 ticks is the correct timing of 5-45 seconds. However, the timer is only updated when the floater is in the water and the server side position was actually bobbing in and out of the water. This meant the timer took ~2-3x longer than it should.

With this change the floater position is always in the water and so the timer works as expected.
2018-04-27 16:33:45 +01:00
mathiascode
02d75c5336 Removed unnecessary disconnect (#4200) 2018-04-27 08:59:03 +02:00
Bond-009
98d807187b Removed duplicate code (#4198)
Should also fix dogs not despawning
2018-04-11 12:17:30 +01:00
peterbell10
4bf160d596 Update m_LastSentPosition in TeleportToCoords and DoMoveToWorld. (#4211) 2018-04-11 08:39:24 +01:00
Alex Sweet
a0896c63d7 Smelting Gives Experience (#4094)
* Smelting Exp

Smelting now gives experience

* Furnace.txt update

Exp rewards are entered in furnace.txt, Reward calculation is now done
is the furnaceentity class

* furnace.txt update

Changed alignment tabs to spaces
Included documentation of exp in recipe

* Updated StringToFloat

changed strtod to strtof

* Explicit Float to Int

* Reworked Smelting Rewards

* No C casts

-Adds new function to the api
-Sets reward counter to 0 in furnace constructor

* Style and exp lock removed

-Fixed  style mistakes accoring to PR notes
-XP isn't locked to a single player anymore

* No Smelter API

-Removed SetLastSmelter and GetLastSmelter
-Fixed comments
-Fixed log reward amounts
2018-04-11 07:46:11 +01:00
peterbell10
1e312296cc Fix cUUID::Variant (#4213) 2018-04-08 00:20:53 +02:00
mathiascode
f4a1ebd880 Properly destroy player (#4199) 2018-04-03 14:39:39 +01:00
Zach DeCook
7833e8112f * Block Info: glazed terracotta and concrete hardness/solid voxel status (#4205) 2018-04-02 18:45:01 +01:00
mathiascode
a879778968 Broadcast playerlist removal in every world (#4201) 2018-04-02 18:39:54 +01:00
Bond-009
1991a5b0e6 Wolves only spawn in taiga biomes (#4197)
Ref: https://minecraft.gamepedia.com/Wolf#Spawning
2018-03-20 10:44:30 +01:00
peterbell10
4f26f653e1
Add cPluginManager::GenericCallHook (#4027)
Replace repetitive CallHook functions with a generic implementation.
Also converts some loops to range-based for.

Related to #1134
2018-03-02 10:40:48 +00:00
peterbell10
999faa9d90
cLightingThread: Faster chunk reading (#4185)
Profiled at a 10x speedup for cLightingThread::ReadChunks.
2018-02-21 10:30:48 +00:00
peterbell10
1ea36298d2
Fix cUrlClient leak (#4125)
Fixes #4040
* The TCP connection is now shutdown after OnBodyFinished
* Any open connections are closed when cNetworkSingleton::Terminate() is called.
* Removed ownership cycles in cUrlClientRequest
* Added a check to the test to ensure there are no leaks.
2018-02-20 17:08:46 +00:00
peterbell10
cf75d7b2c5 cBlockInfo: Deprecate direct access to variables. (#4184) 2018-02-20 10:43:28 +00:00
Bond-009
7e9695ecb0 Damage fishing rod when catching the hook on a block, then reeling it in (#4151)
Fixes #4132
2018-02-11 12:40:16 +00: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
peterbell10
2df14a0496
cChunk and cChunkData: Use vectors for block get and set functions (#4172)
* cChunkData: Change interface to use Vector3i
* cChunk: Add Vector3i overloads for bounded block get and set functions.
2018-02-04 22:15:31 +00:00
Bond-009
d12804d4c0 Ocelots don't take fall damage (#4171) 2018-02-04 20:53:35 +00:00
peterbell10
f0c735e846
A player's inventory is always opened by its owner. (#4176)
Fixes #4093

Window updates are only broadcast to players in the m_OpenedBy list. Normally players are added after sending a window open packet but no packet is sent for a player's inventory. This meant broadcasts were never sent for the inventory window.
2018-01-28 17:24:59 +00:00
peterbell10
95108c134d
cClientHandle: Always call HOOK_PLAYER_RIGHT_CLICK (#4149)
Reverts the reduction in cases where the hook was called, a change which broke plugins.
2018-01-25 08:10:16 +00:00
Bond-009
d3a3c6ad2c Removed cBlockInfo.m_IsSnowable (#4105)
* Removed cBlockInfo.m_IsSnowable

* Return IsSnowable from deprecated variable binding m_IsSnowable.
2018-01-23 21:07:06 +00:00
peterbell10
ab350d1e43
cItemGrid: Allocate storage lazily (#4083)
* cItemGrid: Allocate storage lazily
* cItemGrid: Fix spelling, Prioritary -> Priority
2018-01-21 18:45:13 +00:00
peterbell10
e88b3fa2fe New movement system for leashed entities (#4147)
* New movement system for leashed entities
Entities are accelerated towards the leashed to entity as if by a spring.
 * Mobs now pathfind close to but not directly to the leashing entity.
* Also minor comment changes
2018-01-17 21:40:58 +00:00
Bond-009
ec9e0eecf6 Calculate crit damage properly (#4154) 2018-01-17 21:12:24 +00:00
Bond-009
701fee334c Prioritize hinge on the left side (#4153) 2018-01-17 19:15:42 +00:00
Bond-009
d11335e4f6 Add world name in logs from cWorld (#4148) 2018-01-16 22:04:39 +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
Bond-009
3065a101a5 Don't burn mobs in daylight when swimming (#4145) 2018-01-15 22:44:48 +00:00
peterbell10
a72891fbb0
cWindow: Fix slot area priority when double click stacking. (#4086)
Fixes #4084
2018-01-15 11:35:27 +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
9caihezi
4242431407 Rewrite cClientHandle::HandleRightClick (#4089)
* Add hand parameter to distinguish main hand/off hand.
* Add a new function cClientHandle::HandleUseItem to separate the functionality of using an item without a target block. This matches the protocol with client version >= 1.9
* Always actively update the status of a block if the placement fails (by out of reach or rejected by plugin).
* Do not call plugin callback CallHookPlayerRightClick(-1, 255, -1, -1, 0, 0, 0) when using item.
   The CallHookPlayerUsingItem will still be called.
   Now at most one of CallHookPlayerRightClick, CallHookPlayerUsingBlock,
   CallHookPlayerUsingItem and CallHookPlayerEating will be called based on
   the type of action (not including the used version of callbacks).
* Do not count using item as BlockInteractionsRate check (Using item takes time).
* Now we can open chests(etc.) when sneaking as long as the player's hand is empty.
   This is what vanilla server does.
2018-01-08 13:37:10 +00:00
Alexander Harkness
2529a89835 Golden Apple Fixes (#4130)
* Do not remove food item until player has been fed
* Golden apples now ignore hunger when eating
* Removed EnchantedGoldenApple recipe, as it was removed in 1.9
    Reference: https://minecraft.gamepedia.com/1.9#Items_2
* Adjust golden apple effects, as they were changed in 1.9
    Reference: https://minecraft.gamepedia.com/1.9#Items_2
2018-01-06 00:39:23 +00:00
Bond-009
d7de2dccf0 Improved fishing rewards (#4120)
* Damage fishing rod after use
* Give xp to the player for catching something
* Fixed junk drops
* Implement Luck of the Sea
2018-01-05 14:32:30 +00:00
Bond-009
a2de7c2bb1 Sugar cane can be near frosted ice (#4133) 2018-01-05 12:49:08 +00:00
Alexander Harkness
b4aa19f329
Item durability loss now depends on the item used. (#4123)
Armour durability also no longer changes when it
is used to break blocks or attack mobs.

Fixes #4119
2018-01-05 11:28:06 +00:00
peterbell10
757231cc6e
Add the fmt library (#4065)
* Replaces AppendVPrintf with fmt::sprintf
* fmt::ArgList now used as a type safe alternative to varargs.
* Removed SIZE_T_FMT compatibility macros. fmt::sprintf is fully portable and supports %zu.
* Adds FLOG functions to log with fmt's native formatting style.
2018-01-03 17:41:16 +00:00
Zach DeCook
68fc28857f Concrete mixing (#4096)
Adds a block handler for concrete powder and implements hardening to concrete.
Concrete powder turns into concrete when:
* It is next to water when it receives a block update
* It falls onto a water block (even with Physics SandInstantFall=1)
2018-01-03 16:33:31 +00:00
peterbell10
177273006e
cLuaState: Update Push for entities. (#4128)
Fixes #4127

Some classes were exported but were only pushed as a cEntity
meaning exported functions were inaccessible.
This brings cLuaState::Push(cEntity *) up to date with all exported entities.
2018-01-03 11:38:00 +00:00
Bond-009
00da9006b7 Lilypads can be on top of (frosted) ice (#4122)
Fixes #4117
2017-12-27 18:47:28 +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
Alexander Harkness
705deea205
Water bottles are drinkable potions (#4114)
Water bottles are now drinkable potions

Fixes #4111

Also update outdated mcwiki references
2017-12-26 20:27:24 +00:00
peterbell10
533c95d9e2 Protocol: Fix potion metadata parsing (#4116) 2017-12-26 18:51:38 +00:00
peterbell10
832b394715 Fix Travis build (#4101)
Stop using gdb on osx - was breaking the build
Add clang 3.5 build as travis now defaults to 5.0
Fix unknown-warning-option errors on AppleClang
ProtoProxy: Use nullptr
UrlClientTest: add override to callback destructor
Update jsoncpp to use nullptr
2017-12-22 18:25:46 +00:00
Alexander Lyons Harkness
a9c8ad9ce2 Fix typo in #4095.
The build was being broken.
2017-12-21 16:01:24 +00:00
Mattes D
01322cb1b0 NetworkLookup: Added "virtual" keyword to overridden dtor. (#4100) 2017-12-21 13:31:20 +00:00
peterbell10
e0ff5f5639 cInventory: Add listener to shield slot. (#4095) 2017-12-21 11:55:23 +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