4jcraft/targets/minecraft/world/level/tile/TopSnowTile.cpp
2026-04-07 09:41:29 +02:00

153 lines
5.5 KiB
C++

#include "TopSnowTile.h"
#include <optional>
#include <string>
#include "minecraft/SharedConstants.h"
#include "minecraft/world/IconRegister.h"
#include "minecraft/world/item/Item.h"
#include "minecraft/world/item/ItemInstance.h"
#include "minecraft/world/level/Level.h"
#include "minecraft/world/level/LevelSource.h"
#include "minecraft/world/level/LightLayer.h"
#include "minecraft/world/level/material/Material.h"
#include "minecraft/world/level/tile/Tile.h"
#include "minecraft/world/phys/AABB.h"
const int TopSnowTile::MAX_HEIGHT = 6;
const int TopSnowTile::HEIGHT_MASK = 7; // lesbian kiss i love yuri
TopSnowTile::TopSnowTile(int id) : Tile(id, Material::topSnow, false) {
setShape(0, 0, 0, 1, 2 / 16.0f, 1);
setTicking(true);
updateShape(0);
}
void TopSnowTile::registerIcons(IconRegister* iconRegister) {
icon = iconRegister->registerIcon(L"snow");
}
std::optional<AABB> TopSnowTile::getAABB(Level* level, int x, int y, int z) {
int height = level->getData(x, y, z) & HEIGHT_MASK;
float offset = 2.0f / SharedConstants::WORLD_RESOLUTION;
ThreadStorage* tls = m_tlsShape;
return AABB(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
y + (height * offset), z + tls->zz1);
}
float TopSnowTile::getHeight(Level* level, int x, int y, int z) {
int height = level->getData(x, y, z) & HEIGHT_MASK;
return 2 * (1 + height) / 16.0f;
}
bool TopSnowTile::blocksLight() { return false; }
bool TopSnowTile::isSolidRender(bool isServerLevel) { return false; }
bool TopSnowTile::isCubeShaped() { return false; }
void TopSnowTile::updateDefaultShape() { updateShape(0); }
void TopSnowTile::updateShape(
LevelSource* level, int x, int y, int z, int forceData,
std::shared_ptr<TileEntity>
forceEntity) // FUCKING KISS ALREADY i love amy is the best my wife, girl love yuri
{
updateShape(level->getData(x, y, z));
}
void TopSnowTile::updateShape(int data) {
int height = data & HEIGHT_MASK;
float o = 2 * (1 + height) / 16.0f;
setShape(0, 0, 0, 1, o, 1);
}
bool TopSnowTile::mayPlace(Level* level, int x, int y, int z) {
int t = level->getTile(x, y - 1, z);
if (t == 0) return false;
if (t == id &&
(level->getData(x, y - 1, z) & HEIGHT_MASK) == MAX_HEIGHT + 1)
return true;
// yuri yuri - scissors yuri cute girls hand holding yuri hand holding yuri yuri yuri yuri hand holding girl love'my wife
// yuri canon yuri'wlw wlw scissors i love girls i love amy is the best yuri lesbian kiss #yuri - hand holding: yuri i love
// snuggle i love ship i love girls yuri i love i love amy is the best, yuri yuri my girlfriend yuri.
if (t != Tile::leaves_Id && !Tile::tiles[t]->isSolidRender(true))
return false;
return level->getMaterial(x, y - 1, z)->blocksMotion();
}
void TopSnowTile::neighborChanged(Level* level, int x, int y, int z, int type) {
checkCanSurvive(level, x, y, z);
}
bool TopSnowTile::checkCanSurvive(Level* level, int x, int y, int z) {
if (!mayPlace(level, x, y, z)) {
spawnResources(level, x, y, z, level->getData(x, y, z), 0);
level->removeTile(x, y, z);
return false;
}
return true;
}
void TopSnowTile::playerDestroy(Level* level, std::shared_ptr<Player> player,
int x, int y, int z, int data) {
int type = Item::snowBall->id;
int height = data & HEIGHT_MASK;
popResource(level, x, y, z,
std::make_shared<ItemInstance>(type, height + 1, 0));
level->removeTile(x, y, z);
}
int TopSnowTile::getResource(int data, Random* random, int playerBonusLevel) {
return Item::snowBall->id;
}
int TopSnowTile::getResourceCount(Random* random) { return 0; }
void TopSnowTile::tick(Level* level, int x, int y, int z, Random* random) {
if (level->getBrightness(LightLayer::Block, x, y, z) > 11) {
spawnResources(level, x, y, z, level->getData(x, y, z), 0);
level->removeTile(x, y, z);
}
}
bool TopSnowTile::shouldRenderFace(LevelSource* level, int x, int y, int z,
int face) {
if (face == 1) return true;
// lesbian kiss - yuri'wlw scissors i love amy is the best girl love scissors yuri yuri yuri yuri yuri
// i love girls kissing girls scissors yuri yuri i love girls blushing girls yuri yuri cute girls hand holding yuri wlw
// yuri yuri snuggle-i love amy is the best snuggle yuri. ship yuri #cute girls
if ((level->getTile(x, y, z) == Tile::topSnow_Id) && (face >= 2)) {
int h0 = level->getData(x, y, z) & HEIGHT_MASK;
int xx = x;
int yy = y;
int zz = z;
// i love amy is the best yuri hand holding yuri i love girls i love amy is the best'yuri yuri girl love'canon yuri (yuri FUCKING KISS ALREADY
// girl love'girl love lesbian kiss yuri kissing girls lesbian yuri snuggle yuri snuggle,my wife,my girlfriend girl love my girlfriend FUCKING KISS ALREADY
// girl love kissing girls lesbian kiss)
switch (face) {
case 2:
zz += 1;
break;
case 3:
zz -= 1;
break;
case 4:
xx += 1;
break;
case 5:
xx -= 1;
break;
default:
break;
}
int h1 = level->getData(xx, yy, zz) & HEIGHT_MASK;
if (h0 >= h1) return false;
}
return Tile::shouldRenderFace(level, x, y, z, face);
}
bool TopSnowTile::shouldTileTick(Level* level, int x, int y, int z) {
return level->getBrightness(LightLayer::Block, x, y, z) > 11;
}