mirror of
https://github.com/BluTac10/Xbox-Neo.git
synced 2026-07-19 15:38:16 +00:00
Merge branch 'main-re' into upstream-merge
This commit is contained in:
@@ -10,9 +10,18 @@
|
||||
#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
|
||||
@@ -171,7 +180,7 @@ void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face)
|
||||
}
|
||||
}
|
||||
|
||||
bool ServerPlayerGameMode::stopDestroyBlock(int x, int y, int z)
|
||||
void ServerPlayerGameMode::stopDestroyBlock(int x, int y, int z)
|
||||
{
|
||||
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock)
|
||||
{
|
||||
@@ -187,7 +196,6 @@ bool ServerPlayerGameMode::stopDestroyBlock(int x, int y, int z)
|
||||
isDestroyingBlock = false;
|
||||
level->destroyTileProgress(player->entityId, x, y, z, -1);
|
||||
destroyBlock(x, y, z);
|
||||
return true;
|
||||
}
|
||||
else if (!hasDelayedDestroy)
|
||||
{
|
||||
@@ -198,11 +206,9 @@ bool ServerPlayerGameMode::stopDestroyBlock(int x, int y, int z)
|
||||
delayedDestroyY = y;
|
||||
delayedDestroyZ = z;
|
||||
delayedTickStart = destroyProgressStart;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServerPlayerGameMode::abortDestroyBlock(int x, int y, int z)
|
||||
@@ -249,7 +255,43 @@ 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))
|
||||
{
|
||||
// (SYLV)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)
|
||||
{
|
||||
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.
|
||||
@@ -307,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;
|
||||
|
||||
Reference in New Issue
Block a user