mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-28 05:20:51 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -7,134 +7,143 @@
|
||||
#include "../../Headers/net.minecraft.h"
|
||||
#include "StoneSlabTileItem.h"
|
||||
|
||||
StoneSlabTileItem::StoneSlabTileItem(int id, HalfSlabTile *halfTile, HalfSlabTile *fullTile, bool full) : TileItem(id)
|
||||
{
|
||||
this->halfTile = halfTile;
|
||||
this->fullTile = fullTile;
|
||||
StoneSlabTileItem::StoneSlabTileItem(int id, HalfSlabTile* halfTile,
|
||||
HalfSlabTile* fullTile, bool full)
|
||||
: TileItem(id) {
|
||||
this->halfTile = halfTile;
|
||||
this->fullTile = fullTile;
|
||||
|
||||
this->isFull = full;
|
||||
setMaxDamage(0);
|
||||
setStackedByData(true);
|
||||
this->isFull = full;
|
||||
setMaxDamage(0);
|
||||
setStackedByData(true);
|
||||
}
|
||||
|
||||
Icon *StoneSlabTileItem::getIcon(int itemAuxValue)
|
||||
{
|
||||
return Tile::tiles[id]->getTexture(2, itemAuxValue);
|
||||
Icon* StoneSlabTileItem::getIcon(int itemAuxValue) {
|
||||
return Tile::tiles[id]->getTexture(2, itemAuxValue);
|
||||
}
|
||||
|
||||
int StoneSlabTileItem::getLevelDataForAuxValue(int auxValue)
|
||||
{
|
||||
return auxValue;
|
||||
int StoneSlabTileItem::getLevelDataForAuxValue(int auxValue) {
|
||||
return auxValue;
|
||||
}
|
||||
|
||||
unsigned int StoneSlabTileItem::getDescriptionId(std::shared_ptr<ItemInstance> instance)
|
||||
{
|
||||
return halfTile->getAuxName(instance->getAuxValue());
|
||||
unsigned int StoneSlabTileItem::getDescriptionId(
|
||||
std::shared_ptr<ItemInstance> instance) {
|
||||
return halfTile->getAuxName(instance->getAuxValue());
|
||||
}
|
||||
|
||||
bool StoneSlabTileItem::useOn(std::shared_ptr<ItemInstance> instance, std::shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
|
||||
{
|
||||
if (isFull)
|
||||
{
|
||||
return TileItem::useOn(instance, player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnOnly);
|
||||
}
|
||||
bool StoneSlabTileItem::useOn(std::shared_ptr<ItemInstance> instance,
|
||||
std::shared_ptr<Player> player, Level* level,
|
||||
int x, int y, int z, int face, float clickX,
|
||||
float clickY, float clickZ, bool bTestUseOnOnly) {
|
||||
if (isFull) {
|
||||
return TileItem::useOn(instance, player, level, x, y, z, face, clickX,
|
||||
clickY, clickZ, bTestUseOnOnly);
|
||||
}
|
||||
|
||||
if (instance->count == 0) return false;
|
||||
if (!player->mayBuild(x, y, z)) return false;
|
||||
if (instance->count == 0) return false;
|
||||
if (!player->mayBuild(x, y, z)) return false;
|
||||
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
int currentData = level->getData(x, y, z);
|
||||
int slabType = currentData & HalfSlabTile::TYPE_MASK;
|
||||
bool isUpper = (currentData & HalfSlabTile::TOP_SLOT_BIT) != 0;
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
int currentData = level->getData(x, y, z);
|
||||
int slabType = currentData & HalfSlabTile::TYPE_MASK;
|
||||
bool isUpper = (currentData & HalfSlabTile::TOP_SLOT_BIT) != 0;
|
||||
|
||||
if (((face == Facing::UP && !isUpper) || (face == Facing::DOWN && isUpper)) && currentTile == halfTile->id && slabType == instance->getAuxValue())
|
||||
{
|
||||
if(bTestUseOnOnly)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((face == Facing::UP && !isUpper) ||
|
||||
(face == Facing::DOWN && isUpper)) &&
|
||||
currentTile == halfTile->id && slabType == instance->getAuxValue()) {
|
||||
if (bTestUseOnOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (level->isUnobstructed(fullTile->getAABB(level, x, y, z)) && level->setTileAndData(x, y, z, fullTile->id, slabType))
|
||||
{
|
||||
// level.playSound(x + 0.5f, y + 0.5f, z + 0.5f, fullTile.soundType.getPlaceSound(), (fullTile.soundType.getVolume() + 1) / 2, fullTile.soundType.getPitch() * 0.8f);
|
||||
// instance.count--;
|
||||
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, fullTile->soundType->getStepSound(), (fullTile->soundType->getVolume() + 1) / 2, fullTile->soundType->getPitch() * 0.8f);
|
||||
instance->count--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (tryConvertTargetTile(instance, player, level, x, y, z, face, bTestUseOnOnly))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TileItem::useOn(instance, player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnOnly);
|
||||
}
|
||||
if (level->isUnobstructed(fullTile->getAABB(level, x, y, z)) &&
|
||||
level->setTileAndData(x, y, z, fullTile->id, slabType)) {
|
||||
// level.playSound(x + 0.5f, y + 0.5f, z + 0.5f,
|
||||
// fullTile.soundType.getPlaceSound(),
|
||||
// (fullTile.soundType.getVolume() + 1) / 2,
|
||||
// fullTile.soundType.getPitch() * 0.8f); instance.count--;
|
||||
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f,
|
||||
fullTile->soundType->getStepSound(),
|
||||
(fullTile->soundType->getVolume() + 1) / 2,
|
||||
fullTile->soundType->getPitch() * 0.8f);
|
||||
instance->count--;
|
||||
}
|
||||
return true;
|
||||
} else if (tryConvertTargetTile(instance, player, level, x, y, z, face,
|
||||
bTestUseOnOnly)) {
|
||||
return true;
|
||||
} else {
|
||||
return TileItem::useOn(instance, player, level, x, y, z, face, clickX,
|
||||
clickY, clickZ, bTestUseOnOnly);
|
||||
}
|
||||
}
|
||||
|
||||
bool StoneSlabTileItem::mayPlace(Level* level, int x, int y, int z, int face,
|
||||
std::shared_ptr<Player> player,
|
||||
std::shared_ptr<ItemInstance> item) {
|
||||
int ox = x, oy = y, oz = z;
|
||||
|
||||
bool StoneSlabTileItem::mayPlace(Level *level, int x, int y, int z, int face,std::shared_ptr<Player> player, std::shared_ptr<ItemInstance> item)
|
||||
{
|
||||
int ox = x, oy = y, oz = z;
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
int currentData = level->getData(x, y, z);
|
||||
int slabType = currentData & HalfSlabTile::TYPE_MASK;
|
||||
boolean isUpper = (currentData & HalfSlabTile::TOP_SLOT_BIT) != 0;
|
||||
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
int currentData = level->getData(x, y, z);
|
||||
int slabType = currentData & HalfSlabTile::TYPE_MASK;
|
||||
boolean isUpper = (currentData & HalfSlabTile::TOP_SLOT_BIT) != 0;
|
||||
if (((face == Facing::UP && !isUpper) ||
|
||||
(face == Facing::DOWN && isUpper)) &&
|
||||
currentTile == halfTile->id && slabType == item->getAuxValue()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (((face == Facing::UP && !isUpper) || (face == Facing::DOWN && isUpper)) && currentTile == halfTile->id && slabType == item->getAuxValue())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (face == 0) y--;
|
||||
if (face == 1) y++;
|
||||
if (face == 2) z--;
|
||||
if (face == 3) z++;
|
||||
if (face == 4) x--;
|
||||
if (face == 5) x++;
|
||||
|
||||
if (face == 0) y--;
|
||||
if (face == 1) y++;
|
||||
if (face == 2) z--;
|
||||
if (face == 3) z++;
|
||||
if (face == 4) x--;
|
||||
if (face == 5) x++;
|
||||
currentTile = level->getTile(x, y, z);
|
||||
currentData = level->getData(x, y, z);
|
||||
slabType = currentData & HalfSlabTile::TYPE_MASK;
|
||||
isUpper = (currentData & HalfSlabTile::TOP_SLOT_BIT) != 0;
|
||||
|
||||
currentTile = level->getTile(x, y, z);
|
||||
currentData = level->getData(x, y, z);
|
||||
slabType = currentData & HalfSlabTile::TYPE_MASK;
|
||||
isUpper = (currentData & HalfSlabTile::TOP_SLOT_BIT) != 0;
|
||||
if (currentTile == halfTile->id && slabType == item->getAuxValue()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (currentTile == halfTile->id && slabType == item->getAuxValue())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return TileItem::mayPlace(level, ox, oy, oz, face, player, item);
|
||||
return TileItem::mayPlace(level, ox, oy, oz, face, player, item);
|
||||
}
|
||||
|
||||
bool StoneSlabTileItem::tryConvertTargetTile(std::shared_ptr<ItemInstance> instance, std::shared_ptr<Player> player, Level *level, int x, int y, int z, int face, bool bTestUseOnOnly)
|
||||
{
|
||||
if (face == 0) y--;
|
||||
if (face == 1) y++;
|
||||
if (face == 2) z--;
|
||||
if (face == 3) z++;
|
||||
if (face == 4) x--;
|
||||
if (face == 5) x++;
|
||||
bool StoneSlabTileItem::tryConvertTargetTile(
|
||||
std::shared_ptr<ItemInstance> instance, std::shared_ptr<Player> player,
|
||||
Level* level, int x, int y, int z, int face, bool bTestUseOnOnly) {
|
||||
if (face == 0) y--;
|
||||
if (face == 1) y++;
|
||||
if (face == 2) z--;
|
||||
if (face == 3) z++;
|
||||
if (face == 4) x--;
|
||||
if (face == 5) x++;
|
||||
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
int currentData = level->getData(x, y, z);
|
||||
int slabType = currentData & HalfSlabTile::TYPE_MASK;
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
int currentData = level->getData(x, y, z);
|
||||
int slabType = currentData & HalfSlabTile::TYPE_MASK;
|
||||
|
||||
if (currentTile == halfTile->id && slabType == instance->getAuxValue())
|
||||
{
|
||||
if(bTestUseOnOnly)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (level->isUnobstructed(fullTile->getAABB(level, x, y, z)) && level->setTileAndData(x, y, z, fullTile->id, slabType))
|
||||
{
|
||||
//level.playSound(x + 0.5f, y + 0.5f, z + 0.5f, fullTile.soundType.getPlaceSound(), (fullTile.soundType.getVolume() + 1) / 2, fullTile.soundType.getPitch() * 0.8f);
|
||||
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, fullTile->soundType->getStepSound(), (fullTile->soundType->getVolume() + 1) / 2, fullTile->soundType->getPitch() * 0.8f);
|
||||
instance->count--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (currentTile == halfTile->id && slabType == instance->getAuxValue()) {
|
||||
if (bTestUseOnOnly) {
|
||||
return true;
|
||||
}
|
||||
if (level->isUnobstructed(fullTile->getAABB(level, x, y, z)) &&
|
||||
level->setTileAndData(x, y, z, fullTile->id, slabType)) {
|
||||
// level.playSound(x + 0.5f, y + 0.5f, z + 0.5f,
|
||||
// fullTile.soundType.getPlaceSound(),
|
||||
// (fullTile.soundType.getVolume() + 1) / 2,
|
||||
// fullTile.soundType.getPitch() * 0.8f);
|
||||
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f,
|
||||
fullTile->soundType->getStepSound(),
|
||||
(fullTile->soundType->getVolume() + 1) / 2,
|
||||
fullTile->soundType->getPitch() * 0.8f);
|
||||
instance->count--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user