mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-21 17:23:56 +01:00
TU46 Test content, added missing commits by amending commit and cherry-picking to new branch, ready for iggy guis and tu46 bug fixes
112 lines
3.2 KiB
C++
112 lines
3.2 KiB
C++
#include "stdafx.h"
|
|
#include "ThinFenceTile.h"
|
|
#include "net.minecraft.world.level.h"
|
|
#include "net.minecraft.world.h"
|
|
|
|
ThinFenceTile::ThinFenceTile(int id, const wstring &tex, const wstring &edgeTex, Material *material, bool dropsResources) : Tile(id, material,isSolidRender())
|
|
{
|
|
setLightBlock(0);
|
|
iconSide = nullptr;
|
|
edgeTexture = edgeTex;
|
|
this->dropsResources = dropsResources;
|
|
this->texture = tex;
|
|
}
|
|
|
|
int ThinFenceTile::getResource(int data, Random *random, int playerBonusLevel)
|
|
{
|
|
if (!dropsResources)
|
|
{
|
|
return 0;
|
|
}
|
|
return Tile::getResource(data, random, playerBonusLevel);
|
|
}
|
|
|
|
bool ThinFenceTile::isSolidRender(bool isServerLevel)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool ThinFenceTile::isCubeShaped()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int ThinFenceTile::getRenderShape()
|
|
{
|
|
return material == Material::glass ? Tile::SHAPE_THIN_PANE : Tile::SHAPE_IRON_FENCE;
|
|
}
|
|
|
|
bool ThinFenceTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
|
|
{
|
|
int id = level->getTile(x, y, z);
|
|
if (id == this->id) return false;
|
|
return Tile::shouldRenderFace(level, x, y, z, face);
|
|
}
|
|
|
|
void ThinFenceTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
|
|
{
|
|
bool n = attachsTo(level->getTile(x, y, z - 1));
|
|
bool s = attachsTo(level->getTile(x, y, z + 1));
|
|
bool w = attachsTo(level->getTile(x - 1, y, z));
|
|
bool e = attachsTo(level->getTile(x + 1, y, z));
|
|
|
|
const float lo = 7.0f / 16.0f;
|
|
const float hi = 9.0f / 16.0f;
|
|
setShape(lo, 0, lo, hi, 1, hi);
|
|
Tile::addAABBs(level, x, y, z, box, boxes, source);
|
|
if (n) { setShape(lo, 0, 0, hi, 1, hi); Tile::addAABBs(level, x, y, z, box, boxes, source); }
|
|
if (s) { setShape(lo, 0, lo, hi, 1, 1); Tile::addAABBs(level, x, y, z, box, boxes, source); }
|
|
if (w) { setShape(0, 0, lo, hi, 1, hi); Tile::addAABBs(level, x, y, z, box, boxes, source); }
|
|
if (e) { setShape(lo, 0, lo, 1, 1, hi); Tile::addAABBs(level, x, y, z, box, boxes, source); }
|
|
}
|
|
|
|
void ThinFenceTile::updateDefaultShape()
|
|
{
|
|
setShape(0, 0, 0, 1, 1, 1);
|
|
}
|
|
|
|
void ThinFenceTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
|
|
{
|
|
float minX = 7.0f / 16.0f;
|
|
float maxX = 9.0f / 16.0f;
|
|
float minZ = 7.0f / 16.0f;
|
|
float maxZ = 9.0f / 16.0f;
|
|
|
|
bool n = attachsTo(level->getTile(x, y, z - 1));
|
|
bool s = attachsTo(level->getTile(x, y, z + 1));
|
|
bool w = attachsTo(level->getTile(x - 1, y, z));
|
|
bool e = attachsTo(level->getTile(x + 1, y, z));
|
|
|
|
if (w) minX = 0;
|
|
if (e) maxX = 1;
|
|
if (n) minZ = 0;
|
|
if (s) maxZ = 1;
|
|
setShape(minX, 0, minZ, maxX, 1, maxZ);
|
|
}
|
|
|
|
Icon *ThinFenceTile::getEdgeTexture()
|
|
{
|
|
return iconSide;
|
|
}
|
|
|
|
bool ThinFenceTile::attachsTo(int tile)
|
|
{
|
|
return Tile::solid[tile] || tile == id || tile == Tile::glass_Id || tile == Tile::stained_glass_Id || tile == Tile::stained_glass_pane_Id;
|
|
}
|
|
|
|
bool ThinFenceTile::isSilkTouchable()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
shared_ptr<ItemInstance> ThinFenceTile::getSilkTouchItemInstance(int data)
|
|
{
|
|
return std::make_shared<ItemInstance>(id, 1, data);
|
|
}
|
|
|
|
void ThinFenceTile::registerIcons(IconRegister *iconRegister)
|
|
{
|
|
icon = iconRegister->registerIcon(texture);
|
|
iconSide = iconRegister->registerIcon(edgeTexture);
|
|
}
|