1
0
Fork 0
Commit Graph

365 Commits

Author SHA1 Message Date
Tiger Wang 1e4850a6c5
World: change spawnpoint type to int (#5313)
* World: change spawnpoint type to int

As Vanilla does.
2021-10-03 17:43:22 +01:00
Tiger Wang b98e2c17e0 Don't flush ClientHandle data multiple times
* Change cWorld::m_Players to a vector
2021-06-28 21:54:21 +01:00
Tiger Wang a62b2b1be2
Move item placement into item handlers (#5184)
* Move item placement into item handlers

+ Add appropriate CanBeAt checks in cPlayer::PlaceBlocks, into which all placement handlers call.
* Partly addresses #5157
* Fixes #4878
* Fixes #2919
* Fixes #4629
* Fixes #4239
* Fixes #4849

Co-authored-by: changyong guo <guo1487@163.com>
Co-authored-by: Xotheus <shady3300@outlook.com>
Co-authored-by: Krist Pregracke <krist@tiger-scm.com>

* Review fixes

* Update APIDesc.lua

* Rename

Co-authored-by: changyong guo <guo1487@163.com>
Co-authored-by: Xotheus <shady3300@outlook.com>
Co-authored-by: Krist Pregracke <krist@tiger-scm.com>
2021-05-05 13:25:10 +00:00
Tiger Wang 66c211c33a Unify multiprotocol entity animations 2021-04-12 22:35:07 +01:00
Tiger Wang 956f5bca28 Remove unused GetClassStatic in cWorld 2021-04-12 22:35:07 +01:00
Tiger Wang 1394fc8eb5 Streamline player abilities handling
* Update player list gamemode on world change
* Fix invisibility for spectators, use entity metadata
* Populate m_World for cPlayers on load
- Remove SendPlayerMaxSpeed, a duplicate of SendEntityProperties
2021-04-12 22:35:07 +01:00
Tiger Wang 4cd49d7eca Fix sending incorrect date values on world change
Yak shave: make more things use cTickTime. Fix a couple of incorrect modulo-on-millisecond-value by making them use WorldTickAge.
2021-04-12 22:35:07 +01:00
Damián Imrich 071b7be3d4
Basic elytra flight (#5124)
* Basic elytra flight

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2021-04-03 18:45:20 +01:00
Tiger Wang 748b121703
Unify DoWithBlockEntity (#5168)
+ DoWith calls now broadcast the block entity and mark the chunk dirty
+ Add block entity change queue to synchronise BE updates with block updates
* Fixed a few incorrect assertions about BE type
- Remove manual overloads
2021-03-28 14:40:57 +01:00
Tiger Wang 90369deb5a
Change TimeOfDay to WorldDate (#5160)
* Change TimeOfDay to WorldDate

* Do not wrap at 20 minutes, continue incrementing
* Fixes #4737
* Fixes #5159
2021-03-20 20:58:19 +00:00
Tiger Wang 55ba39ca0e Don't send ping updates one packet at a time
* Use the batch update feature of the packet.
* Lengthen interval between time and ping update packets (ref. http://github.com/cuberite/cuberite/issues/4082#issuecomment-348675321).
2021-03-19 11:23:30 +00:00
Tiger Wang 45591cbe7b
Properly deprecate more XYZ parameter'd functions (#5147)
* Fixes #5144
2021-03-15 02:28:18 +00:00
12xx12 8405b8969f
Adding Boss bar (#5025)
+ Add boss bar

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2021-03-05 15:08:30 +00:00
Tiger Wang 868cd94ee9
Prepare ChunkData for BlockState storage (#5105)
* Rename ChunkData Creatable test

* Add missing Y-check in RedstoneWireHandler

* Remove ChunkDef.h dependency in Scoreboard

* Prepare ChunkData for BlockState storage

+ Split chunk block, meta, block & sky light storage
+ Load the height map from disk
- Reduce duplicated code in ChunkData
- Remove saving MCSBiomes, there aren't any
- Remove the allocation pool, ref #4315, #3864

* fixed build

* fixed test

* fixed the debug compile

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
2021-03-05 14:03:55 +01:00
dImrich 925f960ea2 Adds playerlist header and footer broadcasting (1.8-1.13) 2021-02-06 14:14:40 +00:00
Tiger Wang 054a89dd9e Clarify cClientHandle, cPlayer ownership semantics
+ A cPlayer, once created, has a strong pointer to the cClientHandle. The player ticks the clienthandle. If he finds the handle destroyed, he destroys himself in turn. Nothing else can kill the player.
* The client handle has a pointer to the player. Once a player is created, the client handle never outlasts the player, nor does it manage the player's lifetime. The pointer is always safe to use after FinishAuthenticate, which is also the point where cProtocol is put into the Game state that allows player manipulation.
+ Entities are once again never lost by constructing a chunk when they try to move into one that doesn't exist.
* Fixed a forgotten Super invocation in cPlayer::OnRemoveFromWorld.
* Fix SaveToDisk usage in destructor by only saving things cPlayer owns, instead of accessing cWorld.
2021-01-12 12:34:34 +00:00
Tiger Wang 9328afe65c Convert most calls to blocking GetHeight/GetBiomeAt to direct chunk accesses
* Hopefully fixes #5094
2021-01-11 16:39:56 +00:00
Tiger Wang d9a7c51d4d ViewDistance: unsigned -> signed 2020-12-26 16:58:53 +00:00
Tiger Wang f3ec768dfb unique_ptr<cChunkMap> to plain member 2020-12-21 23:21:01 +00:00
Tiger Wang 090d8305e4 Warnings improvements
* Turn off global-constructors warning. These are needed to implement cRoot signal handler functionality
* Add Clang flags based on version lookup instead of a compile test. The CMake config process is single threaded and slow enough already
* Reduced GetStackValue verbosity
+ Clarify EnchantmentLevel, StayCount, AlwaysTicked, ViewDistance signedness
+ Give SettingsRepositoryInterface a move constructor to simplify main.cpp code
- Remove do {} while (false) construction in redstone handler
2020-12-18 21:03:40 +00:00
12xx12 283b9d706c
Some const and inheritance correctness (#5014)
* Some const and inheritance correctness
* Devirtualise SendBlockTo(Vector3i)

Co-authored-by: 12xx12 <12xx12100@gmail.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-11-13 21:50:46 +00:00
0ddlyoko 672bb04570
Add correct implementation of crops (#4802)
* [FIX] Add correct implementation of seed drops.

> Official percentage of drops has been implemented

* Fix C++ conventions

* Change "Vals" variable to "m_Vals"

* [FIX] Add correct implementation of Carrots, Potatoes, Wheat & Beetroots seed

* Add Fortune support with crops

Add fortune support with Wheat, Carrots, Potatoes & Beetroots seeds

* [FIX] Right-clicking on a grown Beetroot in survival consume 2 bone meals

Fix #4805

* Add documentation for "cWorld::IsFullGrownPlantAt" method

* Fix dispenser that full grown a plant

> Change methods cItemDyeHandler::FertilizePlant & cItemDyeHandler::growPlantsAround to static

* Display particle even if tree doesn't grow

* When right-clicking on a full grown melon / pumpkin seed, no longer produce a melon / pumpkin

Before this commit, when you right-click on a melon or a pumpkin seed, a melon / pumpkin block spawned.
With this commit, it no longer spawns

* [FIX] Do not create melon / pumpkin block when right-clicking with a bone meal

This fix will prevent the creation of a melon / pumpkin block when you right-click with a bone meal on a melon / pumpkin plant
- It just detect if the plant is full grown. if yes, the method "Grow" is not called

- Remove IsFullGrownPlant

Co-authored-by: 12xx12 <12xx12100@gmail.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-11-06 16:54:01 +00:00
12xx12 36a67df105
Ender Crytal Fix and report proper cmake file for luabindingscheck fail (#5017)
* fixed network
fixed explosion
fixed ticking

added network broadcast to Setter method

added nullptr protection

using macros in 1.10 Protocol_1_10.cpp

revealed functions to LUA API

small fixups, typos, less functions used

fixed more doc

readded info that saving is done only if the beam is displayed

made the constructor transfer all needed members

fixed wrong commit

removed default parameters on SpawnEnderCrystal

fixed wrong metadata

moved call to destroy in the right place

fixed some typos

Fixed Ender Crystal

* fixed documentation

* fixed doc and added proper error message

* Parameters, arrows

* Parameters

Co-authored-by: 12xx12 <12xx12100@gmail.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-11-06 15:00:59 +00:00
12xx12 961d5eb420
Add beam target, configurable base visibility to Ender Crystals (#5010)
* Fixes #4990

Co-authored-by: 12xx12 <12xx12100@gmail.com>
2020-10-29 20:47:20 +00:00
Lukas Pioch 6ddc03db09 Add default value nullptr for parameter a_Digger and added digger to
cWorld:DigBlock in lua api
2020-10-09 18:39:20 +01:00
12xx12 3381c0f6d6
Merged OnBreak with OnPlayerBreak (#4967)
Co-authored-by: 12xx12 <12xx12100@gmail.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-10-08 20:13:44 +01:00
Tiger Wang 198407807f
Reverse order of ChunkSender priorities (#4858)
* Reduces confusion when using overloaded operator< and priority_queue

Co-authored-by: peterbell10 <peterbell10@live.co.uk>
2020-09-12 19:43:18 +00:00
Tiger Wang 08bd77e547 Clean up GenerateChunk/TouchChunk
- Remove TouchChunk
- Remove unused bool return value in GenerateChunk
- Remove ShouldGenerateIfLoadFailed
2020-08-28 21:26:04 +01:00
Tiger Wang b084f1f13f Remove unneeded MarkDirty, SendToClients parameters of SetMeta
Partially reverts #3129, whose addition of these parameters was superseded by #3149 that fixed generated leaves' metas.

References:
https://github.com/cuberite/cuberite/pull/4417#discussion_r334950513
e0bcd754009f16480437b2c1fa5e7fbedab31496
2020-08-28 21:08:06 +01:00
Mattes D 3d7acb6d10 Removed const 2020-08-27 17:32:48 +01:00
Mattes D c98a2d9acf Changed tree-growing functions in cWorld to use Vector3i coords. 2020-08-27 17:32:48 +01:00
Tiger Wang 6bdd130aab OnBroken/OnPlaced are for entity actions
* Call OnPlaced/OnBroken in PlaceBlock/DigBlock
- Remove unused Placing/Breaking handlers
* Have the blockhandler's Check handle neighbour updating, instead of QueueTickBlockNeighbors
2020-08-04 18:15:18 +01:00
Tiger Wang 9d277f1d10
cWorld * -> cWorld (#4771)
* cWorld * -> cWorld
2020-07-14 17:57:30 +01:00
Tiger Wang 07ca095740
Improve entity position updates (#4701)
* Make puking pickups fly nicer

* Improve entity position updates

* Move determination of whether a delta is too big for a packet into the protocol handlers
+ Less jittery movement
+ Generalise CollectEntity to take any entity
2020-05-04 08:10:47 +00:00
Mattes D 487f9a2aa9
Vector3 in Handlers (#4680)
Refactored all cBlockHandler and cItemHandler descendants to use Vector3.
2020-04-21 22:19:22 +02:00
Mattes D 26ac146f41
More Vector3 in cBlockHandler (#4644)
* cBlockHandler.OnUpdate uses Vector3 params.

Also slightly changed how block ticking works.
2020-04-17 10:36:37 +01:00
Mattes D 9ee47e5999 Using Super. 2020-04-16 20:07:48 +00:00
Peter Bell 43525c5df8 Acquire chunk map CS when accessing player entities 2020-04-13 17:13:38 +02:00
Mattes D bdedab15c9
Falling blocks can now be spawned at any position. (#4620)
* Falling blocks can now be spawned at any position.

* Added a /cake command to Debuggers that throws a cake in a nice slow arc.

* Fixed regular falling blocks.
2020-04-09 20:25:20 +00:00
Mattes D 01b8ed5295
Pulled the BlockID and BlockInfo headers from Globals.h. (#4591)
The BlockID.h file was removed from Globals.h and renamed to BlockType.h (main change)
The BlockInfo.h file was removed from Globals.h (main change)
The ENUM_BLOCK_ID and ENUM_ITEM_ID enum names were replaced with ENUM_BLOCK_TYPE and ENUM_ITEM_TYPE (cosmetics)
The various enums, such as eDimension, eDamageType and eExplosionSource were moved from BlockType.h to Defines.h, together with the helper functions for converting between them and strings (StringToDimension et al.) (minor)
Many inline functions were moved from headers to their respective cpp files, so that BlockType.h could be included only into the cpp file, rather than the header.
That broke our tests a bit, since they pick bits and pieces out of the main code and provide stubs for the rest; they had to be re-stubbed and re-verified.
eMonsterType values are no longer tied to E_ITEM_SPAWN_EGG_META_* values
2020-04-03 08:57:01 +02:00
Bond-009 ea386eaab1
Lock hopper when powered by redstone (#4347)
* Lock hopper when powered by redstone

* Add to manual bindings

* Add hopper API documentation

Co-authored-by: Mat <mail@mathias.is>
2020-03-27 12:03:28 +00:00
Mat 195bebb480
Disable bonemealable settings for now (#4551) 2020-03-26 17:06:15 +00:00
Mat c968f1f7da
TNT position fixes (#4519)
* TNT position fixes

* Don't add offset to explosion spawn coords

* Don't make other entities push TNT

* Correct initial TNT speed

* Fix typo

* Improvements

* Revert unwanted change

* Style fixes

* Update format
2020-03-22 17:33:36 +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
Mattes D 61904af626 Moved growing from cWorld / cChunk to cBlockHandler descendants. 2019-10-28 10:45:43 +01:00
Mattes D 221cc4ec5c
Refactored block-to-pickup conversion. (#4417) 2019-10-16 10:06:34 +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 66e73a2d68 NBTChunkSerializer: Cleaned up interface.
Removed dependency on cChunkDataCallback.
Moved all the serializing code into a worker class.
Changed the serialization into a single-call action.
2019-09-24 17:38:59 +02:00
Mattes D 878393a03d Moved the generator defaults to ComposableGenerator. 2019-09-06 16:12:33 +02:00
Mattes D a2ffa432b3 Separated chunk generator from world / plugin interfaces.
The generator now only takes care of servicing synchronous "GetChunk(X, Y)" and "GetBiomes(X, Y)" requests.
2019-09-06 16:12:33 +02:00