mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-13 04:33:52 +00:00
finish rewrite; port to cmake, loads of other changes
Theres documentation at https://sylvessa.zip/fourkit/ now. And a bunch of other changes. Check the discord server for a more comprehensive list
This commit is contained in:
parent
ecb3f00bd6
commit
f5f9aa1cf5
107 changed files with 14289 additions and 40 deletions
|
|
@ -10,9 +10,16 @@
|
|||
#include "..\Minecraft.World\net.minecraft.world.level.h"
|
||||
#include "..\Minecraft.World\net.minecraft.world.level.chunk.h"
|
||||
#include "..\Minecraft.World\net.minecraft.world.level.dimension.h"
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include "..\Minecraft.World\EnchantmentHelper.h"
|
||||
#include "..\Minecraft.World\ExperienceOrb.h"
|
||||
#include "..\Minecraft.Server\FourKitBridge.h"
|
||||
#endif
|
||||
#include "MultiPlayerLevel.h"
|
||||
#include "LevelRenderer.h"
|
||||
|
||||
extern bool g_suppressExpDrops;
|
||||
|
||||
ServerPlayerGameMode::ServerPlayerGameMode(Level *level)
|
||||
{
|
||||
// 4J - added initialisers
|
||||
|
|
@ -247,7 +254,44 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
|
|||
|
||||
int t = level->getTile(x, y, z);
|
||||
int data = level->getData(x, y, z);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
int eventExp = 0;
|
||||
if (!isCreative() && !gameModeForPlayer->isAdventureRestricted())
|
||||
{
|
||||
Tile *tile = Tile::tiles[t];
|
||||
if (tile != nullptr && player->canDestroy(tile))
|
||||
{
|
||||
if (!EnchantmentHelper::hasSilkTouch(player))
|
||||
{
|
||||
// todo: shouldnt we get these values from the actual blocks?
|
||||
if (t == Tile::coalOre_Id)
|
||||
eventExp = Mth::nextInt(level->random, 0, 2);
|
||||
else if (t == Tile::diamondOre_Id)
|
||||
eventExp = Mth::nextInt(level->random, 3, 7);
|
||||
else if (t == Tile::emeraldOre_Id)
|
||||
eventExp = Mth::nextInt(level->random, 3, 7);
|
||||
else if (t == Tile::lapisOre_Id)
|
||||
eventExp = Mth::nextInt(level->random, 2, 5);
|
||||
else if (t == Tile::netherQuartz_Id)
|
||||
eventExp = Mth::nextInt(level->random, 2, 5);
|
||||
else if (t == Tile::redStoneOre_Id || t == Tile::redStoneOre_lit_Id)
|
||||
eventExp = 1 + level->random->nextInt(5);
|
||||
else if (t == Tile::mobSpawner_Id)
|
||||
eventExp = 15 + level->random->nextInt(15) + level->random->nextInt(15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int dimId = level->dimension ? level->dimension->id : 0;
|
||||
int breakResult = FourKitBridge::FireBlockBreak(player->entityId, dimId, x, y, z, t, data, eventExp);
|
||||
if (breakResult < 0)
|
||||
{
|
||||
// Cancelled: send block correction to client
|
||||
player->connection->send(std::make_shared<TileUpdatePacket>(x, y, z, level));
|
||||
return false;
|
||||
}
|
||||
int finalExp = breakResult;
|
||||
#endif
|
||||
level->levelEvent(player, LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, t + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||
|
||||
// 4J - In creative mode, the point where we need to tell the renderer that we are about to destroy a tile via destroyingTileAt is quite complicated.
|
||||
|
|
@ -305,8 +349,25 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
|
|||
}
|
||||
}
|
||||
if (changed && canDestroy)
|
||||
{
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
g_suppressExpDrops = true;
|
||||
#endif
|
||||
|
||||
Tile::tiles[t]->playerDestroy(level, player, x, y, z, data);
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
g_suppressExpDrops = false;
|
||||
if (finalExp > 0)
|
||||
{
|
||||
while (finalExp > 0)
|
||||
{
|
||||
int xpDrop = ExperienceOrb::getExperienceValue(finalExp);
|
||||
finalExp -= xpDrop;
|
||||
level->addEntity(std::make_shared<ExperienceOrb>(level, x + .5, y + .5, z + .5, xpDrop));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue