Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into pr/5447
Browse files Browse the repository at this point in the history
  • Loading branch information
12xx12 committed Mar 21, 2023
2 parents 6302340 + cb2201d commit c16f294
Show file tree
Hide file tree
Showing 45 changed files with 567 additions and 392 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
build*/
nbproject/
ipch/
Win32/
Expand Down Expand Up @@ -122,3 +123,6 @@ build-cuberite
# clang-tidy
tidy-build
run-clang-tidy.py

# ctags output
tags
8 changes: 7 additions & 1 deletion COMPILING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ If you're using Git to get the source, use the following command to set up the l
git clone --recursive https://github.com/cuberite/cuberite.git
```

Now that you have the source, it's time to prepare the project files for your favorite compiler. Open a command window in the folder with the source and type in `cmake .` . This will run CMake, it will auto-detect your Visual Studio version and produce the appropriate project and solution files.
Now that you have the source, it's time to prepare the project files for your favorite compiler. Open a command window in the folder with the source and type in:
```
mkdir build
cd build
cmake ..
```
This creates a `build` folder where the build will take place, then runs CMake, which will auto-detect your Visual Studio version and produce the appropriate project and solution files.

Finally, open the newly created file, `Cuberite.sln`, in your Visual Studio.

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ NiLSPACE (formerly STR_Warrior)
npresley0506
p-mcgowan
Persson-dev
plan1231
pokechu22
ProjectBM
pwnOrbitals
Expand Down
4 changes: 2 additions & 2 deletions GETTING-STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Issues that should be easy to get started with are tagged as [easy][6] in GitHub

Other good places to get started are:

- Cleaning up some of the compiler warnings. Check [Travis CI][7] for a list of them.
- Cleaning up some of the compiler warnings. Check [our CI][7] for a list of them.
- Writing some plugins: They are written in lua, with excellent API documentation available via [APIDump][8]. The [Core plugin][9] should also help quite a bit here.

Special Things
Expand All @@ -131,6 +131,6 @@ Special Things
[4]: https://github.com/cuberite/cuberite/blob/master/CONTRIBUTING.md
[5]: https://github.com/cuberite/cuberite/blob/master/COMPILING.md
[6]: https://github.com/cuberite/cuberite/issues?q=is%3Aopen+is%3Aissue+label%3Aeffort%2Feasy
[7]: https://travis-ci.org/cuberite/cuberite
[7]: https://builds.cuberite.org/job/cuberite/job/master/lastSuccessfulBuild/console
[8]: https://api.cuberite.org/
[9]: https://github.com/cuberite/Core
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Cuberite is a Minecraft-compatible multiplayer game server that is written in C++ and designed to be efficient with memory and CPU, as well as having a flexible Lua Plugin API. Cuberite is compatible with the Java Edition Minecraft client.

Cuberite runs on Windows, *nix and Android operating systems. This includes Android phones and tablets as well as Raspberry Pis.
Cuberite runs on Windows, *nix and Android operating systems. This includes Android phones and tablets as well as Raspberry Pis; support for small embedded devices is experimental.

Currently we support Release 1.8 - 1.12.2 Minecraft protocol versions.

Expand Down
23 changes: 15 additions & 8 deletions Server/Plugins/APIDump/APIDesc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2228,18 +2228,21 @@ end
Chaining example below for details.</p>
<p>
Each part of the composite chat message takes a "Style" parameter, this is a string that describes
the formatting. It uses the following strings, concatenated together:
the formatting. It uses the "standard" minecraft format code without the '&' symbole, concatenated
together:
<table>
<tr><th>String</th><th>Style</th></tr>
<tr><td>b</td><td>Bold text</td></tr>
<tr><td>i</td><td>Italic text</td></tr>
<tr><td>u</td><td>Underlined text</td></tr>
<tr><td>s</td><td>Strikethrough text</td></tr>
<tr><td>o</td><td>Obfuscated text</td></tr>
<tr><td>@X</td><td>color [0–9a–f], same as dye meta</td></tr>
<tr><td>l</td><td>Bold text</td></tr>
<tr><td>o</td><td>Italic text</td></tr>
<tr><td>n</td><td>Underlined text</td></tr>
<tr><td>m</td><td>Strikethrough text</td></tr>
<tr><td>k</td><td>Obfuscated text</td></tr>
<tr><td>r</td><td>Reset Style</td></tr>
<tr><td>[0-9a-f]</td><td>colors</td></tr>
</table>
You can escape the '&' character with an antislash in front of it. as follow: `I love Choco\&chips`
The following picture, taken from the Minecraft Wiki, illustrates the color codes:</p>
<img src="http://images.wikia.com/minecraft_gamepedia/images/archive/4/4c/20200824112326!Colors.png" />
<img src="https://static.wikia.nocookie.net/minecraft_gamepedia/images/7/7e/Minecraft_Formatting.gif/revision/latest/scale-to-width-down/292?cb=20200828001454" />
]],
Functions =
{
Expand Down Expand Up @@ -17950,6 +17953,10 @@ end
{
Notes = "A TNT explosion. The SourceData param is the {{cTNTEntity|TNT entity}} object.",
},
esTNTMinecart =
{
Notes = "A TNT minecart explosion. The SourceData param is the {{cMinecartWithTNT|Minecart with TNT entity}} object.",
},
esWitherBirth =
{
Notes = "An explosion at a wither's birth. The SourceData param is the {{cMonster|wither entity}} object.",
Expand Down
2 changes: 1 addition & 1 deletion Server/Plugins/Core
Submodule Core updated 2 files
+2 −2 cmd_scoreboard.lua
+1 −1 core_motd.lua
2 changes: 1 addition & 1 deletion src/Bindings/ManualBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3949,7 +3949,7 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
}

// Add the part:
AString Text, Command, Style = "u@a";
AString Text, Command, Style = "na";
L.GetStackValue(2, Text);
L.GetStackValue(3, Command);
L.GetStackValue(4, Style);
Expand Down
4 changes: 4 additions & 0 deletions src/Bindings/PluginLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// Implements the cPluginLua class representing a plugin written in Lua

#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Defines.h"
#include "Entities/Minecart.h"

#ifdef __APPLE__
#define LUA_USE_MACOSX
Expand Down Expand Up @@ -431,6 +433,7 @@ bool cPluginLua::OnExploded(cWorld & a_World, double a_ExplosionSize, bool a_Can
case esOther: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res); break;
case esPlugin: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res); break;
case esPrimedTNT: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cTNTEntity *> (a_SourceData), cLuaState::Return, res); break;
case esTNTMinecart: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMinecartWithTNT *> (a_SourceData), cLuaState::Return, res); break;
case esWitherBirth: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMonster *> (a_SourceData), cLuaState::Return, res); break;
case esWitherSkull: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cWitherSkullEntity *> (a_SourceData), cLuaState::Return, res); break;
case esMax:
Expand Down Expand Up @@ -471,6 +474,7 @@ bool cPluginLua::OnExploding(cWorld & a_World, double & a_ExplosionSize, bool &
case esOther: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
case esPlugin: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
case esPrimedTNT: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cTNTEntity *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
case esTNTMinecart: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMinecartWithTNT *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
case esWitherBirth: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMonster *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
case esWitherSkull: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cWitherSkullEntity *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
case esMax:
Expand Down
1 change: 0 additions & 1 deletion src/BlockInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class cBlockInfo




bool IsBlockWater(BLOCKTYPE a_BlockType);

bool IsBlockIce(BLOCKTYPE a_BlockType);
Expand Down
37 changes: 36 additions & 1 deletion src/Blocks/BlockButton.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#pragma once

#include "BlockHandler.h"
#include "BlockSlab.h"
#include "BlockStairs.h"
#include "../BlockInfo.h"
#include "../Chunk.h"
#include "Defines.h"
#include "Entities/Player.h"
#include "Mixins.h"
#include "ChunkInterface.h"
#include "World.h"



Expand Down Expand Up @@ -132,7 +137,37 @@ class cBlockButtonHandler final :
return false;
}
BLOCKTYPE SupportBlockType;
a_Chunk.UnboundedRelGetBlockType(SupportRelPos, SupportBlockType);
NIBBLETYPE SupportBlockMeta;
a_Chunk.UnboundedRelGetBlock(SupportRelPos, SupportBlockType, SupportBlockMeta);
eBlockFace Face = BlockMetaDataToBlockFace(a_Meta);

// upside down slabs
if (cBlockSlabHandler::IsAnySlabType(SupportBlockType))
{
return (Face == BLOCK_FACE_YP) && (SupportBlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN);
}

// stairs (top and sides)
if (cBlockStairsHandler::IsAnyStairType(SupportBlockType))
{
switch (Face)
{
case eBlockFace::BLOCK_FACE_YP:
return (SupportBlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN);
case eBlockFace::BLOCK_FACE_XP:
return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_XP);
case eBlockFace::BLOCK_FACE_XM:
return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_XM);
case eBlockFace::BLOCK_FACE_ZP:
return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_ZP);
case eBlockFace::BLOCK_FACE_ZM:
return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_ZM);
default:
{
return false;
}
}
}

return cBlockInfo::FullyOccupiesVoxel(SupportBlockType);
}
Expand Down
17 changes: 11 additions & 6 deletions src/Blocks/BlockComparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,19 @@ class cBlockComparatorHandler final :
{
return true;
}
else if (cBlockSlabHandler::IsAnySlabType(BelowBlock))

// upside down slabs
if (cBlockSlabHandler::IsAnySlabType(BelowBlock))
{
// Check if the slab is turned up side down
if ((BelowBlockMeta & 0x08) == 0x08)
{
return true;
}
return BelowBlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN;
}

// upside down stairs
if (cBlockStairsHandler::IsAnyStairType(BelowBlock))
{
return BelowBlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN;
}

return false;
}

Expand Down
26 changes: 25 additions & 1 deletion src/Blocks/BlockLever.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "BlockHandler.h"
#include "../Chunk.h"
#include "Blocks/BlockStairs.h"
#include "ChunkDef.h"
#include "Defines.h"
#include "Mixins.h"
#include "BlockSlab.h"

Expand Down Expand Up @@ -117,7 +120,28 @@ class cBlockLeverHandler final :
(((NeighborMeta & 0x08) == 0) && (NeighborFace == BLOCK_FACE_BOTTOM))
);
}

else if (cBlockStairsHandler::IsAnyStairType(NeighborBlockType))
{
switch (NeighborFace)
{
case eBlockFace::BLOCK_FACE_YM:
return !(NeighborMeta & E_BLOCK_STAIRS_UPSIDE_DOWN);
case eBlockFace::BLOCK_FACE_YP:
return (NeighborMeta & E_BLOCK_STAIRS_UPSIDE_DOWN);
case eBlockFace::BLOCK_FACE_XP:
return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_XP);
case eBlockFace::BLOCK_FACE_XM:
return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_XM);
case eBlockFace::BLOCK_FACE_ZP:
return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_ZP);
case eBlockFace::BLOCK_FACE_ZM:
return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_ZM);
default:
{
return false;
}
}
}
return false;
}

Expand Down
20 changes: 18 additions & 2 deletions src/Blocks/BlockPressurePlate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#pragma once

#include "BlockHandler.h"
#include "BlockSlab.h"
#include "../Chunk.h"
#include "BlockStairs.h"



Expand All @@ -24,9 +27,22 @@ class cBlockPressurePlateHandler final :
return false;
}

// TODO: check if the block is upside-down slab or upside-down stairs
BLOCKTYPE Block;
NIBBLETYPE BlockMeta;
a_Chunk.GetBlockTypeMeta(a_Position.addedY(-1), Block, BlockMeta);

// upside down slabs
if (cBlockSlabHandler::IsAnySlabType(Block))
{
return BlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN;
}

// upside down stairs
if (cBlockStairsHandler::IsAnyStairType(Block))
{
return BlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN;
}

const auto Block = a_Chunk.GetBlock(a_Position.addedY(-1));
switch (Block)
{
case E_BLOCK_ACACIA_FENCE:
Expand Down
30 changes: 28 additions & 2 deletions src/Blocks/BlockRail.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

#pragma once

#include "BlockHandler.h"
#include "BlockSlab.h"
#include "BlockStairs.h"
#include "BlockType.h"
#include "Blocks/Mixins.h"
#include "../BlockInfo.h"
#include "../Chunk.h"
#include "ChunkDef.h"




Expand Down Expand Up @@ -154,9 +162,26 @@ class cBlockRailHandler final :

private:

static bool CanBeSupportedBy(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
if (cBlockSlabHandler::IsAnySlabType(a_BlockType))
{
return (a_BlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN);
}
else if (cBlockStairsHandler::IsAnyStairType(a_BlockType))
{
return (a_BlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN);
}
return cBlockInfo::FullyOccupiesVoxel(a_BlockType);
}

virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, NIBBLETYPE a_Meta) const override
{
if ((a_Position.y <= 0) || !cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_Position.addedY(-1))))
BLOCKTYPE BelowBlock;
NIBBLETYPE BelowBlockMeta;
a_Chunk.GetBlockTypeMeta(a_Position.addedY(-1), BelowBlock, BelowBlockMeta);

if ((a_Position.y <= 0) || !CanBeSupportedBy(BelowBlock, BelowBlockMeta))
{
return false;
}
Expand Down Expand Up @@ -187,6 +212,7 @@ class cBlockRailHandler final :
return cBlockInfo::FullyOccupiesVoxel(BlockType);
}
}

return true;
}

Expand Down
19 changes: 13 additions & 6 deletions src/Blocks/BlockRedstoneRepeater.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#pragma once

#include "BlockHandler.h"
#include "BlockType.h"
#include "Mixins.h"
#include "ChunkInterface.h"
#include "BlockSlab.h"
#include "BlockStairs.h"
#include "../Chunk.h"


Expand Down Expand Up @@ -120,14 +122,19 @@ class cBlockRedstoneRepeaterHandler final :
{
return true;
}
else if (cBlockSlabHandler::IsAnySlabType(BelowBlock))

// upside down slabs
if (cBlockSlabHandler::IsAnySlabType(BelowBlock))
{
// Check if the slab is turned up side down
if ((BelowBlockMeta & 0x08) == 0x08)
{
return true;
}
return BelowBlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN;
}

// upside down stairs
if (cBlockStairsHandler::IsAnyStairType(BelowBlock))
{
return BelowBlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN;
}

return false;
}

Expand Down

0 comments on commit c16f294

Please sign in to comment.