mirror of
https://github.com/DrPerkyLegit/LCEServerTest.git
synced 2026-06-28 07:15:46 +00:00
slabs, fences, doors from TU25
This commit is contained in:
@@ -1,152 +1,172 @@
|
||||
#include "stdafx.h"
|
||||
#include "HalfSlabTile.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.biome.h"
|
||||
#include "net.minecraft.world.item.h"
|
||||
#include "net.minecraft.stats.h"
|
||||
#include "net.minecraft.world.level.tile.h"
|
||||
#include "net.minecraft.h"
|
||||
#include "Facing.h"
|
||||
|
||||
|
||||
HalfSlabTile::HalfSlabTile(int id, bool fullSize, Material *material) : Tile(id, material, fullSize)
|
||||
HalfSlabTile::HalfSlabTile(int id, Material *material)
|
||||
: Tile(id, material, true)
|
||||
{
|
||||
this->fullSize = fullSize;
|
||||
|
||||
if (fullSize)
|
||||
{
|
||||
solid[id] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
setShape(0, 0, 0, 1, 0.5f, 1);
|
||||
}
|
||||
setLightBlock(255);
|
||||
|
||||
Tile::lightBlock[id] = 0xFF;
|
||||
}
|
||||
|
||||
void HalfSlabTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
|
||||
void HalfSlabTile::DerivedInit()
|
||||
{
|
||||
if (fullSize)
|
||||
{
|
||||
setShape(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool upper = (level->getData(x, y, z) & TOP_SLOT_BIT) != 0;
|
||||
if (upper)
|
||||
{
|
||||
setShape(0, 0.5f, 0, 1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
setShape(0, 0, 0, 1, 0.5f, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isFullSize())
|
||||
setShape(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f);
|
||||
else
|
||||
Tile::solid[id] = true;
|
||||
}
|
||||
|
||||
void HalfSlabTile::updateDefaultShape()
|
||||
void HalfSlabTile::updateDefaultShape()
|
||||
{
|
||||
if (fullSize)
|
||||
{
|
||||
setShape(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
setShape(0, 0, 0, 1, 0.5f, 1);
|
||||
}
|
||||
|
||||
if (isFullSize())
|
||||
setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
|
||||
else
|
||||
setShape(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
void HalfSlabTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
|
||||
void HalfSlabTile::updateShape(
|
||||
LevelSource *level, int x, int y, int z,
|
||||
int forceData, shared_ptr<TileEntity> forceEntity)
|
||||
{
|
||||
updateShape(level, x, y, z);
|
||||
Tile::addAABBs(level, x, y, z, box, boxes, source);
|
||||
|
||||
if (isFullSize())
|
||||
{
|
||||
setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
int data = (forceData >= 0) ? forceData : level->getData(x, y, z);
|
||||
bool isUpper = (data & TOP_SLOT_BIT) != 0;
|
||||
|
||||
if (isUpper)
|
||||
setShape(0.0f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f);
|
||||
else
|
||||
setShape(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
bool HalfSlabTile::isSolidRender(bool isServerLevel)
|
||||
void HalfSlabTile::addAABBs(
|
||||
Level *level, int x, int y, int z,
|
||||
AABB *box, AABBList *boxes, shared_ptr<Entity> source)
|
||||
{
|
||||
return fullSize;
|
||||
|
||||
updateShape(level, x, y, z);
|
||||
Tile::addAABBs(level, x, y, z, box, boxes, source);
|
||||
}
|
||||
|
||||
int HalfSlabTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue)
|
||||
bool HalfSlabTile::isSolidRender(bool isServerLevel)
|
||||
{
|
||||
if (fullSize) return itemValue;
|
||||
|
||||
if (face == Facing::DOWN || (face != Facing::UP && clickY > 0.5))
|
||||
{
|
||||
return itemValue | TOP_SLOT_BIT;
|
||||
}
|
||||
return itemValue;
|
||||
|
||||
return isFullSize() != 0;
|
||||
}
|
||||
|
||||
int HalfSlabTile::getResourceCount(Random *random)
|
||||
bool HalfSlabTile::isSilkTouchable()
|
||||
{
|
||||
if (fullSize)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int HalfSlabTile::getSpawnResourcesAuxValue(int data)
|
||||
int HalfSlabTile::getResourceCount(Random *random)
|
||||
{
|
||||
return data & TYPE_MASK;
|
||||
|
||||
return isFullSize() ? 2 : 1;
|
||||
}
|
||||
|
||||
bool HalfSlabTile::isCubeShaped()
|
||||
bool HalfSlabTile::isCubeShaped()
|
||||
{
|
||||
return fullSize;
|
||||
|
||||
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 (fullSize) 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 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 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++;
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
bool HalfSlabTile::isHalfSlab(int tileId)
|
||||
int HalfSlabTile::getSpawnResourcesAuxValue(int data)
|
||||
{
|
||||
return tileId == Tile::stoneSlabHalf_Id || tileId == Tile::woodSlabHalf_Id;
|
||||
return data & TYPE_MASK;
|
||||
}
|
||||
|
||||
int HalfSlabTile::cloneTileData(Level *level, int x, int y, int z)
|
||||
{
|
||||
return Tile::cloneTileData(level, x, y, z) & TYPE_MASK;
|
||||
|
||||
return level->getData(x, y, z) & TYPE_MASK;
|
||||
}
|
||||
|
||||
int HalfSlabTile::cloneTileId(Level *level, int x, int y, int z)
|
||||
{
|
||||
if (isHalfSlab(id))
|
||||
{
|
||||
return id;
|
||||
}
|
||||
if (id == Tile::stoneSlab_Id)
|
||||
{
|
||||
return Tile::stoneSlabHalf_Id;
|
||||
}
|
||||
if (id == Tile::woodSlab_Id)
|
||||
{
|
||||
return Tile::woodSlabHalf_Id;
|
||||
}
|
||||
return Tile::stoneSlabHalf_Id;
|
||||
return id;
|
||||
}
|
||||
|
||||
int HalfSlabTile::getPlacedOnFaceDataValue(
|
||||
Level *level, int x, int y, int z,
|
||||
int face, float clickX, float clickY, float clickZ,
|
||||
int itemValue)
|
||||
{
|
||||
|
||||
if (face == Facing::DOWN)
|
||||
return itemValue | TOP_SLOT_BIT;
|
||||
if (face == Facing::UP)
|
||||
return itemValue;
|
||||
|
||||
return (clickY > 0.5f) ? (itemValue | TOP_SLOT_BIT) : itemValue;
|
||||
}
|
||||
|
||||
bool HalfSlabTile::isHalfSlab(int tileId)
|
||||
{
|
||||
if (tileId <= 0 || Tile::tiles[tileId] == nullptr)
|
||||
return false;
|
||||
return dynamic_cast<HalfSlabTile *>(Tile::tiles[tileId]) != nullptr
|
||||
&& !Tile::tiles[tileId]->isCubeShaped();
|
||||
}
|
||||
Reference in New Issue
Block a user