feat: blockstates

actually this time but might need to make a couple of fixes
This commit is contained in:
Fireblade
2026-05-04 21:26:13 -04:00
parent 0ee913e6e2
commit b750c4bbf4
28 changed files with 564 additions and 12 deletions
+60 -3
View File
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "FenceGateTile.h"
#include "AABB.h"
#include "BlockPos.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.h"
#include "net.minecraft.h"
@@ -23,17 +24,73 @@ int FenceGateTile::defaultBlockState()
int FenceGateTile::convertBlockStateToLegacyData(BlockState *state)
{
return state ? (state->value & 0x7) : 0;
if (!state) return 0;
return state->value & (DirectionalTile::DIRECTION_MASK | OPEN_BIT | POWERED_BIT);
}
Tile::BlockState FenceGateTile::getBlockState(int data)
{
return Tile::BlockState(data & 0x7);
return Tile::BlockState(data & (DirectionalTile::DIRECTION_MASK | OPEN_BIT | POWERED_BIT));
}
Tile::BlockState FenceGateTile::getBlockState(LevelSource *level, int x, int y, int z)
{
return Tile::BlockState(level->getData(x, y, z));
int data = level->getData(x, y, z) & (DirectionalTile::DIRECTION_MASK | OPEN_BIT | POWERED_BIT);
int dir = DirectionalTile::getDirection(data);
bool inWall = false;
if (dir == Direction::NORTH || dir == Direction::SOUTH)
{
int westTile = level->getTile(x - 1, y, z);
int eastTile = level->getTile(x + 1, y, z);
inWall = (westTile == Tile::cobbleWall_Id) || (eastTile == Tile::cobbleWall_Id);
}
else
{
int northTile = level->getTile(x, y, z - 1);
int southTile = level->getTile(x, y, z + 1);
inWall = (northTile == Tile::cobbleWall_Id) || (southTile == Tile::cobbleWall_Id);
}
if (inWall)
{
data |= IN_WALL_BIT;
}
return Tile::BlockState(data);
}
void FenceGateTile::fillVirtualBlockStateProperties(Tile::BlockState *state, LevelSource *level, const BlockPos &pos)
{
if (!state || !level) return;
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
Tile::BlockState base = getBlockState(level, x, y, z);
state->value = base.value;
int dir = DirectionalTile::getDirection(base.value);
bool inWall = false;
if (dir == Direction::NORTH || dir == Direction::SOUTH)
{
int westTile = level->getTile(x - 1, y, z);
int eastTile = level->getTile(x + 1, y, z);
inWall = (westTile == Tile::cobbleWall_Id) || (eastTile == Tile::cobbleWall_Id);
}
else
{
int northTile = level->getTile(x, y, z - 1);
int southTile = level->getTile(x, y, z + 1);
inWall = (northTile == Tile::cobbleWall_Id) || (southTile == Tile::cobbleWall_Id);
}
if (inWall)
{
state->value |= IN_WALL_BIT;
}
}
Icon *FenceGateTile::getTexture(int face, int data)