mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-26 21:26:38 +01:00
Patch Notes: Blocks + Colored shulker boxes + Concrete powder + Concrete + Glazed terracotta Items + Shulker shell + Iron nugget UI Changes + Added Custom Controls to Keyboard & Mouse, as well as Controller + Added Custom SuperFlat + Added Edit Server Menu + Added Firework Crafting Feature Changes + Host Options + Added Pick Block + Added off-hand slot for maps and arrows. Bug Fixes & changes + TU47: Banner hitbox wrong (and inventory model fixed) + TU47/48: Ice not melting properly + TU48: Dead bushes not dropping sticks + TU48: Guardians and polar bears not dropping cooked fish when on fire + TU48: Bonus chest missing saplings and seeds + TU48: Frosted ice obtainable + TU48: Hoppers not collecting items + TU48: Wither skeletons spawning in 2-high gaps + TU48: End crystals exploding with “TNT Explodes” off + TU48: Tamed ocelots staying hostile + TU48: Signs not placing on tall grass + TU51: Skeleton hitbox wrong + TU53: Fall damage in shallow water + TU53: Squids not spawning in man-made pools + Elytra has been improved to be more accurate to the source material + Removed Spectral Arrow from crafting + Fixed several broken item descriptions + You can no longer cook Pufferfish or Clownfish + Fixed scaling issue with paperdoll and chat + Iron and gold armor can now be smelted into nuggets. + More items can now be used as fuel in a furnace. + Using a firework rocket while gliding with elytra will now give the player a boost. + Changed the color of dyes, wool, carpets, and banners. + Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items. + Fishing rods can now hook on entities without causing knockback or pseudo-damage. + Fixed banner crafting + Fixed Map colors for certain blocks + Fixed Path block height + Fixed String block issues + Fixed Item frame culling. + Fixed Tutorial world NBT/Block State issues + Fixed World Slider + Fixed Enderman AI + Fixed Player animation bug + HUD Flash text changes + Generation accuracy changes + Many other small accuracy changes and fixes
103 lines
3.7 KiB
C++
103 lines
3.7 KiB
C++
#include "stdafx.h"
|
|
#include "BonusChestFeature.h"
|
|
#include "net.minecraft.world.level.h"
|
|
#include "net.minecraft.world.level.tile.h"
|
|
#include "net.minecraft.world.level.tile.entity.h"
|
|
#include "LootTableManager.h"
|
|
#include "WeighedTreasure.h"
|
|
#include "StructurePiece.h"
|
|
|
|
BonusChestFeature::BonusChestFeature(const std::string &lootTableName) : lootTableName(lootTableName)
|
|
{
|
|
}
|
|
|
|
// 4J - original virtual method
|
|
bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z)
|
|
{
|
|
return place(level, random, x, y, z, false);
|
|
}
|
|
|
|
// 4J - added force parameter - trying to keep this as similar as possible to the original algorithm, but would also like it to definitely place a
|
|
// chest as it doesn't necessarily find somewhere in the original java. This method is called multple times for different x,y,z round the
|
|
// spawn point and force signifies that this is the last time this will be called. In this case, just place the chest exactly where the input
|
|
// parameters requested we place it (we know this will be one tile above the top solid block of a randomn column), and then do our best to place
|
|
// any surrounding torches where appropriate.
|
|
|
|
bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z, bool force)
|
|
{
|
|
// check if level is corrupted first
|
|
if (level == nullptr || random == nullptr)
|
|
{
|
|
return false;
|
|
}
|
|
if (!level->isNew) return false;
|
|
//Will only spawn a bonus chest if the world is new and has never been saved.
|
|
if (level->isNew)
|
|
{
|
|
if (!force)
|
|
{
|
|
int t = 0;
|
|
while (((t = level->getTile(x, y, z)) == 0 || t == Tile::leaves_Id) && y > 1)
|
|
y--;
|
|
|
|
if (y < 1)
|
|
{
|
|
return false;
|
|
}
|
|
y++;
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
int x2, y2, z2;
|
|
|
|
if (force)
|
|
{
|
|
x2 = x;
|
|
y2 = y - 1; // 4J - the position passed in is actually two above the top solid block, as the calling function adds 1 to getTopSolidBlock, and that actually returns the block above anyway.
|
|
// this would explain why there is a while loop above here (not used in force mode) to move the y back down again, shouldn't really be needed if 1 wasn't added to the getTopSolidBlock return value.
|
|
z2 = z;
|
|
}
|
|
else
|
|
{
|
|
x2 = x + random->nextInt(4) - random->nextInt(4);
|
|
y2 = y + random->nextInt(3) - random->nextInt(3);
|
|
z2 = z + random->nextInt(4) - random->nextInt(4);
|
|
}
|
|
|
|
if (force || (level->isEmptyTile(x2, y2, z2) && level->isTopSolidBlocking(x2, y2 - 1, z2)))
|
|
{
|
|
level->setTileAndData(x2, y2, z2, Tile::chest_Id, 0, Tile::UPDATE_CLIENTS);
|
|
shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(level->getTileEntity(x2, y2, z2));
|
|
if (chest != nullptr)
|
|
{
|
|
std::vector<LootTableDropResult> drops = LootTableManager::Get().ResolveDrops(
|
|
lootTableName, false, 0,
|
|
[random](int bound) { return random->nextInt(bound); });
|
|
WeighedTreasure::addChestItems(random, drops, chest);
|
|
chest->isBonusChest = true; // 4J added
|
|
}
|
|
if (level->isEmptyTile(x2 - 1, y2, z2) && level->isTopSolidBlocking(x2 - 1, y2 - 1, z2))
|
|
{
|
|
level->setTileAndData(x2 - 1, y2, z2, Tile::torch_Id, 0, Tile::UPDATE_CLIENTS);
|
|
}
|
|
if (level->isEmptyTile(x2 + 1, y2, z2) && level->isTopSolidBlocking(x2 + 1, y2 - 1, z2))
|
|
{
|
|
level->setTileAndData(x2 + 1, y2, z2, Tile::torch_Id, 0, Tile::UPDATE_CLIENTS);
|
|
}
|
|
if (level->isEmptyTile(x2, y2, z2 - 1) && level->isTopSolidBlocking(x2, y2 - 1, z2 - 1))
|
|
{
|
|
level->setTileAndData(x2, y2, z2 - 1, Tile::torch_Id, 0, Tile::UPDATE_CLIENTS);
|
|
}
|
|
if (level->isEmptyTile(x2, y2, z2 + 1) && level->isTopSolidBlocking(x2, y2 - 1, z2 + 1))
|
|
{
|
|
level->setTileAndData(x2, y2, z2 + 1, Tile::torch_Id, 0, Tile::UPDATE_CLIENTS);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|