1
0
Fork 0
Commit Graph

125 Commits

Author SHA1 Message Date
Tobias Wilken 36eab1b323
Introduce recipe book functionality (#4493)
* Introduce recipe book functionality

The recipe book helps especially new players. Missing it gives the
impression that cuberite is not as advanced as it is.

The handling of the recipe book uses the following functions:

- Unlock Recipes
(https://wiki.vg/index.php?title=Protocol&oldid=14204#Unlock_Recipes) to
make recipes available and show the notification for new recipes.
Initialization is done on player login for known ones, the update is done
when new items are discovered.
- Craft Recipe Request
(https://wiki.vg/index.php?title=Protocol&oldid=14204#Craft_Recipe_Request)
when the user selects a recipe from the recipe book to fill the slots.

Known recipes are initialized on player login via `Unlock Recipes` with
`Action` 0.
As soon as a new recipe is discovered this is added via `Unlock Recipes`
with `Action` 1.

To be able to know and recognize new recipes the player class is
extended with `KnownItems` and `KnownRecipes`. As soon as a player
touches an item this is compared to the list of `KnownItems`, if the
item is unknown the recipes are checked for this item and the other
ingredients are checked with the list of `KnownItems`. If a full match
is discovered the recipe is unlocked with the client and stored in the
`KnownRecipes`.

To unlock recipes the recipe ID is sent to the client. A mapping file
(for protocol 1.12.2) translated the minecraft recipe names to ids. The
crafting.txt is extended with and minecraft recipe names is possible.

Limitations:
Only a single recipe is added to the crafting area. Multiple clicks or
shift click does not increase the number of builds.

Co-authored-by: peterbell10 <peterbell10@live.co.uk>

* Address first issues mentioned by @peterbell10

- Some linting
- Extract loading of recipe specific protocol mapping into a function
- Build `RecipeNameMap` only once
- Use `std::optional`
- Extract `LoadRecipe` from `Window`

* Start to implement new suggestions

* Update with suggestions from @peterbell10

* Some minor cleanup

* Update protocol packet IDs
* Remove unused include
* Include header in cmake
* Change a vector to integer counter

* Change dromedaryCase method names to PascalCase

* Address suggestions from @madmaxoft

* Read Protocol subdirectories to load recipe books

To load all recipebooks iterate over the `Protocol` subdirectories
to find mapping files.

Co-authored-by: peterbell10 <peterbell10@live.co.uk>
2020-07-14 17:56:42 +01:00
DrButcher 258318ab98
Buttons can now be triggered by arrows. (#4670)
* Buttons can now be triggered by arrows.
2020-05-03 21:05:32 +01:00
Alexander Harkness 994036a3b8
Add cEntity::GetBoundingBox, and use where appropriate. (#4711)
* Add cEntity::GetBoundingBox, and use where appropriate.
2020-05-03 21:04:33 +01:00
Tiger Wang 63adc6d7dc Add API documentation for repeater metadata constants 2020-04-18 16:51:29 +01:00
Mattes D a55f61548e
Extended Vector3 (#4666) 2020-04-18 11:44:35 +02:00
Mattes D 2cb85a1bcb API docs: Fixed eMonsterType relocation. 2020-04-10 08:19:43 +02:00
Bond-009 8438def87e
Add Zombie Villagers 2020-04-10 00:50:45 +01:00
Mat 60bcc06f43
Implement wither skeletons (#4563) 2020-04-04 13:44:17 +02:00
Alexander Harkness cdc452916e
Replace buckets to the selected hotbar slot, rather than the first available. (#4580)
* Replace buckets to the selected hotbar slot, rather than the first available.

Replicates vanilla behaviour, as well as being more logical.

* Refactor cInventory::AddItem. Behaviour is now documented

* Add new cInventory::ReplaceOneEquippedItem and ::SetEquippedItem methods

* Return empty potion to the same slot after drinking

* Replace buckets correctly in other situations, not simply water and lava

Uses the new ReplaceOneEquippedItem method

* Correct collecting water from source block with bottle

* Add cPlayer::ReplaceOneEquippedItemTossRest method

* Handle stacked filled buckets (in theory)

Use new cPlayer::ReplaceOneEquippedItemTossRest method
2020-04-02 12:42:15 +00:00
Alexander Harkness 9210501af5
Prevent player from being destroyed by plugins (#4584)
* Prevent player from being destroyed by plugins

Add manual binding, bails out with error message if attempted
entity to destroy is player.

* Improve warnings and documentation, remove automatic binding

* Remove old and unnecessary deprecated function
2020-03-31 11:39:23 +00:00
Mat 5eb1ba3bcc
Lua API for spectating entities (#4518) 2020-03-30 21:35:37 +02:00
Mat 782619e3f8
Send respawn packet by default (#4540) 2020-03-24 14:54:12 +00: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 8212f163b5 Register vanilla blocks in BlockTypeRegistry. 2019-08-05 21:42:54 +02:00
Zach DeCook 31a8d017d9 * Sponge: Add water absorbtion (#4333)
Closes #1411
2019-06-11 00:28:02 +01:00
Zach DeCook 24a8456f79 Create Ender Portal with Eyes of Ender (#4126)
The algorithm was designed so All portals must be facing the center, no matter which block had the eye inserted in last.

Note: Still need to create a block entity so that portals don't become invisible when you relog.

Addresses part of #3445
Fixes #3695
2019-05-11 20:43:26 +01:00
Muhammad Kaisar Arkhan 73689024f0 Add BurnsInDaylight to Lua API and Monsters.ini (#4295)
* Monster.h: Export SetBurnsInDaylight

This commit also adds BurnsInDaylight to check if the Monster burns in daylight
or not.

Closes https://github.com/cuberite/cuberite/issues/4294

* MonsterConfig.cpp: Add BurnsInDaylight

Closes https://github.com/cuberite/cuberite/issues/4294
2018-09-24 21:32:47 +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
changyong guo 2d3013d1d3 Support swap item between main hand and offhand by press key "F" (#4241)
Hi,

I found cuberite don't support to press key "F" to swap items on main hand and offhand, so I implemented this feature.

Best regards
Changyong
2018-06-24 10:24:10 +01:00
peterbell10 cf75d7b2c5 cBlockInfo: Deprecate direct access to variables. (#4184) 2018-02-20 10:43:28 +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
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
peterbell10 0bacda3269 Implement horse inventory (#4053)
* Implement horse inventory

* Fix sign conversions

* Add API doc for ItemCategory::IsHorseArmor

* Improve HandleOpenHorseInventory comment and style fixes.
2017-10-21 17:56:09 +01: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
Lane Kolbly b12f4ef7d5 Made world data paths adjustable, and added API to temporarily disable saving chunks to disk. (#3912) 2017-09-07 13:41:16 +01:00
Alexander Harkness b5a23e5cd9 Lighting now generally consistent with vanilla (#3988)
* Lighting now generally consistent with vanilla

Skylight is now dispersed by some blocks, instead of passing
through unimpeded.

Some blocks which were not marked as transparent are now marked as
such.

Water and other such blocks now attenuate light with the correct
intensity.

Generally changes were based on documentation in the Minecraft
Wiki: https://minecraft.gamepedia.com/Opacity#On_block_light ,
however during play-testing on vanilla lava was found not to
attenuate sky or block-light so the attenuation was removed.

This fixes #3849

* Add API documentation for IsSkylightDispersant

* Rename m_SkylightDispersant to m_IsSkylightDispersant

* Update comment for m_Transparent property of Blocks
2017-09-07 11:56:17 +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
Lukas Pioch ed7adef1ca Updated APIDoc (#3985) 2017-09-07 10:33:46 +02:00
Lane Kolbly 1f9788a801 Added ShouldSendRespawn parameter to ScheduleMoveToWorld (#3979) 2017-08-30 02:35:53 +03:00
Lukas Pioch d5c4b3af6b APIDump: Removed unneeded Globals prefix 2017-08-29 15:49:29 +02:00
satoshinm 6bc5031517 Implement Forge protocol handshake support (#3869) 2017-08-27 23:10:20 +02:00
peterbell10 f4f2fc7c3d Add cUUID class (#3871) 2017-08-25 13:43:18 +01:00
mathiascode 02775e52c4 Minor changes (#3909) 2017-08-24 11:19:40 +02:00
Pablo Beltrán b18f6637b6 Fully implemented leashes (#3798) 2017-08-21 10:46:41 +02:00
peterbell10 b8dda388e0 Represent cItem::m_Lore as an AStringVector (#3882)
* Replace cItem::m_Lore with AStringVector

* Reword deprecation warning

* Fix lua bindings
2017-08-18 11:29:54 +01:00
Lane Kolbly 1ec85a2b2c Add cLuaWindow OnClicked Callback (#3901) 2017-08-17 16:27:43 +02:00
peterbell10 9472380494 cBlockInfo: Deprecate place sound 2017-08-07 09:31:36 +01:00
Lane Kolbly 790e15f2e6 Added anvil enchantment handling. (#3857)
+ Added anvil enchantment handling.
2017-07-28 18:00:20 +01:00
Lane Kolbly 5402b214b3 Check for intersection between placed blocks and entities. (#3850)
* Check for intersection between placed blocks and entities.

+ Implemented GetPlacementCollisionBox, to permit custom placement collision boxes for blocks.

* Factored block-entity placement checking into another function in cPlayer.

- Removed vector min/max functions

* Use GetWorld to get the world in DoesPlacingBlocksIntersectEntity.

+ Added block height checks, allow different cEntity subclasses to decide whether they will prevent block placement.
2017-07-28 17:59:21 +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
peterbell10 41d016cf5b Handle middle mouse drag (#3847) 2017-07-13 15:43:48 +02:00
Lane Kolbly b61898c30c Lua plugin cColor (#3833) 2017-07-12 12:30:43 +02:00
Lane Kolbly 793acd267f Changing pickup lifetime and combining semantics, making these adjustable in the lua api. (#3843) 2017-07-12 12:13:27 +02:00
Lane Kolbly a561886bf3 Implemented draggingitem API. 2017-07-10 05:46:04 +02:00
peterbell10 bbf5bec817 BigFlower fixes (#3826)
* BigFlowers fixes

* Correct upper part meta
* Documented parameters to DoesIgnoreBuildCollision
2017-07-07 16:37:53 +02:00
Bond-009 7fd3899796 Added 1.12 blocks (#3760) 2017-06-30 10:46:58 +02:00
peterbell10 33527067ed Update tolua and export EffectID 2017-06-29 18:58:48 +02:00