mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-07-16 02:50:39 +00:00
fix: half slab
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Minecraft.Client/Minecraft.h"
|
||||
#include "GrassTile.h"
|
||||
#include "HalfSlabTile.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.biome.h"
|
||||
#include "net.minecraft.h"
|
||||
@@ -96,7 +97,16 @@ 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)
|
||||
int aboveTileId = level->getTile(x, y + 1, z);
|
||||
Material* above = level->getMaterial(x, y + 1, z);
|
||||
bool aboveIsTopSlab = false;
|
||||
if (Tile::tiles[aboveTileId] != nullptr)
|
||||
{
|
||||
HalfSlabTile *aboveSlab = dynamic_cast<HalfSlabTile *>(Tile::tiles[aboveTileId]);
|
||||
aboveIsTopSlab = aboveSlab != nullptr && (level->getData(x, y + 1, z) & HalfSlabTile::TOP_SLOT_BIT) != 0;
|
||||
}
|
||||
|
||||
if (!aboveIsTopSlab && level->getRawBrightness(x, y + 1, z) < MIN_BRIGHTNESS && Tile::lightBlock[aboveTileId] > 2)
|
||||
{
|
||||
level->setTileAndUpdate(x, y, z, Tile::dirt_Id);
|
||||
}
|
||||
@@ -123,12 +133,10 @@ void GrassTile::tick(Level *level, int x, int y, int z, Random *random)
|
||||
|
||||
// using isSolid() here is wrong because non full blocks like iron bars,
|
||||
// fences, walls are also flagged as solid by their material
|
||||
int aboveTileId = level->getTile(x, y + 1, z);
|
||||
Material* above = level->getMaterial(x, y + 1, z);
|
||||
if (above->isLiquid() || Tile::lightBlock[aboveTileId] > 2)
|
||||
{
|
||||
level->setTileAndUpdate(x, y, z, Tile::dirt_Id);
|
||||
}
|
||||
if (!aboveIsTopSlab && (above->isLiquid() || Tile::lightBlock[aboveTileId] > 2))
|
||||
{
|
||||
level->setTileAndUpdate(x, y, z, Tile::dirt_Id);
|
||||
}
|
||||
}
|
||||
|
||||
int GrassTile::getResource(int data, Random *random, int playerBonusLevel)
|
||||
|
||||
@@ -113,54 +113,33 @@ bool HalfSlabTile::isCubeShaped()
|
||||
return isFullSize() != 0;
|
||||
}
|
||||
|
||||
bool HalfSlabTile::shouldRenderFace(
|
||||
LevelSource *level, int x, int y, int z, int face)
|
||||
bool HalfSlabTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
|
||||
{
|
||||
|
||||
if (isFullSize())
|
||||
return Tile::shouldRenderFace(level, x, y, z, face);
|
||||
if (isFullSize()) return Tile::shouldRenderFace(level, x, y, z, face);
|
||||
|
||||
|
||||
if (face != Facing::UP && face != Facing::DOWN
|
||||
&& !Tile::shouldRenderFace(level, x, y, z, face))
|
||||
return false;
|
||||
if (face != Facing::UP && face != Facing::DOWN && !Tile::shouldRenderFace(level, x, y, z, face))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int oppFace = Facing::getOpposite(face);
|
||||
int nx = x, ny = y, nz = z;
|
||||
|
||||
if (oppFace == Facing::DOWN) ny--;
|
||||
if (oppFace == Facing::UP) ny++;
|
||||
if (oppFace == Facing::NORTH) nz--;
|
||||
if (oppFace == Facing::SOUTH) nz++;
|
||||
if (oppFace == Facing::WEST) nx--;
|
||||
if (oppFace == Facing::EAST) nx++;
|
||||
int ox = x, oy = y, oz = z;
|
||||
ox += Facing::STEP_X[Facing::OPPOSITE_FACING[face]];
|
||||
oy += Facing::STEP_Y[Facing::OPPOSITE_FACING[face]];
|
||||
oz += Facing::STEP_Z[Facing::OPPOSITE_FACING[face]];
|
||||
|
||||
int currentData = level->getData(x, y, z);
|
||||
int neighborData = level->getData(nx, ny, nz);
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
int neighborTile = level->getTile(nx, ny, nz);
|
||||
|
||||
bool currentIsUpper = (currentData & TOP_SLOT_BIT) != 0;
|
||||
bool neighborIsUpper = (neighborData & TOP_SLOT_BIT) != 0;
|
||||
|
||||
bool currentIsSlab = isHalfSlab(currentTile);
|
||||
bool neighborIsSlab = isHalfSlab(neighborTile);
|
||||
|
||||
|
||||
if (neighborIsSlab && neighborIsUpper)
|
||||
{
|
||||
if (face == Facing::DOWN)
|
||||
return true;
|
||||
if (face == Facing::UP && !Tile::shouldRenderFace(level, x, y, z, face))
|
||||
return currentIsSlab && !currentIsUpper ? false : true;
|
||||
return !(currentIsSlab && currentIsUpper);
|
||||
}
|
||||
|
||||
if (face == Facing::UP || (face == Facing::DOWN
|
||||
&& Tile::shouldRenderFace(level, x, y, z, face)))
|
||||
return true;
|
||||
|
||||
return !(currentIsSlab && !currentIsUpper);
|
||||
boolean isUpper = (level->getData(ox, oy, oz) & TOP_SLOT_BIT) != 0;
|
||||
if (isUpper)
|
||||
{
|
||||
if (face == Facing::DOWN) return true;
|
||||
if (face == Facing::UP && Tile::shouldRenderFace(level, x, y, z, face)) return true;
|
||||
return !(isHalfSlab(level->getTile(x, y, z)) && (level->getData(x, y, z) & TOP_SLOT_BIT) != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (face == Facing::UP) return true;
|
||||
if (face == Facing::DOWN && Tile::shouldRenderFace(level, x, y, z, face)) return true;
|
||||
return !(isHalfSlab(level->getTile(x, y, z)) && (level->getData(x, y, z) & TOP_SLOT_BIT) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
int HalfSlabTile::getSpawnResourcesAuxValue(int data)
|
||||
|
||||
Reference in New Issue
Block a user