mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
doubled speed of minecartfurnace
This commit is contained in:
parent
4fb2723109
commit
a552afded7
|
|
@ -9,171 +9,177 @@
|
||||||
|
|
||||||
MinecartFurnace::MinecartFurnace(Level *level) : Minecart(level)
|
MinecartFurnace::MinecartFurnace(Level *level) : Minecart(level)
|
||||||
{
|
{
|
||||||
defineSynchedData();
|
defineSynchedData();
|
||||||
|
|
||||||
fuel = 0;
|
fuel = 0;
|
||||||
xPush = zPush = 0.0f;
|
xPush = zPush = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
MinecartFurnace::MinecartFurnace(Level *level, double x, double y, double z) : Minecart(level, x, y, z)
|
MinecartFurnace::MinecartFurnace(Level *level, double x, double y, double z) : Minecart(level, x, y, z)
|
||||||
{
|
{
|
||||||
defineSynchedData();
|
defineSynchedData();
|
||||||
|
|
||||||
fuel = 0;
|
fuel = 0;
|
||||||
xPush = zPush = 0.0f;
|
xPush = zPush = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
int MinecartFurnace::getContainerType()
|
int MinecartFurnace::getContainerType()
|
||||||
{
|
{
|
||||||
return ContainerOpenPacket::MINECART_HOPPER;
|
return ContainerOpenPacket::MINECART_HOPPER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MinecartFurnace::getType()
|
int MinecartFurnace::getType()
|
||||||
{
|
{
|
||||||
return TYPE_FURNACE;
|
return TYPE_FURNACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartFurnace::defineSynchedData()
|
void MinecartFurnace::defineSynchedData()
|
||||||
{
|
{
|
||||||
Minecart::defineSynchedData();
|
Minecart::defineSynchedData();
|
||||||
entityData->define(DATA_ID_FUEL, static_cast<byte>(0));
|
entityData->define(DATA_ID_FUEL, static_cast<byte>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartFurnace::tick()
|
void MinecartFurnace::tick()
|
||||||
{
|
{
|
||||||
Minecart::tick();
|
Minecart::tick();
|
||||||
|
|
||||||
if (fuel > 0)
|
if (fuel > 0)
|
||||||
{
|
{
|
||||||
fuel--;
|
fuel--;
|
||||||
}
|
}
|
||||||
if (fuel <= 0)
|
if (fuel <= 0)
|
||||||
{
|
{
|
||||||
xPush = zPush = 0;
|
xPush = zPush = 0;
|
||||||
}
|
}
|
||||||
setHasFuel(fuel > 0);
|
setHasFuel(fuel > 0);
|
||||||
|
|
||||||
if (hasFuel() && random->nextInt(4) == 0)
|
if (hasFuel() && random->nextInt(4) == 0)
|
||||||
{
|
{
|
||||||
level->addParticle(eParticleType_largesmoke, x, y + 0.8, z, 0, 0, 0);
|
level->addParticle(eParticleType_largesmoke, x, y + 0.8, z, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartFurnace::destroy(DamageSource *source)
|
void MinecartFurnace::destroy(DamageSource *source)
|
||||||
{
|
{
|
||||||
Minecart::destroy(source);
|
Minecart::destroy(source);
|
||||||
|
|
||||||
if (!source->isExplosion())
|
if (!source->isExplosion())
|
||||||
{
|
{
|
||||||
spawnAtLocation(std::make_shared<ItemInstance>(Tile::furnace, 1), 0);
|
spawnAtLocation(std::make_shared<ItemInstance>(Tile::furnace, 1), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartFurnace::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double slideSpeed, int tile, int data)
|
void MinecartFurnace::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double slideSpeed, int tile, int data)
|
||||||
{
|
{
|
||||||
Minecart::moveAlongTrack(xt, yt, zt, maxSpeed, slideSpeed, tile, data);
|
//2 times max speed to get 8blocks
|
||||||
|
double lceMaxSpeed = maxSpeed * 2.0;
|
||||||
|
|
||||||
double sd = xPush * xPush + zPush * zPush;
|
Minecart::moveAlongTrack(xt, yt, zt, lceMaxSpeed, slideSpeed, tile, data);
|
||||||
if (sd > 0.01 * 0.01 && xd * xd + zd * zd > 0.001)
|
|
||||||
{
|
|
||||||
sd = Mth::sqrt(sd);
|
|
||||||
xPush /= sd;
|
|
||||||
zPush /= sd;
|
|
||||||
|
|
||||||
if (xPush * xd + zPush * zd < 0)
|
double sd = xPush * xPush + zPush * zPush;
|
||||||
{
|
if (sd > 0.01 * 0.01 && xd * xd + zd * zd > 0.001)
|
||||||
xPush = 0;
|
{
|
||||||
zPush = 0;
|
sd = Mth::sqrt(sd);
|
||||||
}
|
xPush /= sd;
|
||||||
else
|
zPush /= sd;
|
||||||
{
|
|
||||||
xPush = xd;
|
if (xPush * xd + zPush * zd < 0)
|
||||||
zPush = zd;
|
{
|
||||||
}
|
xPush = 0;
|
||||||
}
|
zPush = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xPush = xd;
|
||||||
|
zPush = zd;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartFurnace::applyNaturalSlowdown()
|
void MinecartFurnace::applyNaturalSlowdown()
|
||||||
{
|
{
|
||||||
double sd = xPush * xPush + zPush * zPush;
|
double sd = xPush * xPush + zPush * zPush;
|
||||||
|
|
||||||
if (sd > 0.01 * 0.01)
|
if (sd > 0.01 * 0.01)
|
||||||
{
|
{
|
||||||
sd = Mth::sqrt(sd);
|
sd = Mth::sqrt(sd);
|
||||||
xPush /= sd;
|
xPush /= sd;
|
||||||
zPush /= sd;
|
zPush /= sd;
|
||||||
double speed = 0.05;
|
|
||||||
xd *= 0.8f;
|
//from 0.05 to 0.1
|
||||||
yd *= 0;
|
double speed = 0.1;
|
||||||
zd *= 0.8f;
|
|
||||||
xd += xPush * speed;
|
xd *= 0.8f;
|
||||||
zd += zPush * speed;
|
yd *= 0;
|
||||||
}
|
zd *= 0.8f;
|
||||||
else
|
xd += xPush * speed;
|
||||||
{
|
zd += zPush * speed;
|
||||||
xd *= 0.98f;
|
}
|
||||||
yd *= 0;
|
else
|
||||||
zd *= 0.98f;
|
{
|
||||||
}
|
xd *= 0.98f;
|
||||||
|
yd *= 0;
|
||||||
|
zd *= 0.98f;
|
||||||
|
}
|
||||||
|
|
||||||
Minecart::applyNaturalSlowdown();
|
Minecart::applyNaturalSlowdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MinecartFurnace::interact(shared_ptr<Player> player)
|
bool MinecartFurnace::interact(shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> selected = player->inventory->getSelected();
|
shared_ptr<ItemInstance> selected = player->inventory->getSelected();
|
||||||
if (selected != nullptr && selected->id == Item::coal_Id)
|
if (selected != nullptr && selected->id == Item::coal_Id)
|
||||||
{
|
{
|
||||||
if (!player->abilities.instabuild && --selected->count == 0) player->inventory->setItem(player->inventory->selected, nullptr);
|
if (!player->abilities.instabuild && --selected->count == 0) player->inventory->setItem(player->inventory->selected, nullptr);
|
||||||
fuel += SharedConstants::TICKS_PER_SECOND * 180;
|
fuel += SharedConstants::TICKS_PER_SECOND * 180;
|
||||||
|
|
||||||
}
|
}
|
||||||
xPush = x - player->x;
|
xPush = x - player->x;
|
||||||
zPush = z - player->z;
|
zPush = z - player->z;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartFurnace::addAdditonalSaveData(CompoundTag *base)
|
void MinecartFurnace::addAdditonalSaveData(CompoundTag *base)
|
||||||
{
|
{
|
||||||
Minecart::addAdditonalSaveData(base);
|
Minecart::addAdditonalSaveData(base);
|
||||||
base->putDouble(L"PushX", xPush);
|
base->putDouble(L"PushX", xPush);
|
||||||
base->putDouble(L"PushZ", zPush);
|
base->putDouble(L"PushZ", zPush);
|
||||||
base->putShort(L"Fuel", static_cast<short>(fuel));
|
base->putShort(L"Fuel", static_cast<short>(fuel));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartFurnace::readAdditionalSaveData(CompoundTag *base)
|
void MinecartFurnace::readAdditionalSaveData(CompoundTag *base)
|
||||||
{
|
{
|
||||||
Minecart::readAdditionalSaveData(base);
|
Minecart::readAdditionalSaveData(base);
|
||||||
xPush = base->getDouble(L"PushX");
|
xPush = base->getDouble(L"PushX");
|
||||||
zPush = base->getDouble(L"PushZ");
|
zPush = base->getDouble(L"PushZ");
|
||||||
fuel = base->getShort(L"Fuel");
|
fuel = base->getShort(L"Fuel");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MinecartFurnace::hasFuel()
|
bool MinecartFurnace::hasFuel()
|
||||||
{
|
{
|
||||||
return (entityData->getByte(DATA_ID_FUEL) & 1) != 0;
|
return (entityData->getByte(DATA_ID_FUEL) & 1) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartFurnace::setHasFuel(bool fuel)
|
void MinecartFurnace::setHasFuel(bool fuel)
|
||||||
{
|
{
|
||||||
if (fuel)
|
if (fuel)
|
||||||
{
|
{
|
||||||
entityData->set(DATA_ID_FUEL, static_cast<byte>(entityData->getByte(DATA_ID_FUEL) | 1));
|
entityData->set(DATA_ID_FUEL, static_cast<byte>(entityData->getByte(DATA_ID_FUEL) | 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entityData->set(DATA_ID_FUEL, static_cast<byte>(entityData->getByte(DATA_ID_FUEL) & ~1));
|
entityData->set(DATA_ID_FUEL, static_cast<byte>(entityData->getByte(DATA_ID_FUEL) & ~1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tile *MinecartFurnace::getDefaultDisplayTile()
|
Tile *MinecartFurnace::getDefaultDisplayTile()
|
||||||
{
|
{
|
||||||
return Tile::furnace_lit;
|
return Tile::furnace_lit;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MinecartFurnace::getDefaultDisplayData()
|
int MinecartFurnace::getDefaultDisplayData()
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue