mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-23 14:45:36 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -3,107 +3,90 @@
|
||||
#include "../../Headers/net.minecraft.world.entity.player.h"
|
||||
#include "../../Headers/net.minecraft.world.level.h"
|
||||
|
||||
EnchantmentTableEntity::EnchantmentTableEntity() {
|
||||
random = new Random();
|
||||
|
||||
|
||||
EnchantmentTableEntity::EnchantmentTableEntity()
|
||||
{
|
||||
random = new Random();
|
||||
|
||||
time = 0;
|
||||
time = 0;
|
||||
flip = 0.0f;
|
||||
oFlip = 0.0f;
|
||||
flipT = 0.0f;
|
||||
flipA = 0.0f;
|
||||
oFlip = 0.0f;
|
||||
flipT = 0.0f;
|
||||
flipA = 0.0f;
|
||||
open = 0.0f;
|
||||
oOpen = 0.0f;
|
||||
oOpen = 0.0f;
|
||||
rot = 0.0f;
|
||||
oRot = 0.0f;
|
||||
tRot = 0.0f;
|
||||
oRot = 0.0f;
|
||||
tRot = 0.0f;
|
||||
}
|
||||
|
||||
EnchantmentTableEntity::~EnchantmentTableEntity()
|
||||
{
|
||||
delete random;
|
||||
EnchantmentTableEntity::~EnchantmentTableEntity() { delete random; }
|
||||
|
||||
void EnchantmentTableEntity::tick() {
|
||||
TileEntity::tick();
|
||||
oOpen = open;
|
||||
oRot = rot;
|
||||
|
||||
std::shared_ptr<Player> player =
|
||||
level->getNearestPlayer(x + 0.5f, y + 0.5f, z + 0.5f, 3);
|
||||
if (player != NULL) {
|
||||
double xd = player->x - (x + 0.5f);
|
||||
double zd = player->z - (z + 0.5f);
|
||||
|
||||
tRot = (float)atan2(zd, xd);
|
||||
|
||||
open += 0.1f;
|
||||
|
||||
if (open < 0.5f || random->nextInt(40) == 0) {
|
||||
float old = flipT;
|
||||
do {
|
||||
flipT += random->nextInt(4) - random->nextInt(4);
|
||||
} while (old == flipT);
|
||||
}
|
||||
|
||||
} else {
|
||||
tRot += 0.02f;
|
||||
open -= 0.1f;
|
||||
}
|
||||
|
||||
while (rot >= PI) rot -= PI * 2;
|
||||
while (rot < -PI) rot += PI * 2;
|
||||
while (tRot >= PI) tRot -= PI * 2;
|
||||
while (tRot < -PI) tRot += PI * 2;
|
||||
float rotDir = tRot - rot;
|
||||
while (rotDir >= PI) rotDir -= PI * 2;
|
||||
while (rotDir < -PI) rotDir += PI * 2;
|
||||
|
||||
rot += rotDir * 0.4f;
|
||||
|
||||
if (open < 0) open = 0;
|
||||
if (open > 1) open = 1;
|
||||
|
||||
time++;
|
||||
oFlip = flip;
|
||||
|
||||
float diff = (flipT - flip) * 0.4f;
|
||||
float max = 0.2f;
|
||||
if (diff < -max) diff = -max;
|
||||
if (diff > +max) diff = +max;
|
||||
flipA += (diff - flipA) * 0.9f;
|
||||
|
||||
flip = flip + flipA;
|
||||
}
|
||||
|
||||
void EnchantmentTableEntity::tick()
|
||||
{
|
||||
TileEntity::tick();
|
||||
oOpen = open;
|
||||
oRot = rot;
|
||||
std::shared_ptr<TileEntity> EnchantmentTableEntity::clone() {
|
||||
std::shared_ptr<EnchantmentTableEntity> result =
|
||||
std::shared_ptr<EnchantmentTableEntity>(new EnchantmentTableEntity());
|
||||
TileEntity::clone(result);
|
||||
|
||||
std::shared_ptr<Player> player = level->getNearestPlayer(x + 0.5f, y + 0.5f, z + 0.5f, 3);
|
||||
if (player != NULL)
|
||||
{
|
||||
double xd = player->x - (x + 0.5f);
|
||||
double zd = player->z - (z + 0.5f);
|
||||
result->time = time;
|
||||
result->flip = flip;
|
||||
result->oFlip = oFlip;
|
||||
result->flipT = flipT;
|
||||
result->flipA = flipA;
|
||||
result->open = open;
|
||||
result->oOpen = oOpen;
|
||||
result->rot = rot;
|
||||
result->oRot = oRot;
|
||||
result->tRot = tRot;
|
||||
|
||||
tRot = (float) atan2(zd, xd);
|
||||
|
||||
open += 0.1f;
|
||||
|
||||
if (open < 0.5f || random->nextInt(40) == 0)
|
||||
{
|
||||
float old = flipT;
|
||||
do
|
||||
{
|
||||
flipT += random->nextInt(4) - random->nextInt(4);
|
||||
} while (old == flipT);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
tRot += 0.02f;
|
||||
open -= 0.1f;
|
||||
}
|
||||
|
||||
while (rot >= PI)
|
||||
rot -= PI * 2;
|
||||
while (rot < -PI)
|
||||
rot += PI * 2;
|
||||
while (tRot >= PI)
|
||||
tRot -= PI * 2;
|
||||
while (tRot < -PI)
|
||||
tRot += PI * 2;
|
||||
float rotDir = tRot - rot;
|
||||
while (rotDir >= PI)
|
||||
rotDir -= PI * 2;
|
||||
while (rotDir < -PI)
|
||||
rotDir += PI * 2;
|
||||
|
||||
rot += rotDir * 0.4f;
|
||||
|
||||
if (open < 0) open = 0;
|
||||
if (open > 1) open = 1;
|
||||
|
||||
time++;
|
||||
oFlip = flip;
|
||||
|
||||
float diff = (flipT - flip) * 0.4f;
|
||||
float max = 0.2f;
|
||||
if (diff < -max) diff = -max;
|
||||
if (diff > +max) diff = +max;
|
||||
flipA += (diff - flipA) * 0.9f;
|
||||
|
||||
flip = flip + flipA;
|
||||
}
|
||||
|
||||
std::shared_ptr<TileEntity> EnchantmentTableEntity::clone()
|
||||
{
|
||||
std::shared_ptr<EnchantmentTableEntity> result = std::shared_ptr<EnchantmentTableEntity>( new EnchantmentTableEntity() );
|
||||
TileEntity::clone(result);
|
||||
|
||||
result->time = time;
|
||||
result->flip = flip;
|
||||
result->oFlip = oFlip;
|
||||
result->flipT = flipT;
|
||||
result->flipA = flipA;
|
||||
result->open = open;
|
||||
result->oOpen = oOpen;
|
||||
result->rot = rot;
|
||||
result->oRot = oRot;
|
||||
result->tRot = tRot;
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user