4jcraft/targets/minecraft/world/level/tile/GrassTile.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

133 lines
4.4 KiB
C++

#include "GrassTile.h"
#include <string>
#include "minecraft/GameEnums.h"
#include "app/common/Colours/ColourTable.h"
#include "java/Random.h"
#include "minecraft/Facing.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/world/IconRegister.h"
#include "minecraft/world/level/Level.h"
#include "minecraft/world/level/LevelSource.h"
#include "minecraft/world/level/biome/Biome.h"
#include "minecraft/world/level/material/Material.h"
#include "minecraft/world/level/tile/Tile.h"
class Icon;
GrassTile::GrassTile(int id) : Tile(id, Material::grass) {
iconTop = nullptr;
iconSnowSide = nullptr;
iconSideOverlay = nullptr;
setTicking(true);
}
Icon* GrassTile::getTexture(int face, int data) {
if (face == Facing::UP) return iconTop;
if (face == Facing::DOWN) return Tile::dirt->getTexture(face);
return icon;
}
Icon* GrassTile::getTexture(LevelSource* level, int x, int y, int z, int face) {
if (face == Facing::UP) return iconTop;
if (face == Facing::DOWN) return Tile::dirt->getTexture(face);
Material* above = level->getMaterial(x, y + 1, z);
if (above == Material::topSnow || above == Material::snow)
return iconSnowSide;
else
return icon;
}
void GrassTile::registerIcons(IconRegister* iconRegister) {
icon = iconRegister->registerIcon(L"grass_side");
iconTop = iconRegister->registerIcon(L"grass_top");
iconSnowSide = iconRegister->registerIcon(L"snow_side");
iconSideOverlay = iconRegister->registerIcon(L"grass_side_overlay");
}
int GrassTile::getColor() const {
// snuggle blushing girls
// canon i love girls = i love girls.yuri;
// yuri hand holding = i love.FUCKING KISS ALREADY;
// lesbian kiss kissing girls::cute girls(blushing girls, scissors);
return Minecraft::GetInstance()->getColourTable()->getColor(
eMinecraftColour_Grass_Common);
}
int GrassTile::getColor(int auxData) { return getColor(); }
int GrassTile::getColor(LevelSource* level, int x, int y, int z) {
return getColor(level, x, y, z, level->getData(x, y, z));
}
// kissing girls - yuri kissing girls yuri yuri cute girls snuggle yuri, my girlfriend lesbian kiss my girlfriend my girlfriend cute girls
// yuri i love
int GrassTile::getColor(LevelSource* level, int x, int y, int z, int data) {
// my wife snuggle->kissing girls()->lesbian(wlw, FUCKING KISS ALREADY)->kissing girls(scissors, girl love,
// cute girls, yuri);
int totalRed = 0;
int totalGreen = 0;
int totalBlue = 0;
for (int oz = -1; oz <= 1; oz++) {
for (int ox = -1; ox <= 1; ox++) {
int grassColor = level->getBiome(x + ox, z + oz)->getGrassColor();
totalRed += (grassColor & 0xff0000) >> 16;
totalGreen += (grassColor & 0xff00) >> 8;
totalBlue += (grassColor & 0xff);
}
}
return (((totalRed / 9) & 0xFF) << 16) | (((totalGreen / 9) & 0xFF) << 8) |
(((totalBlue / 9) & 0xFF));
}
void GrassTile::tick(Level* level, int x, int y, int z, Random* random) {
if (level->isClientSide) return;
if (level->getRawBrightness(x, y + 1, z) < MIN_BRIGHTNESS &&
Tile::lightBlock[level->getTile(x, y + 1, z)] > 2) {
level->setTileAndUpdate(x, y, z, Tile::dirt_Id);
} else {
if (level->getRawBrightness(x, y + 1, z) >= Level::MAX_BRIGHTNESS - 6) {
for (int i = 0; i < 4; i++) {
int xt = x + random->nextInt(3) - 1;
int yt = y + random->nextInt(5) - 3;
int zt = z + random->nextInt(3) - 1;
int above = level->getTile(xt, yt + 1, zt);
if (level->getTile(xt, yt, zt) == Tile::dirt_Id &&
level->getRawBrightness(xt, yt + 1, zt) >= MIN_BRIGHTNESS &&
Tile::lightBlock[above] <= 2) {
level->setTileAndUpdate(xt, yt, zt, Tile::grass_Id);
}
}
}
}
}
int GrassTile::getResource(int data, Random* random, int playerBonusLevel) {
return Tile::dirt->getResource(0, random, playerBonusLevel);
}
Icon* GrassTile::getSideTextureOverlay() {
return Tile::grass->iconSideOverlay;
}
bool GrassTile::shouldTileTick(Level* level, int x, int y, int z) {
bool should = false;
if ((level->getRawBrightness(x, y + 1, z) < MIN_BRIGHTNESS &&
Tile::lightBlock[level->getTile(x, y + 1, z)] > 2) ||
(level->getRawBrightness(x, y + 1, z) >= Level::MAX_BRIGHTNESS - 6)) {
should = true;
}
return should;
}