mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-04 03:26:35 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -5,98 +5,83 @@
|
||||
#include "../Headers/net.minecraft.h"
|
||||
#include "../Level/Events/LevelEvent.h"
|
||||
|
||||
FenceGateTile::FenceGateTile(int id) : DirectionalTile(id, Material::wood, false)
|
||||
{
|
||||
FenceGateTile::FenceGateTile(int id)
|
||||
: DirectionalTile(id, Material::wood, false) {}
|
||||
|
||||
Icon* FenceGateTile::getTexture(int face, int data) {
|
||||
return Tile::wood->getTexture(face);
|
||||
}
|
||||
|
||||
Icon *FenceGateTile::getTexture(int face, int data)
|
||||
{
|
||||
return Tile::wood->getTexture(face);
|
||||
}
|
||||
|
||||
bool FenceGateTile::mayPlace(Level *level, int x, int y, int z)
|
||||
{
|
||||
bool FenceGateTile::mayPlace(Level* level, int x, int y, int z) {
|
||||
if (!level->getMaterial(x, y - 1, z)->isSolid()) return false;
|
||||
return Tile::mayPlace(level, x, y, z);
|
||||
}
|
||||
|
||||
AABB *FenceGateTile::getAABB(Level *level, int x, int y, int z)
|
||||
{
|
||||
AABB* FenceGateTile::getAABB(Level* level, int x, int y, int z) {
|
||||
int data = level->getData(x, y, z);
|
||||
if (isOpen(data))
|
||||
{
|
||||
if (isOpen(data)) {
|
||||
return NULL;
|
||||
}
|
||||
// 4J Brought forward change from 1.2.3 to fix hit box rotation
|
||||
if (data == Direction::NORTH || data == Direction::SOUTH)
|
||||
{
|
||||
return AABB::newTemp(x, y, z + 6.0f / 16.0f, x + 1, y + 1.5f, z + 10.0f / 16.0f);
|
||||
}
|
||||
return AABB::newTemp(x + 6.0f / 16.0f, y, z, x + 10.0f / 16.0f, y + 1.5f, z + 1);
|
||||
//return AABB::newTemp(x, y, z, x + 1, y + 1.5f, z + 1);
|
||||
// 4J Brought forward change from 1.2.3 to fix hit box rotation
|
||||
if (data == Direction::NORTH || data == Direction::SOUTH) {
|
||||
return AABB::newTemp(x, y, z + 6.0f / 16.0f, x + 1, y + 1.5f,
|
||||
z + 10.0f / 16.0f);
|
||||
}
|
||||
return AABB::newTemp(x + 6.0f / 16.0f, y, z, x + 10.0f / 16.0f, y + 1.5f,
|
||||
z + 1);
|
||||
// return AABB::newTemp(x, y, z, x + 1, y + 1.5f, z + 1);
|
||||
}
|
||||
|
||||
// 4J - Brought forward from 1.2.3 to fix hit box rotation
|
||||
void FenceGateTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, std::shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
|
||||
void FenceGateTile::updateShape(
|
||||
LevelSource* level, int x, int y, int z, int forceData,
|
||||
std::shared_ptr<TileEntity>
|
||||
forceEntity) // 4J added forceData, forceEntity param
|
||||
{
|
||||
int data = getDirection(level->getData(x, y, z));
|
||||
if (data == Direction::NORTH || data == Direction::SOUTH)
|
||||
{
|
||||
setShape(0, 0, 6.0f / 16.0f, 1, 1.0f, 10.0f / 16.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
setShape(6.0f / 16.0f, 0, 0, 10.0f / 16.0f, 1.0f, 1);
|
||||
}
|
||||
int data = getDirection(level->getData(x, y, z));
|
||||
if (data == Direction::NORTH || data == Direction::SOUTH) {
|
||||
setShape(0, 0, 6.0f / 16.0f, 1, 1.0f, 10.0f / 16.0f);
|
||||
} else {
|
||||
setShape(6.0f / 16.0f, 0, 0, 10.0f / 16.0f, 1.0f, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool FenceGateTile::blocksLight()
|
||||
{
|
||||
return false;
|
||||
bool FenceGateTile::blocksLight() { return false; }
|
||||
|
||||
bool FenceGateTile::isSolidRender(bool isServerLevel) { return false; }
|
||||
|
||||
bool FenceGateTile::isCubeShaped() { return false; }
|
||||
|
||||
bool FenceGateTile::isPathfindable(LevelSource* level, int x, int y, int z) {
|
||||
return isOpen(level->getData(x, y, z));
|
||||
}
|
||||
|
||||
bool FenceGateTile::isSolidRender(bool isServerLevel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int FenceGateTile::getRenderShape() { return Tile::SHAPE_FENCE_GATE; }
|
||||
|
||||
bool FenceGateTile::isCubeShaped()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FenceGateTile::isPathfindable(LevelSource *level, int x, int y, int z)
|
||||
{
|
||||
return isOpen(level->getData(x, y, z));
|
||||
}
|
||||
|
||||
int FenceGateTile::getRenderShape()
|
||||
{
|
||||
return Tile::SHAPE_FENCE_GATE;
|
||||
}
|
||||
|
||||
void FenceGateTile::setPlacedBy(Level *level, int x, int y, int z, std::shared_ptr<Mob> by)
|
||||
{
|
||||
void FenceGateTile::setPlacedBy(Level* level, int x, int y, int z,
|
||||
std::shared_ptr<Mob> by) {
|
||||
int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3)) % 4;
|
||||
level->setData(x, y, z, dir);
|
||||
}
|
||||
|
||||
bool FenceGateTile::use(Level *level, int x, int y, int z, std::shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
|
||||
bool FenceGateTile::use(Level* level, int x, int y, int z,
|
||||
std::shared_ptr<Player> player, int clickedFace,
|
||||
float clickX, float clickY, float clickZ,
|
||||
bool soundOnly /*=false*/) // 4J added soundOnly param
|
||||
{
|
||||
if( soundOnly )
|
||||
{
|
||||
// 4J - added - just do enough to play the sound
|
||||
level->levelEvent(player, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0); // 4J - changed event to pass player rather than NULL as the source of the event so we can filter the broadcast properly
|
||||
return false;
|
||||
}
|
||||
if (soundOnly) {
|
||||
// 4J - added - just do enough to play the sound
|
||||
level->levelEvent(
|
||||
player, LevelEvent::SOUND_OPEN_DOOR, x, y, z,
|
||||
0); // 4J - changed event to pass player rather than NULL as the
|
||||
// source of the event so we can filter the broadcast properly
|
||||
return false;
|
||||
}
|
||||
|
||||
int data = level->getData(x, y, z);
|
||||
if (isOpen(data))
|
||||
{
|
||||
if (isOpen(data)) {
|
||||
level->setData(x, y, z, data & ~OPEN_BIT);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// open the door from the player
|
||||
int dir = (((Mth::floor(player->yRot * 4 / (360) + 0.5)) & 3)) % 4;
|
||||
int current = getDirection(data);
|
||||
@@ -109,39 +94,32 @@ bool FenceGateTile::use(Level *level, int x, int y, int z, std::shared_ptr<Playe
|
||||
return true;
|
||||
}
|
||||
|
||||
void FenceGateTile::neighborChanged(Level *level, int x, int y, int z, int type)
|
||||
{
|
||||
if (level->isClientSide) return;
|
||||
void FenceGateTile::neighborChanged(Level* level, int x, int y, int z,
|
||||
int type) {
|
||||
if (level->isClientSide) return;
|
||||
|
||||
int data = level->getData(x, y, z);
|
||||
int data = level->getData(x, y, z);
|
||||
|
||||
bool signal = level->hasNeighborSignal(x, y, z);
|
||||
if (signal || ((type > 0 && Tile::tiles[type]->isSignalSource()) || type == 0))
|
||||
{
|
||||
if (signal && !isOpen(data))
|
||||
{
|
||||
level->setData(x, y, z, data | OPEN_BIT);
|
||||
level->levelEvent(nullptr, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0);
|
||||
}
|
||||
else if (!signal && isOpen(data))
|
||||
{
|
||||
level->setData(x, y, z, data & ~OPEN_BIT);
|
||||
level->levelEvent(nullptr, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0);
|
||||
}
|
||||
}
|
||||
bool signal = level->hasNeighborSignal(x, y, z);
|
||||
if (signal ||
|
||||
((type > 0 && Tile::tiles[type]->isSignalSource()) || type == 0)) {
|
||||
if (signal && !isOpen(data)) {
|
||||
level->setData(x, y, z, data | OPEN_BIT);
|
||||
level->levelEvent(nullptr, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0);
|
||||
} else if (!signal && isOpen(data)) {
|
||||
level->setData(x, y, z, data & ~OPEN_BIT);
|
||||
level->levelEvent(nullptr, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FenceGateTile::isOpen(int data)
|
||||
{
|
||||
return (data & OPEN_BIT) != 0;
|
||||
bool FenceGateTile::isOpen(int data) { return (data & OPEN_BIT) != 0; }
|
||||
|
||||
void FenceGateTile::registerIcons(IconRegister* iconRegister) {
|
||||
// None
|
||||
}
|
||||
|
||||
void FenceGateTile::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
// None
|
||||
}
|
||||
|
||||
bool FenceGateTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
|
||||
{
|
||||
return true;
|
||||
bool FenceGateTile::shouldRenderFace(LevelSource* level, int x, int y, int z,
|
||||
int face) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user