4jcraft/Minecraft.World/Blocks/WoolCarpetTile.cpp
Nikita Edel a006cc5aa0 uninitialized vptr
the vptr to isSolidRender() is not known before contruction of the Tile. Its true by default. if false, need to pass false. that is what i did. i verfied what isSolidRender() is in every file. and did exactly what isSolidRender() would return
2026-03-10 23:22:34 +01:00

112 lines
2.6 KiB
C++

#include "../Platform/stdafx.h"
#include "../Headers/net.minecraft.world.phys.h"
#include "../Headers/net.minecraft.world.level.h"
#include "../Util/SharedConstants.h"
#include "WoolCarpetTile.h"
WoolCarpetTile::WoolCarpetTile(int id) : Tile(id, Material::clothDecoration, false)
{
setShape(0, 0, 0, 1, 1 / 16.0f, 1);
setTicking(true);
updateShape(0);
}
Icon *WoolCarpetTile::getTexture(int face, int data)
{
return Tile::cloth->getTexture(face, data);
}
AABB *WoolCarpetTile::getAABB(Level *level, int x, int y, int z)
{
int height = 0;
float offset = 1.0f / SharedConstants::WORLD_RESOLUTION;
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1);
}
bool WoolCarpetTile::blocksLight()
{
return false;
}
bool WoolCarpetTile::isSolidRender(bool isServerLevel)
{
return false;
}
bool WoolCarpetTile::isCubeShaped()
{
return false;
}
void WoolCarpetTile::updateDefaultShape()
{
updateShape(0);
}
void WoolCarpetTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, std::shared_ptr<TileEntity> forceEntity)
{
updateShape(level->getData(x, y, z));
}
void WoolCarpetTile::updateShape(int data)
{
int height = 0;
float o = 1 * (1 + height) / 16.0f;
setShape(0, 0, 0, 1, o, 1);
}
bool WoolCarpetTile::mayPlace(Level *level, int x, int y, int z)
{
return Tile::mayPlace(level, x, y, z) && canSurvive(level, x, y, z);
}
void WoolCarpetTile::neighborChanged(Level *level, int x, int y, int z, int type)
{
checkCanSurvive(level, x, y, z);
}
bool WoolCarpetTile::checkCanSurvive(Level *level, int x, int y, int z)
{
if (!canSurvive(level, x, y, z))
{
spawnResources(level, x, y, z, level->getData(x, y, z), 0);
level->setTile(x, y, z, 0);
return false;
}
return true;
}
bool WoolCarpetTile::canSurvive(Level *level, int x, int y, int z)
{
return !level->isEmptyTile(x, y - 1, z);
}
bool WoolCarpetTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{
if (face == 1) return true;
return Tile::shouldRenderFace(level, x, y, z, face);
}
int WoolCarpetTile::getSpawnResourcesAuxValue(int data)
{
return data;
}
int WoolCarpetTile::getTileDataForItemAuxValue(int auxValue)
{
return (~auxValue & 0xf);
}
int WoolCarpetTile::getItemAuxValueForTileData(int data)
{
return (~data & 0xf);
}
void WoolCarpetTile::registerIcons(IconRegister *iconRegister)
{
// None, delegates to cloth tile
}