1
0
Fork 0
Commit Graph

118 Commits

Author SHA1 Message Date
Tiger Wang bab5794f76 Remove some unused typedefs 2021-07-06 21:33:03 +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 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 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 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
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 53ae358d8c Replace custom ChunkCoordinate with cChunkCoords 2020-12-21 23:21:01 +00:00
Tiger Wang f3ec768dfb unique_ptr<cChunkMap> to plain member 2020-12-21 23:21:01 +00:00
Tiger Wang 93adbdce9a
Use tracing for explosions (#4845)
* TNT: Implement tracing algorithm

+ Add intensity tracing
* Fix iterating over all players to SendExplosion, even those not in range

* Implemented TNT entity interaction

* Fixed misaligned destruction tracing

* Finalise TNT algorithm

- Remove BlockArea and just use chunks

Using SetBlock makes it so that we can update everything properly, and does appear to be faster.

* BlockInfo learns about explosion attentuation

* Rename Explodinator parameters

* TNT: pull block destruction into common function

Co-authored-by: Alexander Harkness <me@bearbin.net>
2020-09-12 18:57:44 +00:00
Tiger Wang 5e670a050b Rename AddEntityIfNotPresent to AddPlayer
+ Always make a chunk for the player to go into
* Fixes #4847
2020-09-03 22:25:35 +01:00
Tiger Wang 7023548de0 Simplify MoveEntityToNewChunk
- No longer try getting from the chunkmap if GetNeighborChunk fails, since nothing else does this and entities (in future) will not tick close to an unloaded chunk edge
* GetRelNeighborChunk uses FindChunk
2020-08-28 21:32:46 +01: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 72ae5ecb5a ChunkMap: do not wantonly make empty chunks
- Removed calls that constructed an empty chunk, found it was invalid, and did nothing with said chunk

Partially addresses #2324
2020-08-28 21:22:44 +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
Tiger Wang d1b0d0f5b5 Remove level of indirection in cChunk storage
- No more unique_ptr storage
2020-08-21 00:50:09 +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 71ffa76847 Remove unused block tick related cChunk functions 2020-08-02 15:52:06 +01: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
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
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 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
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
Bond-009 10c5c1227e BroadcastBlockBreakAnimation and BroadcastBlockEntity use vectors (#4038) 2017-09-25 18:17:45 +02:00
Lane Kolbly 30c8470a52 Changed BroadcastSoundEffect, SendSoundEffect, and CastThunderbolt parameters to vectors (#3959)
* Made BroadcastSoundEffect take vector parameters.

* Added docs for new vectored methods

* Removed old code

* Fixed lua warnings

* Made old BroadcastSoundEffect not an override.

* m_Block to m_BlockPos, used Vector3d constructor where prettier.

* a_Block to a_BlockPos

* Changed thunderbolt a_Block to a_BlockPos
2017-09-19 15:12:54 +01:00
peterbell10 e225b7f826 Replace ItemCallbacks with lambdas (#3993) 2017-09-11 23:20:49 +02:00
LogicParrot 49c443896d Revert "Replace ItemCallbacks with lambdas (#3948)"
This reverts commit 496c337cdf.
2017-09-02 08:50:23 +01:00
peterbell10 496c337cdf Replace ItemCallbacks with lambdas (#3948) 2017-09-01 13:04:50 +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 7bdbfad1bb Changed int parameters to vector parameters in cCuboid and simulators (#3874) 2017-08-17 15:48:38 +02:00
Tiger Wang 4ef47aed62 Changed entity ownership model to use smart pointers 2017-08-07 19:24:16 +01:00
Dan Čermák 028ed77ca9 Fixed compilation for clang 4.0 & gcc 7.1 2017-08-04 11:17:39 +02:00
Lukas Pioch 0397535fa7 Removed unused forward declarations (#3888) 2017-08-03 15:10:29 +02:00
peterbell10 8eb5672920 cWorld::SendBlockTo take player by ref 2017-08-01 08:21:20 +02:00
Mattes D 167c4bf2e6 Simulators: Added area-based wakeup. 2017-07-16 10:01:19 +02:00
Lukas Pioch 885d828712 Added bed entity (#3823)
* Added bed entity

* Export cBedEntity to lua
* Set color of bed through item damage value
* Added bed entity to APIDoc
* NBT: Added loading and saving
* Crafting recipes for the colored beds
2017-07-07 09:31:45 +02:00
peterbell10 360d8eade0 FastRandom rewrite (#3754) 2017-06-13 21:35:30 +02:00
Mattes D 7cc3fb098d DeadlockDetect now lists some tracked CS's stats. 2017-01-18 09:03:05 +01:00
Mattes D 0e3b3be766 Initial support for the 1.11 protocol. 2016-12-16 00:07:22 +01:00
bibo38 cb640ffea4 Spectators added (#2852) 2016-10-12 14:38:45 +02:00
LogicParrot 7e9e7f7911 Configurable dirty unused chunk cap to avoid RAM overuse (#3359)
Configurable dirty unused chunk cap to avoid RAM overuse
2016-09-03 18:38:29 +03:00
Tiger Wang 38368f361d Simplified cChunkMap chunk storage (#2565) 2016-08-03 00:56:53 +02:00
Mattes D f8e1df2476 Updated API documentation. 2016-07-18 22:11:40 +02:00
QUSpilPrgm f1192c6860 Makes tall grass and large flowers bonemealable
Adds the bonemeal particle effect to some more places
2016-06-03 15:45:49 +02:00
QUSpilPrgm 706257f8fb Update Dispensers and let them act more like in Vanilla
- Added code to make bonemeal, potions, minecarts, XP bottles and boats work inside dispensers
- Dispensers are now able to place TNT if the block is transparent but not air
- Added return value that indicates the success of pumpkin, melon, sugarcane and cactus growing functions
- Changed return value of "GrowRipePlant" so that it actually indicates if the block was able to grow
- Fixed "GrowSugarcane" and "GrowCactus" in "GrowRipePlant" so that it only grows them a single block
2016-06-03 15:45:49 +02:00
Pokechu22 a4f327118b 1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a

I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.

* Update to 15w34b protocol

Also, fix an issue with the Entity Equipment packet from the past version.  Clients are able to connect and do stuff!

* Partially update to 15w35e

Chunk data doesn't work, but the client joins.  I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.

* Add '/blk' debug command

This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.

* Fix CRLF normalization in CheckBasicStyle.lua

Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line.  Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.

The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.

* Update to 15w40b

This includes chunk serialization.  Fully functional chunk serialization for 1.9.

I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later.  The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.

* Write long-by-long rather than creating a buffer

This is a bit faster and should be equivalent.  However, the code still doesn't look too good.

* Update to 15w41a protocol

This includes the new set passengers packet, which works off of the ridden entity, not the rider.  That means, among other things, that information about the previously ridden vehicle is needed when detaching.  So a new method with that info was added.

* Update to 15w45a

* 15w51b protocol

* Update to 1.9.0 protocol

Closes #3067.  There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work.  I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes).  Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).

* Fix item pickup packet not working

That was a silly mistake, but at least it was an easy one.

* 1.9.2 protocol support

* Fix version info found in server list ping

Thus, the client reports that it can connect rather than saying that the server is out of date.  This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.

* Fix build errors generated by clang

These didn't happen in MSVC.

* Add protocol19x.cpp and protocol19x.h to CMakeLists

* Ignore warnings in protocol19x that are ignored in protocol18x

* Document BLOCK_FACE and DIG_STATUS constants

* Fix BLOCK_FACE links and add separate section for DIG_STATUS

* Fix bat animation and object spawning

The causes of both of these are explained in #3135, but the gist is that both were typos.

* Implement Use Item packet

This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.

* Handle DIG_STATUS_SWAP_ITEM_IN_HAND

* Add support for spawn eggs and potions

The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.

* Remove spammy potion debug logging

* Fix wolf collar color metadata

The wrong type was being used, causing several clientside issues (including the screen going black).

* Fix 1.9 chunk sending in the nether

The nether and the end don't send skylight.

* Fix clang build errors

* Fix water bottles becoming mundane potions

This happened because the can become splash potion bit got set incorrectly.  Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.

Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.

* Copy Protocol18x as Protocol19x

Aditionally, method and class names have been swapped to clean up other diffs.  This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).

* Make thrown potions use the correct appearence

This was caused by potions now using metadata.

* Add missing api doc for cSplashPotionEntity::GetItem

* Fix compile error in SplashPotionEntity.cpp

* Fix fix of cSplashPotionEntity API doc

* Temporarilly disable fall damage particles

These were causing issues in 1.9 due to the changed effect ID.

* Properly send a kick packet when connecting with an invalid version

This means that the client no longer waits on the server screen with no indication whatsoever.  However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.

I also added a GetVarIntSize method to cByteBuffer.  This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).

* Handle server list pings from unrecognized versions

This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).

* Use cPacketizer for the disconnect packet

This also should fix clang build errors.

* Add 1.9.3 / 1.9.4 support

* Fix incorrect indentation in APIDesc
2016-05-14 20:12:42 +01:00
LogicParrot 36754f20f8 Fix Crash on stopping the server (#3176) 2016-05-02 00:18:21 +03:00
LogicParrot 7c7a0a0085 ChunkLayers now stored in std::map 2016-04-24 20:02:24 +03:00
LogicParrot b48b61eca4 Revert "ChunkLayers now stored in std::map" 2016-04-24 17:40:37 +03:00