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
239 lines
6.9 KiB
C++
239 lines
6.9 KiB
C++
#include "stdafx.h"
|
|
#include "com.mojang.nbt.h"
|
|
#include "net.minecraft.world.h"
|
|
#include "net.minecraft.world.level.h"
|
|
#include "net.minecraft.world.entity.h"
|
|
#include "net.minecraft.world.entity.item.h"
|
|
#include "net.minecraft.world.entity.player.h"
|
|
#include "net.minecraft.world.item.h"
|
|
#include "net.minecraft.world.inventory.h"
|
|
#include "net.minecraft.world.phys.h"
|
|
#include "Facing.h"
|
|
#include "ShulkerBoxTileEntity.h"
|
|
#include "ShulkerBoxTile.h"
|
|
|
|
ShulkerBoxTile::ShulkerBoxTile(int id, int color) : BaseEntityTile(id, Material::stone, false)
|
|
{
|
|
this->color = color;
|
|
}
|
|
|
|
static const int SHULKER_BOX_TILE_RGB[16] =
|
|
{
|
|
0xFFFFFF, 0xFF760B, 0xC341B6, 0x31A9E2, 0xFFC02B, 0x74C218, 0xF589A9, 0x4B4F52,
|
|
0x999991, 0x22919C, 0x9B6E9B, 0x3537A4, 0x7C4C29, 0x5F7928, 0xA81513, 0x2A2A2F
|
|
};
|
|
|
|
void ShulkerBoxTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity)
|
|
{
|
|
shared_ptr<ShulkerBoxTileEntity> box = dynamic_pointer_cast<ShulkerBoxTileEntity>(forceEntity);
|
|
if (box == nullptr && level != nullptr)
|
|
box = dynamic_pointer_cast<ShulkerBoxTileEntity>(level->getTileEntity(x, y, z));
|
|
float grow = box != nullptr ? 0.5f * box->getProgress(1.0f) : 0.0f;
|
|
int data = forceData >= 0 ? forceData : (level != nullptr ? level->getData(x, y, z) : 1);
|
|
int facing = data % 6;
|
|
float x0 = 0.0f, y0 = 0.0f, z0 = 0.0f, x1 = 1.0f, y1 = 1.0f, z1 = 1.0f;
|
|
if (Facing::STEP_X[facing] > 0) x1 += grow; else if (Facing::STEP_X[facing] < 0) x0 -= grow;
|
|
if (Facing::STEP_Y[facing] > 0) y1 += grow; else if (Facing::STEP_Y[facing] < 0) y0 -= grow;
|
|
if (Facing::STEP_Z[facing] > 0) z1 += grow; else if (Facing::STEP_Z[facing] < 0) z0 -= grow;
|
|
setShape(x0, y0, z0, x1, y1, z1);
|
|
}
|
|
|
|
AABB *ShulkerBoxTile::getAABB(Level *level, int x, int y, int z)
|
|
{
|
|
updateShape(level, x, y, z);
|
|
return BaseEntityTile::getAABB(level, x, y, z);
|
|
}
|
|
|
|
AABB *ShulkerBoxTile::getTileAABB(Level *level, int x, int y, int z)
|
|
{
|
|
updateShape(level, x, y, z);
|
|
return BaseEntityTile::getTileAABB(level, x, y, z);
|
|
}
|
|
|
|
int ShulkerBoxTile::getDyeColor()
|
|
{
|
|
return color;
|
|
}
|
|
|
|
int ShulkerBoxTile::getBoxRGB()
|
|
{
|
|
return SHULKER_BOX_TILE_RGB[color & 15];
|
|
}
|
|
|
|
int ShulkerBoxTile::getColor(int auxData)
|
|
{
|
|
return getBoxRGB();
|
|
}
|
|
|
|
int ShulkerBoxTile::getColor(LevelSource *level, int x, int y, int z)
|
|
{
|
|
return getBoxRGB();
|
|
}
|
|
|
|
int ShulkerBoxTile::getColor(LevelSource *level, int x, int y, int z, int data)
|
|
{
|
|
return getBoxRGB();
|
|
}
|
|
|
|
bool ShulkerBoxTile::isSolidRender(bool isServerLevel)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool ShulkerBoxTile::isCubeShaped()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int ShulkerBoxTile::getRenderShape()
|
|
{
|
|
return Tile::SHAPE_ENTITYTILE_ANIMATED;
|
|
}
|
|
|
|
shared_ptr<TileEntity> ShulkerBoxTile::newTileEntity(Level *level)
|
|
{
|
|
return std::make_shared<ShulkerBoxTileEntity>(color);
|
|
}
|
|
|
|
bool ShulkerBoxTile::TestUse()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool ShulkerBoxTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly)
|
|
{
|
|
if (soundOnly) return true;
|
|
if (level->isClientSide) return true;
|
|
if (player->isSpectator()) return true;
|
|
|
|
shared_ptr<ShulkerBoxTileEntity> box = dynamic_pointer_cast<ShulkerBoxTileEntity>(level->getTileEntity(x, y, z));
|
|
if (box == nullptr) return false;
|
|
|
|
bool canOpen = true;
|
|
if (box->getAnimationStatus() == ShulkerBoxTileEntity::ANIMATION_CLOSED)
|
|
{
|
|
int facing = level->getData(x, y, z) % 6;
|
|
int sx = Facing::STEP_X[facing];
|
|
int sy = Facing::STEP_Y[facing];
|
|
int sz = Facing::STEP_Z[facing];
|
|
double nx = x + sx;
|
|
double ny = y + sy;
|
|
double nz = z + sz;
|
|
double x0 = nx, y0 = ny, z0 = nz, x1 = nx + 1, y1 = ny + 1, z1 = nz + 1;
|
|
if (sx > 0) x1 = nx + 0.5; else if (sx < 0) x0 = nx + 0.5;
|
|
if (sy > 0) y1 = ny + 0.5; else if (sy < 0) y0 = ny + 0.5;
|
|
if (sz > 0) z1 = nz + 0.5; else if (sz < 0) z0 = nz + 0.5;
|
|
AABBList *cubes = level->getCubes(nullptr, AABB::newTemp(x0 + 0.001, y0 + 0.001, z0 + 0.001, x1 - 0.001, y1 - 0.001, z1 - 0.001), true);
|
|
canOpen = cubes == nullptr || cubes->empty();
|
|
if (canOpen)
|
|
{
|
|
vector<shared_ptr<Entity> > *onTop = level->getEntitiesOfClass(typeid(LivingEntity), AABB::newTemp(x0, y0, z0, x1, y1, z1));
|
|
if (onTop != nullptr)
|
|
{
|
|
canOpen = onTop->empty();
|
|
delete onTop;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (canOpen)
|
|
{
|
|
player->openContainer(box);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int ShulkerBoxTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue)
|
|
{
|
|
return face;
|
|
}
|
|
|
|
void ShulkerBoxTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance)
|
|
{
|
|
shared_ptr<ShulkerBoxTileEntity> box = dynamic_pointer_cast<ShulkerBoxTileEntity>(level->getTileEntity(x, y, z));
|
|
if (box == nullptr || itemInstance == nullptr) return;
|
|
|
|
if (itemInstance->hasTag())
|
|
{
|
|
CompoundTag *tag = itemInstance->getTag();
|
|
if (tag->contains(L"BlockEntityTag"))
|
|
{
|
|
box->loadContents(tag->getCompound(L"BlockEntityTag"));
|
|
}
|
|
}
|
|
if (itemInstance->hasCustomHoverName())
|
|
{
|
|
box->setCustomName(itemInstance->getHoverName());
|
|
}
|
|
box->setChanged();
|
|
}
|
|
|
|
void ShulkerBoxTile::playerWillDestroy(Level *level, int x, int y, int z, int data, shared_ptr<Player> player)
|
|
{
|
|
shared_ptr<ShulkerBoxTileEntity> box = dynamic_pointer_cast<ShulkerBoxTileEntity>(level->getTileEntity(x, y, z));
|
|
if (box != nullptr)
|
|
{
|
|
box->setDestroyedByCreativePlayer(player->abilities.instabuild);
|
|
}
|
|
BaseEntityTile::playerWillDestroy(level, x, y, z, data, player);
|
|
}
|
|
|
|
void ShulkerBoxTile::onRemove(Level *level, int x, int y, int z, int id, int data)
|
|
{
|
|
shared_ptr<ShulkerBoxTileEntity> box = dynamic_pointer_cast<ShulkerBoxTileEntity>(level->getTileEntity(x, y, z));
|
|
if (box != nullptr && !level->isClientSide)
|
|
{
|
|
if (!box->isCleared() && box->shouldDrop())
|
|
{
|
|
shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(this->id, 1, 0);
|
|
if (!box->isEmpty())
|
|
{
|
|
CompoundTag *entityTag = new CompoundTag();
|
|
box->saveContents(entityTag);
|
|
entityTag->remove(L"CustomName");
|
|
CompoundTag *rootTag = new CompoundTag();
|
|
rootTag->putCompound(L"BlockEntityTag", entityTag);
|
|
item->setTag(rootTag);
|
|
}
|
|
if (box->hasCustomName())
|
|
{
|
|
item->setHoverName(box->getCustomName());
|
|
}
|
|
popResource(level, x, y, z, item);
|
|
}
|
|
box->clearContent();
|
|
level->updateNeighbourForOutputSignal(x, y, z, id);
|
|
}
|
|
BaseEntityTile::onRemove(level, x, y, z, id, data);
|
|
}
|
|
|
|
int ShulkerBoxTile::getResourceCount(Random *random)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int ShulkerBoxTile::getPistonPushReaction()
|
|
{
|
|
return Material::PUSH_DESTROY;
|
|
}
|
|
|
|
bool ShulkerBoxTile::hasAnalogOutputSignal()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
int ShulkerBoxTile::getAnalogOutputSignal(Level *level, int x, int y, int z, int dir)
|
|
{
|
|
return AbstractContainerMenu::getRedstoneSignalFromContainer(dynamic_pointer_cast<Container>(level->getTileEntity(x, y, z)));
|
|
}
|
|
|
|
int ShulkerBoxTile::cloneTileData(Level *level, int x, int y, int z)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void ShulkerBoxTile::registerIcons(IconRegister *iconRegister)
|
|
{
|
|
icon = iconRegister->registerIcon(L"shulker_top");
|
|
}
|