mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-23 12:23:06 +00:00
format everything
This commit is contained in:
@@ -49,12 +49,12 @@ std::shared_ptr<ChatPacket> EntityDamageSource::getDeathMessagePacket(
|
||||
}
|
||||
|
||||
if ((held != nullptr) && held->hasCustomHoverName()) {
|
||||
return std::make_shared<ChatPacket>(
|
||||
player->getNetworkName(), m_msgWithItemId, entity->GetType(),
|
||||
additional, held->getHoverName());
|
||||
return std::make_shared<ChatPacket>(player->getNetworkName(),
|
||||
m_msgWithItemId, entity->GetType(),
|
||||
additional, held->getHoverName());
|
||||
} else {
|
||||
return std::make_shared<ChatPacket>(
|
||||
player->getNetworkName(), m_msgId, entity->GetType(), additional);
|
||||
return std::make_shared<ChatPacket>(player->getNetworkName(), m_msgId,
|
||||
entity->GetType(), additional);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ std::shared_ptr<ChatPacket> IndirectEntityDamageSource::getDeathMessagePacket(
|
||||
new ChatPacket(player->getNetworkName(), m_msgWithItemId, type,
|
||||
additional, held->getHoverName()));
|
||||
} else {
|
||||
return std::make_shared<ChatPacket>(
|
||||
player->getNetworkName(), m_msgId, type, additional);
|
||||
return std::make_shared<ChatPacket>(player->getNetworkName(), m_msgId,
|
||||
type, additional);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -333,8 +333,7 @@ void Entity::_init(bool useSmallId, Level* level) {
|
||||
|
||||
// values that need to be sent to clients in SMP
|
||||
if (useSmallId) {
|
||||
entityData =
|
||||
std::make_shared<SynchedEntityData>();
|
||||
entityData = std::make_shared<SynchedEntityData>();
|
||||
} else {
|
||||
entityData = nullptr;
|
||||
}
|
||||
@@ -1405,9 +1404,8 @@ std::shared_ptr<ItemEntity> Entity::spawnAtLocation(int resource, int count) {
|
||||
|
||||
std::shared_ptr<ItemEntity> Entity::spawnAtLocation(int resource, int count,
|
||||
float yOffs) {
|
||||
return spawnAtLocation(
|
||||
std::make_shared<ItemInstance>(resource, count, 0),
|
||||
yOffs);
|
||||
return spawnAtLocation(std::make_shared<ItemInstance>(resource, count, 0),
|
||||
yOffs);
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemEntity> Entity::spawnAtLocation(
|
||||
@@ -1535,7 +1533,8 @@ void Entity::lerpTo(double x, double y, double z, float yRot, float xRot,
|
||||
// intersect the geometry they land in slightly.
|
||||
if (GetType() != eTYPE_ARROW) {
|
||||
AABB shrunk = bb.shrink(1 / 32.0, 0.0, 1 / 32.0);
|
||||
std::vector<AABB>* collisions = level->getCubes(shared_from_this(), &shrunk);
|
||||
std::vector<AABB>* collisions =
|
||||
level->getCubes(shared_from_this(), &shrunk);
|
||||
if (!collisions->empty()) {
|
||||
double yTop = 0;
|
||||
auto itEnd = collisions->end();
|
||||
@@ -1583,9 +1582,12 @@ void Entity::handleEntityEvent(uint8_t eventId) {}
|
||||
|
||||
void Entity::animateHurt() {}
|
||||
|
||||
std::vector<std::shared_ptr<ItemInstance>> Entity::getEquipmentSlots() // ItemInstance[]
|
||||
std::vector<std::shared_ptr<ItemInstance>>
|
||||
Entity::getEquipmentSlots() // ItemInstance[]
|
||||
{
|
||||
return std::vector<std::shared_ptr<ItemInstance>>(); // Default ctor creates nullptr internal array
|
||||
return std::vector<std::shared_ptr<ItemInstance>>(); // Default ctor
|
||||
// creates nullptr
|
||||
// internal array
|
||||
}
|
||||
|
||||
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer
|
||||
@@ -1744,7 +1746,7 @@ std::wstring Entity::getAName() {
|
||||
#endif
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Entity> >* Entity::getSubEntities() {
|
||||
std::vector<std::shared_ptr<Entity>>* Entity::getSubEntities() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -357,7 +357,8 @@ public:
|
||||
virtual void lerpMotion(double xd, double yd, double zd);
|
||||
virtual void handleEntityEvent(uint8_t eventId);
|
||||
virtual void animateHurt();
|
||||
virtual std::vector<std::shared_ptr<ItemInstance>> getEquipmentSlots(); // ItemInstance[]
|
||||
virtual std::vector<std::shared_ptr<ItemInstance>>
|
||||
getEquipmentSlots(); // ItemInstance[]
|
||||
virtual void setEquippedSlot(
|
||||
int slot, std::shared_ptr<ItemInstance>
|
||||
item); // 4J Stu - Brought forward change from 1.3 to fix
|
||||
@@ -443,7 +444,7 @@ public:
|
||||
bool isExtraWanderingEnabled();
|
||||
int getWanderingQuadrant();
|
||||
|
||||
virtual std::vector<std::shared_ptr<Entity> >* getSubEntities();
|
||||
virtual std::vector<std::shared_ptr<Entity>>* getSubEntities();
|
||||
virtual bool is(std::shared_ptr<Entity> other);
|
||||
virtual float getYHeadRot();
|
||||
virtual void setYHeadRot(float yHeadRot);
|
||||
|
||||
@@ -54,8 +54,7 @@ void ItemFrame::dropItem(std::shared_ptr<Entity> causedBy) {
|
||||
}
|
||||
}
|
||||
|
||||
spawnAtLocation(
|
||||
std::make_shared<ItemInstance>(Item::frame), 0);
|
||||
spawnAtLocation(std::make_shared<ItemInstance>(Item::frame), 0);
|
||||
if ((item != nullptr) && (random->nextFloat() < dropChance)) {
|
||||
item = item->copy();
|
||||
removeFramedMap(item);
|
||||
|
||||
@@ -158,7 +158,6 @@ LivingEntity::~LivingEntity() {
|
||||
|
||||
delete attributes;
|
||||
delete combatTracker;
|
||||
|
||||
}
|
||||
|
||||
void LivingEntity::defineSynchedData() {
|
||||
@@ -1534,7 +1533,8 @@ void LivingEntity::aiStep() {
|
||||
// pop up the sides of walls, undersides of trees etc.
|
||||
AABB shrinkbb = bb.shrink(0.1, 0, 0.1);
|
||||
shrinkbb.y1 = shrinkbb.y0 + 0.1;
|
||||
std::vector<AABB>* collisions = level->getCubes(shared_from_this(), &shrinkbb);
|
||||
std::vector<AABB>* collisions =
|
||||
level->getCubes(shared_from_this(), &shrinkbb);
|
||||
if (collisions->size() > 0) {
|
||||
double yTop = 0;
|
||||
auto itEnd = collisions->end();
|
||||
@@ -1601,7 +1601,7 @@ void LivingEntity::newServerAiStep() {}
|
||||
|
||||
void LivingEntity::pushEntities() {
|
||||
AABB grown = bb.grow(0.2, 0, 0.2);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
std::vector<std::shared_ptr<Entity>>* entities =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
if (entities != nullptr && !entities->empty()) {
|
||||
auto itEnd = entities->end();
|
||||
|
||||
@@ -111,7 +111,6 @@ Mob::~Mob() {
|
||||
if (sensing != nullptr) delete sensing;
|
||||
|
||||
if (leashInfoTag != nullptr) delete leashInfoTag;
|
||||
|
||||
}
|
||||
|
||||
void Mob::registerAttributes() {
|
||||
@@ -319,7 +318,7 @@ void Mob::aiStep() {
|
||||
if (!level->isClientSide && canPickUpLoot() && !dead &&
|
||||
level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)) {
|
||||
AABB grown = bb.grow(1, 0, 1);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
std::vector<std::shared_ptr<Entity>>* entities =
|
||||
level->getEntitiesOfClass(typeid(ItemEntity), &grown);
|
||||
for (auto it = entities->begin(); it != entities->end(); ++it) {
|
||||
std::shared_ptr<ItemEntity> entity =
|
||||
@@ -424,32 +423,30 @@ void Mob::checkDespawn() {
|
||||
}
|
||||
|
||||
void Mob::newServerAiStep() {
|
||||
noActionTime++;
|
||||
checkDespawn();
|
||||
|
||||
sensing->tick();
|
||||
|
||||
targetSelector.tick();
|
||||
|
||||
goalSelector.tick();
|
||||
|
||||
navigation->tick();
|
||||
|
||||
serverAiMobStep();
|
||||
|
||||
moveControl->tick();
|
||||
|
||||
lookControl->tick();
|
||||
|
||||
jumpControl->tick();
|
||||
|
||||
noActionTime++;
|
||||
checkDespawn();
|
||||
|
||||
sensing->tick();
|
||||
|
||||
targetSelector.tick();
|
||||
|
||||
goalSelector.tick();
|
||||
|
||||
navigation->tick();
|
||||
|
||||
serverAiMobStep();
|
||||
|
||||
moveControl->tick();
|
||||
|
||||
lookControl->tick();
|
||||
|
||||
jumpControl->tick();
|
||||
|
||||
// Consider this for extra strolling if it is protected against despawning.
|
||||
// We aren't interested in ones that aren't protected as the whole point of
|
||||
// this extra wandering is to potentially transition from protected to not
|
||||
// protected.
|
||||
considerForExtraWandering(isDespawnProtected());
|
||||
|
||||
|
||||
considerForExtraWandering(isDespawnProtected());
|
||||
}
|
||||
|
||||
void Mob::serverAiStep() {
|
||||
@@ -567,7 +564,9 @@ void Mob::setEquippedSlot(int slot, std::shared_ptr<ItemInstance> item) {
|
||||
equipment[slot] = item;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ItemInstance>> Mob::getEquipmentSlots() { return equipment; }
|
||||
std::vector<std::shared_ptr<ItemInstance>> Mob::getEquipmentSlots() {
|
||||
return equipment;
|
||||
}
|
||||
|
||||
void Mob::dropEquipment(bool byPlayer, int playerBonusLevel) {
|
||||
for (int slot = 0; slot < (int)getEquipmentSlots().size(); slot++) {
|
||||
@@ -854,7 +853,7 @@ void Mob::restoreLeashFromSave() {
|
||||
if (leashInfoTag->contains(L"UUID")) {
|
||||
std::wstring leashUuid = leashInfoTag->getString(L"UUID");
|
||||
AABB grown = bb.grow(10, 10, 10);
|
||||
std::vector<std::shared_ptr<Entity> >* livingEnts =
|
||||
std::vector<std::shared_ptr<Entity>>* livingEnts =
|
||||
level->getEntitiesOfClass(typeid(LivingEntity), &grown);
|
||||
for (auto it = livingEnts->begin(); it != livingEnts->end(); ++it) {
|
||||
std::shared_ptr<LivingEntity> le =
|
||||
|
||||
@@ -146,6 +146,5 @@ void Painting::dropItem(std::shared_ptr<Entity> causedBy) {
|
||||
}
|
||||
}
|
||||
|
||||
spawnAtLocation(
|
||||
std::make_shared<ItemInstance>(Item::painting), 0.0f);
|
||||
spawnAtLocation(std::make_shared<ItemInstance>(Item::painting), 0.0f);
|
||||
}
|
||||
@@ -94,13 +94,13 @@ bool VillageSiege::tryToSetupSiege() {
|
||||
|
||||
bool overlaps = false;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
spawnX = center->x +
|
||||
(int)(cosf(level->random->nextFloat() * std::numbers::pi * 2.f) *
|
||||
radius * 0.9);
|
||||
spawnX = center->x + (int)(cosf(level->random->nextFloat() *
|
||||
std::numbers::pi * 2.f) *
|
||||
radius * 0.9);
|
||||
spawnY = center->y;
|
||||
spawnZ = center->z +
|
||||
(int)(sinf(level->random->nextFloat() * std::numbers::pi * 2.f) *
|
||||
radius * 0.9);
|
||||
spawnZ = center->z + (int)(sinf(level->random->nextFloat() *
|
||||
std::numbers::pi * 2.f) *
|
||||
radius * 0.9);
|
||||
overlaps = false;
|
||||
std::vector<std::shared_ptr<Village> >* villages =
|
||||
level->villages->getVillages();
|
||||
|
||||
@@ -121,8 +121,7 @@ void Villages::cluster() {
|
||||
if (found) continue;
|
||||
|
||||
// create new Village
|
||||
std::shared_ptr<Village> village =
|
||||
std::make_shared<Village>(level);
|
||||
std::shared_ptr<Village> village = std::make_shared<Village>(level);
|
||||
village->addDoorInfo(di);
|
||||
villages.push_back(village);
|
||||
setDirty();
|
||||
@@ -206,8 +205,7 @@ void Villages::load(CompoundTag* tag) {
|
||||
(ListTag<CompoundTag>*)tag->getList(L"Villages");
|
||||
for (int i = 0; i < villageTags->size(); i++) {
|
||||
CompoundTag* compoundTag = villageTags->get(i);
|
||||
std::shared_ptr<Village> village =
|
||||
std::make_shared<Village>();
|
||||
std::shared_ptr<Village> village = std::make_shared<Village>();
|
||||
village->readAdditionalSaveData(compoundTag);
|
||||
villages.push_back(village);
|
||||
}
|
||||
|
||||
@@ -144,7 +144,6 @@ EntityHorse::EntityHorse(Level* level) : Animal(level) {
|
||||
createInventory();
|
||||
}
|
||||
|
||||
|
||||
void EntityHorse::defineSynchedData() {
|
||||
Animal::defineSynchedData();
|
||||
entityData->define(DATA_ID_HORSE_FLAGS, 0);
|
||||
@@ -1285,9 +1284,8 @@ void EntityHorse::readAdditionalSaveData(CompoundTag* tag) {
|
||||
inventory->setItem(INV_SLOT_SADDLE, saddleItem);
|
||||
}
|
||||
} else if (tag->getBoolean(L"Saddle")) {
|
||||
inventory->setItem(
|
||||
INV_SLOT_SADDLE,
|
||||
std::make_shared<ItemInstance>(Item::saddle));
|
||||
inventory->setItem(INV_SLOT_SADDLE,
|
||||
std::make_shared<ItemInstance>(Item::saddle));
|
||||
}
|
||||
updateEquipment();
|
||||
}
|
||||
@@ -1313,8 +1311,7 @@ std::shared_ptr<AgableMob> EntityHorse::getBreedOffspring(
|
||||
std::shared_ptr<AgableMob> partner) {
|
||||
std::shared_ptr<EntityHorse> horsePartner =
|
||||
std::dynamic_pointer_cast<EntityHorse>(partner);
|
||||
std::shared_ptr<EntityHorse> baby =
|
||||
std::make_shared<EntityHorse>(level);
|
||||
std::shared_ptr<EntityHorse> baby = std::make_shared<EntityHorse>(level);
|
||||
|
||||
int type = getType();
|
||||
int partnerType = horsePartner->getType();
|
||||
|
||||
@@ -229,8 +229,7 @@ std::shared_ptr<AgableMob> Ocelot::getBreedOffspring(
|
||||
std::shared_ptr<AgableMob> target) {
|
||||
// 4J - added limit to number of animals that can be bred
|
||||
if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) {
|
||||
std::shared_ptr<Ocelot> offspring =
|
||||
std::make_shared<Ocelot>(level);
|
||||
std::shared_ptr<Ocelot> offspring = std::make_shared<Ocelot>(level);
|
||||
if (isTame()) {
|
||||
offspring->setOwnerUUID(getOwnerUUID());
|
||||
offspring->setTame(true);
|
||||
@@ -314,8 +313,7 @@ MobGroupData* Ocelot::finalizeMobSpawn(
|
||||
#endif
|
||||
if (level->random->nextInt(7) == 0) {
|
||||
for (int kitten = 0; kitten < 2; kitten++) {
|
||||
std::shared_ptr<Ocelot> ocelot =
|
||||
std::make_shared<Ocelot>(level);
|
||||
std::shared_ptr<Ocelot> ocelot = std::make_shared<Ocelot>(level);
|
||||
ocelot->moveTo(x, y, z, yRot, 0);
|
||||
ocelot->setAge(-20 * 60 * 20);
|
||||
level->addEntity(ocelot);
|
||||
|
||||
@@ -140,8 +140,7 @@ void Pig::setSaddle(bool value) {
|
||||
|
||||
void Pig::thunderHit(const LightningBolt* lightningBolt) {
|
||||
if (level->isClientSide) return;
|
||||
std::shared_ptr<PigZombie> pz =
|
||||
std::make_shared<PigZombie>(level);
|
||||
std::shared_ptr<PigZombie> pz = std::make_shared<PigZombie>(level);
|
||||
pz->moveTo(x, y, z, yRot, xRot);
|
||||
level->addEntity(pz);
|
||||
remove();
|
||||
|
||||
@@ -152,7 +152,8 @@ float Sheep::getHeadEatAngleScale(float a) {
|
||||
if (eatAnimationTick > 4 && eatAnimationTick <= (EAT_ANIMATION_TICKS - 4)) {
|
||||
float scale = ((float)(eatAnimationTick - 4) - a) /
|
||||
(float)(EAT_ANIMATION_TICKS - 8);
|
||||
return std::numbers::pi * .20f + std::numbers::pi * .07f * sinf(scale * 28.7f);
|
||||
return std::numbers::pi * .20f +
|
||||
std::numbers::pi * .07f * sinf(scale * 28.7f);
|
||||
}
|
||||
if (eatAnimationTick > 0) {
|
||||
return std::numbers::pi * .20f;
|
||||
|
||||
@@ -63,8 +63,8 @@ bool Squid::makeStepSound() { return false; }
|
||||
void Squid::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) {
|
||||
int count = random->nextInt(3 + playerBonusLevel) + 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
spawnAtLocation(std::make_shared<ItemInstance>(
|
||||
Item::dye_powder, 1, DyePowderItem::BLACK),
|
||||
spawnAtLocation(std::make_shared<ItemInstance>(Item::dye_powder, 1,
|
||||
DyePowderItem::BLACK),
|
||||
0.0f);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,8 @@ void Squid::aiStep() {
|
||||
if (tentacleMovement < std::numbers::pi) {
|
||||
float tentacleScale = tentacleMovement / std::numbers::pi;
|
||||
tentacleAngle =
|
||||
sinf(tentacleScale * tentacleScale * std::numbers::pi) * std::numbers::pi * 0.25f;
|
||||
sinf(tentacleScale * tentacleScale * std::numbers::pi) *
|
||||
std::numbers::pi * 0.25f;
|
||||
|
||||
if (tentacleScale > .75) {
|
||||
speed = 1.0f;
|
||||
@@ -117,14 +118,18 @@ void Squid::aiStep() {
|
||||
|
||||
double horizontalMovement = sqrt(xd * xd + zd * zd);
|
||||
|
||||
yBodyRot += ((-(float)atan2(xd, zd) * 180 / std::numbers::pi) - yBodyRot) * 0.1f;
|
||||
yBodyRot +=
|
||||
((-(float)atan2(xd, zd) * 180 / std::numbers::pi) - yBodyRot) *
|
||||
0.1f;
|
||||
yRot = yBodyRot;
|
||||
zBodyRot = zBodyRot + (float)std::numbers::pi * rotateSpeed * 1.5f;
|
||||
xBodyRot +=
|
||||
((-(float)atan2(horizontalMovement, yd) * 180 / std::numbers::pi) - xBodyRot) *
|
||||
((-(float)atan2(horizontalMovement, yd) * 180 / std::numbers::pi) -
|
||||
xBodyRot) *
|
||||
0.1f;
|
||||
} else {
|
||||
tentacleAngle = Mth::abs(sinf(tentacleMovement)) * std::numbers::pi * 0.25f;
|
||||
tentacleAngle =
|
||||
Mth::abs(sinf(tentacleMovement)) * std::numbers::pi * 0.25f;
|
||||
|
||||
if (!level->isClientSide) {
|
||||
// unable to move, apply gravity
|
||||
|
||||
@@ -238,8 +238,8 @@ float Wolf::getBodyRollAngle(float a, float offset) {
|
||||
} else if (progress > 1) {
|
||||
progress = 1;
|
||||
}
|
||||
return sinf(progress * std::numbers::pi) * sinf(progress * std::numbers::pi * 11.0f) * 0.15f *
|
||||
std::numbers::pi;
|
||||
return sinf(progress * std::numbers::pi) *
|
||||
sinf(progress * std::numbers::pi * 11.0f) * 0.15f * std::numbers::pi;
|
||||
}
|
||||
|
||||
float Wolf::getHeadRollAngle(float a) {
|
||||
@@ -461,8 +461,7 @@ std::shared_ptr<AgableMob> Wolf::getBreedOffspring(
|
||||
std::shared_ptr<AgableMob> target) {
|
||||
// 4J - added limit to wolves that can be bred
|
||||
if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) {
|
||||
std::shared_ptr<Wolf> pBabyWolf =
|
||||
std::make_shared<Wolf>(level);
|
||||
std::shared_ptr<Wolf> pBabyWolf = std::make_shared<Wolf>(level);
|
||||
|
||||
if (!getOwnerUUID().empty()) {
|
||||
// set the baby wolf to be tame, and assign the owner
|
||||
|
||||
@@ -168,7 +168,8 @@ void EnderDragon::defineSynchedData() {
|
||||
e_EnderdragonAction_HoldingPattern);
|
||||
}
|
||||
|
||||
void EnderDragon::getLatencyPos(std::vector<double>& result, int step, float a) {
|
||||
void EnderDragon::getLatencyPos(std::vector<double>& result, int step,
|
||||
float a) {
|
||||
if (getHealth() <= 0) {
|
||||
a = 0;
|
||||
}
|
||||
@@ -319,7 +320,7 @@ void EnderDragon::aiStep() {
|
||||
// d < 3; ++d)
|
||||
{
|
||||
Vec3 vN = Vec3{v.x, v.y, v.z}.normalize();
|
||||
vN.yRot(-std::numbers::pi / 4);
|
||||
vN.yRot(-std::numbers::pi / 4);
|
||||
|
||||
for (unsigned int i = 0; i < 8; ++i) {
|
||||
if (getSynchedAction() == e_EnderdragonAction_Landing) {
|
||||
@@ -484,7 +485,8 @@ void EnderDragon::aiStep() {
|
||||
Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z))
|
||||
.normalize();
|
||||
|
||||
Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0, -cos(yRot * std::numbers::pi / 180))
|
||||
Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0,
|
||||
-cos(yRot * std::numbers::pi / 180))
|
||||
.normalize();
|
||||
|
||||
float dot = (float)dir.dot(aim);
|
||||
@@ -498,7 +500,8 @@ void EnderDragon::aiStep() {
|
||||
// 2);
|
||||
double zdd = attackTarget->z - head->z;
|
||||
|
||||
double yRotT = (180) - atan2(xdd, zdd) * 180 / std::numbers::pi;
|
||||
double yRotT =
|
||||
(180) - atan2(xdd, zdd) * 180 / std::numbers::pi;
|
||||
double yRotD = Mth::wrapDegrees(yRotT - yRot);
|
||||
|
||||
if (yRotD > 50) yRotD = 50;
|
||||
@@ -568,7 +571,8 @@ void EnderDragon::aiStep() {
|
||||
Vec3 aim =
|
||||
Vec3((xTarget - x), (yTarget - y), (zTarget - z)).normalize();
|
||||
|
||||
Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), yd, -cos(yRot * std::numbers::pi / 180))
|
||||
Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), yd,
|
||||
-cos(yRot * std::numbers::pi / 180))
|
||||
.normalize();
|
||||
float dot = (float)(dir.dot(aim) + 0.5f) / 1.5f;
|
||||
if (dot < 0) dot = 0;
|
||||
@@ -620,8 +624,9 @@ void EnderDragon::aiStep() {
|
||||
wing2->bbWidth = 4;
|
||||
|
||||
// double latencyPosAcomponents[3],latencyPosBcomponents[3];
|
||||
// std::vector<double> latencyPosA = std::vector<double>(latencyPosAcomponents,3);
|
||||
// std::vector<double> latencyPosB = std::vector<double>(latencyPosBcomponents,3);
|
||||
// std::vector<double> latencyPosA =
|
||||
// std::vector<double>(latencyPosAcomponents,3); std::vector<double>
|
||||
// latencyPosB = std::vector<double>(latencyPosBcomponents,3);
|
||||
// getLatencyPos(latencyPosA, 5, 1);
|
||||
// getLatencyPos(latencyPosB, 10, 1);
|
||||
|
||||
@@ -660,18 +665,21 @@ void EnderDragon::aiStep() {
|
||||
}
|
||||
|
||||
double p1components[3];
|
||||
std::vector<double> p1 = std::vector<double>(p1components, p1components + 3);
|
||||
std::vector<double> p1 =
|
||||
std::vector<double>(p1components, p1components + 3);
|
||||
getLatencyPos(p1, 5, 1);
|
||||
|
||||
{
|
||||
// double p0components[3];
|
||||
// std::vector<double> p0 = std::vector<double>(p0components, p0components + 3);
|
||||
// getLatencyPos(p0, 0, 1);
|
||||
// std::vector<double> p0 = std::vector<double>(p0components,
|
||||
// p0components + 3); getLatencyPos(p0, 0, 1);
|
||||
|
||||
double yRotDiff = getHeadYRotDiff(1);
|
||||
|
||||
float ss = sin((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f);
|
||||
float cc = cos((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f);
|
||||
float ss =
|
||||
sin((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f);
|
||||
float cc =
|
||||
cos((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f);
|
||||
head->tick();
|
||||
neck->tick();
|
||||
double yOffset = getHeadYOffset(1); // (p0[1] - p1[1]) * 1
|
||||
@@ -715,10 +723,12 @@ void EnderDragon::aiStep() {
|
||||
if (i == 2) part = tail3;
|
||||
|
||||
double p0components[3];
|
||||
std::vector<double> p0 = std::vector<double>(p0components, p0components + 3);
|
||||
std::vector<double> p0 =
|
||||
std::vector<double>(p0components, p0components + 3);
|
||||
getLatencyPos(p0, 12 + i * 2, 1);
|
||||
|
||||
float rot = yRot * std::numbers::pi / 180 + rotWrap(p0[0] - p1[0]) * std::numbers::pi / 180 * (1);
|
||||
float rot = yRot * std::numbers::pi / 180 +
|
||||
rotWrap(p0[0] - p1[0]) * std::numbers::pi / 180 * (1);
|
||||
float ss = sin(rot);
|
||||
float cc = cos(rot);
|
||||
|
||||
@@ -742,7 +752,8 @@ void EnderDragon::aiStep() {
|
||||
Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z))
|
||||
.normalize();
|
||||
|
||||
Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0, -cos(yRot * std::numbers::pi / 180))
|
||||
Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0,
|
||||
-cos(yRot * std::numbers::pi / 180))
|
||||
.normalize();
|
||||
|
||||
float dot = (float)dir.dot(aim);
|
||||
@@ -1532,18 +1543,24 @@ int EnderDragon::findClosestNode() {
|
||||
int yAdjustment = 5;
|
||||
multiplier = i;
|
||||
if (i < 12) {
|
||||
nodeX = 60 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 12) * multiplier));
|
||||
nodeZ = 60 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 12) * multiplier));
|
||||
nodeX = 60 * cosf(2 * (-std::numbers::pi +
|
||||
(std::numbers::pi / 12) * multiplier));
|
||||
nodeZ = 60 * sinf(2 * (-std::numbers::pi +
|
||||
(std::numbers::pi / 12) * multiplier));
|
||||
} else if (i < 20) {
|
||||
multiplier -= 12;
|
||||
nodeX = 40 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 8) * multiplier));
|
||||
nodeZ = 40 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 8) * multiplier));
|
||||
nodeX = 40 * cosf(2 * (-std::numbers::pi +
|
||||
(std::numbers::pi / 8) * multiplier));
|
||||
nodeZ = 40 * sinf(2 * (-std::numbers::pi +
|
||||
(std::numbers::pi / 8) * multiplier));
|
||||
yAdjustment +=
|
||||
10; // Make the target well above the top of the towers
|
||||
} else {
|
||||
multiplier -= 20;
|
||||
nodeX = 20 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 4) * multiplier));
|
||||
nodeZ = 20 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 4) * multiplier));
|
||||
nodeX = 20 * cosf(2 * (-std::numbers::pi +
|
||||
(std::numbers::pi / 4) * multiplier));
|
||||
nodeZ = 20 * sinf(2 * (-std::numbers::pi +
|
||||
(std::numbers::pi / 4) * multiplier));
|
||||
}
|
||||
// Fix for #77202 - TU9: Content: Gameplay: The Ender Dragon
|
||||
// sometimes flies through terrain Add minimum height
|
||||
@@ -1762,8 +1779,10 @@ float EnderDragon::getTilt(float a) {
|
||||
// else
|
||||
{
|
||||
double latencyPosAcomponents[3], latencyPosBcomponents[3];
|
||||
std::vector<double> latencyPosA = std::vector<double>(latencyPosAcomponents, latencyPosAcomponents + 3);
|
||||
std::vector<double> latencyPosB = std::vector<double>(latencyPosBcomponents, latencyPosBcomponents + 3);
|
||||
std::vector<double> latencyPosA = std::vector<double>(
|
||||
latencyPosAcomponents, latencyPosAcomponents + 3);
|
||||
std::vector<double> latencyPosB = std::vector<double>(
|
||||
latencyPosBcomponents, latencyPosBcomponents + 3);
|
||||
getLatencyPos(latencyPosA, 5, a);
|
||||
getLatencyPos(latencyPosB, 10, a);
|
||||
|
||||
@@ -1782,11 +1801,13 @@ double EnderDragon::getHeadYOffset(float a) {
|
||||
headYOffset = -1.0;
|
||||
} else {
|
||||
double p1components[3];
|
||||
std::vector<double> p1 = std::vector<double>(p1components, p1components + 3);
|
||||
std::vector<double> p1 =
|
||||
std::vector<double>(p1components, p1components + 3);
|
||||
getLatencyPos(p1, 5, 1);
|
||||
|
||||
double p0components[3];
|
||||
std::vector<double> p0 = std::vector<double>(p0components, p0components + 3);
|
||||
std::vector<double> p0 =
|
||||
std::vector<double>(p0components, p0components + 3);
|
||||
getLatencyPos(p0, 0, 1);
|
||||
|
||||
headYOffset = (p0[1] - p1[1]) * 1;
|
||||
@@ -1806,7 +1827,8 @@ double EnderDragon::getHeadYRotDiff(float a) {
|
||||
return result;
|
||||
}
|
||||
|
||||
double EnderDragon::getHeadPartYOffset(int partIndex, std::vector<double>& bodyPos,
|
||||
double EnderDragon::getHeadPartYOffset(int partIndex,
|
||||
std::vector<double>& bodyPos,
|
||||
std::vector<double>& partPos) {
|
||||
double result = 0.0;
|
||||
if (getSynchedAction() == e_EnderdragonAction_Landing ||
|
||||
@@ -1834,7 +1856,8 @@ double EnderDragon::getHeadPartYOffset(int partIndex, std::vector<double>& bodyP
|
||||
return result;
|
||||
}
|
||||
|
||||
double EnderDragon::getHeadPartYRotDiff(int partIndex, std::vector<double>& bodyPos,
|
||||
double EnderDragon::getHeadPartYRotDiff(int partIndex,
|
||||
std::vector<double>& bodyPos,
|
||||
std::vector<double>& partPos) {
|
||||
double result = 0.0;
|
||||
// if( getSynchedAction() == e_EnderdragonAction_Sitting_Flaming ||
|
||||
|
||||
@@ -347,7 +347,8 @@ double WitherBoss::getHeadX(int index) {
|
||||
if (index <= 0) {
|
||||
return x;
|
||||
}
|
||||
float headAngle = (yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi;
|
||||
float headAngle =
|
||||
(yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi;
|
||||
float cos = cosf(headAngle);
|
||||
return x + cos * 1.3;
|
||||
}
|
||||
@@ -364,7 +365,8 @@ double WitherBoss::getHeadZ(int index) {
|
||||
if (index <= 0) {
|
||||
return z;
|
||||
}
|
||||
float headAngle = (yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi;
|
||||
float headAngle =
|
||||
(yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi;
|
||||
float sin = sinf(headAngle);
|
||||
return z + sin * 1.3;
|
||||
}
|
||||
@@ -400,10 +402,9 @@ void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz,
|
||||
double yd = ty - hy;
|
||||
double zd = tz - hz;
|
||||
|
||||
std::shared_ptr<WitherSkull> ie =
|
||||
std::make_shared<WitherSkull>(
|
||||
level, std::dynamic_pointer_cast<LivingEntity>(shared_from_this()),
|
||||
xd, yd, zd);
|
||||
std::shared_ptr<WitherSkull> ie = std::make_shared<WitherSkull>(
|
||||
level, std::dynamic_pointer_cast<LivingEntity>(shared_from_this()), xd,
|
||||
yd, zd);
|
||||
if (dangerous) ie->setDangerous(true);
|
||||
ie->y = hy;
|
||||
ie->x = hx;
|
||||
|
||||
@@ -134,8 +134,8 @@ void FallingTile::tick() {
|
||||
CompoundTag* swap = new CompoundTag();
|
||||
tileEntity->save(swap);
|
||||
std::vector<Tag*> allTags = tileData->getAllTags();
|
||||
for (auto it = allTags.begin();
|
||||
it != allTags.end(); ++it) {
|
||||
for (auto it = allTags.begin(); it != allTags.end();
|
||||
++it) {
|
||||
Tag* tag = *it;
|
||||
if (tag->getName().compare(L"x") == 0 ||
|
||||
tag->getName().compare(L"y") == 0 ||
|
||||
|
||||
@@ -757,7 +757,8 @@ void Minecart::push(std::shared_ptr<Entity> e) {
|
||||
Vec3 dir(xo, 0, zo);
|
||||
dir = dir.normalize();
|
||||
|
||||
Vec3 facing(cos(yRot * std::numbers::pi / 180), 0, sin(yRot * std::numbers::pi / 180));
|
||||
Vec3 facing(cos(yRot * std::numbers::pi / 180), 0,
|
||||
sin(yRot * std::numbers::pi / 180));
|
||||
facing = facing.normalize();
|
||||
|
||||
double dot = abs(dir.dot(facing));
|
||||
|
||||
@@ -42,8 +42,8 @@ void MinecartContainer::destroy(DamageSource* source) {
|
||||
std::shared_ptr<ItemEntity> itemEntity =
|
||||
std::make_shared<ItemEntity>(
|
||||
level, x + xo, y + yo, z + zo,
|
||||
std::make_shared<ItemInstance>(
|
||||
item->id, count, item->getAuxValue()));
|
||||
std::make_shared<ItemInstance>(item->id, count,
|
||||
item->getAuxValue()));
|
||||
float pow = 0.05f;
|
||||
itemEntity->xd = (float)random->nextGaussian() * pow;
|
||||
itemEntity->yd = (float)random->nextGaussian() * pow + 0.2f;
|
||||
|
||||
@@ -66,9 +66,7 @@ void MinecartFurnace::destroy(DamageSource* source) {
|
||||
Minecart::destroy(source);
|
||||
|
||||
if (!source->isExplosion()) {
|
||||
spawnAtLocation(
|
||||
std::make_shared<ItemInstance>(Tile::furnace, 1),
|
||||
0);
|
||||
spawnAtLocation(std::make_shared<ItemInstance>(Tile::furnace, 1), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,7 @@ void MinecartTNT::destroy(DamageSource* source) {
|
||||
double speedSqr = xd * xd + zd * zd;
|
||||
|
||||
if (!source->isExplosion()) {
|
||||
spawnAtLocation(
|
||||
std::make_shared<ItemInstance>(Tile::tnt, 1), 0);
|
||||
spawnAtLocation(std::make_shared<ItemInstance>(Tile::tnt, 1), 0);
|
||||
}
|
||||
|
||||
if (source->isFire() || source->isExplosion() || speedSqr >= 0.01f) {
|
||||
|
||||
@@ -39,7 +39,7 @@ AttributeModifier* EnderMan::SPEED_MODIFIER_ATTACKING =
|
||||
bool EnderMan::MAY_TAKE[256];
|
||||
|
||||
void EnderMan::staticCtor() {
|
||||
memset(MAY_TAKE, 0, sizeof(bool) * 256);
|
||||
memset(MAY_TAKE, 0, sizeof(bool) * 256);
|
||||
MAY_TAKE[Tile::grass_Id] = true;
|
||||
MAY_TAKE[Tile::dirt_Id] = true;
|
||||
MAY_TAKE[Tile::sand_Id] = true;
|
||||
|
||||
@@ -164,7 +164,8 @@ void Ghast::serverAiStep() {
|
||||
if (charge > 0) charge--;
|
||||
}
|
||||
} else {
|
||||
yBodyRot = yRot = -(float)atan2(this->xd, this->zd) * 180 / std::numbers::pi;
|
||||
yBodyRot = yRot =
|
||||
-(float)atan2(this->xd, this->zd) * 180 / std::numbers::pi;
|
||||
if (charge > 0) charge--;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,8 @@ bool Monster::doHurtTarget(std::shared_ptr<Entity> target) {
|
||||
|
||||
if (wasHurt) {
|
||||
if (knockback > 0) {
|
||||
target->push(-sinf(yRot * std::numbers::pi / 180) * knockback * .5f, 0.1,
|
||||
target->push(-sinf(yRot * std::numbers::pi / 180) * knockback * .5f,
|
||||
0.1,
|
||||
cosf(yRot * std::numbers::pi / 180) * knockback * .5f);
|
||||
xd *= 0.6;
|
||||
zd *= 0.6;
|
||||
|
||||
@@ -5,7 +5,8 @@ class AttributeInstance;
|
||||
class AttributeModifier;
|
||||
class BaseAttributeMap;
|
||||
class CompoundTag;
|
||||
template <class T> class ListTag;
|
||||
template <class T>
|
||||
class ListTag;
|
||||
|
||||
class SharedMonsterAttributes {
|
||||
public:
|
||||
|
||||
@@ -214,8 +214,7 @@ void Skeleton::dropRareDeathLoot(int rareLootLevel) {
|
||||
void Skeleton::populateDefaultEquipmentSlots() {
|
||||
Monster::populateDefaultEquipmentSlots();
|
||||
|
||||
setEquippedSlot(SLOT_WEAPON,
|
||||
std::make_shared<ItemInstance>(Item::bow));
|
||||
setEquippedSlot(SLOT_WEAPON, std::make_shared<ItemInstance>(Item::bow));
|
||||
}
|
||||
|
||||
MobGroupData* Skeleton::finalizeMobSpawn(
|
||||
|
||||
@@ -159,8 +159,7 @@ MobGroupData* Spider::finalizeMobSpawn(
|
||||
if (level->random->nextInt(100) == 0)
|
||||
#endif
|
||||
{
|
||||
std::shared_ptr<Skeleton> skeleton =
|
||||
std::make_shared<Skeleton>(level);
|
||||
std::shared_ptr<Skeleton> skeleton = std::make_shared<Skeleton>(level);
|
||||
skeleton->moveTo(x, y, z, yRot, 0);
|
||||
skeleton->finalizeMobSpawn(nullptr);
|
||||
level->addEntity(skeleton);
|
||||
|
||||
@@ -211,10 +211,9 @@ void Witch::performRangedAttack(std::shared_ptr<LivingEntity> target,
|
||||
float power) {
|
||||
if (isUsingItem()) return;
|
||||
|
||||
std::shared_ptr<ThrownPotion> potion =
|
||||
std::make_shared<ThrownPotion>(
|
||||
level, std::dynamic_pointer_cast<LivingEntity>(shared_from_this()),
|
||||
PotionBrewing::POTION_ID_SPLASH_DAMAGE);
|
||||
std::shared_ptr<ThrownPotion> potion = std::make_shared<ThrownPotion>(
|
||||
level, std::dynamic_pointer_cast<LivingEntity>(shared_from_this()),
|
||||
PotionBrewing::POTION_ID_SPLASH_DAMAGE);
|
||||
potion->xRot -= -20;
|
||||
double xd = (target->x + target->xd) - x;
|
||||
double yd = (target->y + target->getHeadHeight() - 1.1f) - y;
|
||||
|
||||
@@ -193,13 +193,13 @@ bool Zombie::hurt(DamageSource* source, float dmg) {
|
||||
|
||||
for (int i = 0; i < REINFORCEMENT_ATTEMPTS; i++) {
|
||||
int xt = x + random->nextInt(REINFORCEMENT_RANGE_MIN,
|
||||
REINFORCEMENT_RANGE_MAX) *
|
||||
REINFORCEMENT_RANGE_MAX) *
|
||||
random->nextInt(-1, 1);
|
||||
int yt = y + random->nextInt(REINFORCEMENT_RANGE_MIN,
|
||||
REINFORCEMENT_RANGE_MAX) *
|
||||
REINFORCEMENT_RANGE_MAX) *
|
||||
random->nextInt(-1, 1);
|
||||
int zt = z + random->nextInt(REINFORCEMENT_RANGE_MIN,
|
||||
REINFORCEMENT_RANGE_MAX) *
|
||||
REINFORCEMENT_RANGE_MAX) *
|
||||
random->nextInt(-1, 1);
|
||||
|
||||
if (level->isTopSolidBlocking(xt, yt - 1, zt) &&
|
||||
@@ -334,8 +334,7 @@ void Zombie::killed(std::shared_ptr<LivingEntity> mob) {
|
||||
if (level->difficulty == Difficulty::NORMAL && random->nextBoolean())
|
||||
return;
|
||||
|
||||
std::shared_ptr<Zombie> zombie =
|
||||
std::make_shared<Zombie>(level);
|
||||
std::shared_ptr<Zombie> zombie = std::make_shared<Zombie>(level);
|
||||
zombie->copyPosition(mob);
|
||||
level->removeEntity(mob);
|
||||
zombie->finalizeMobSpawn(nullptr);
|
||||
@@ -473,8 +472,7 @@ bool Zombie::isConverting() {
|
||||
}
|
||||
|
||||
void Zombie::finishConversion() {
|
||||
std::shared_ptr<Villager> villager =
|
||||
std::make_shared<Villager>(level);
|
||||
std::shared_ptr<Villager> villager = std::make_shared<Villager>(level);
|
||||
villager->copyPosition(shared_from_this());
|
||||
villager->finalizeMobSpawn(nullptr);
|
||||
villager->setRewardPlayersInVillage();
|
||||
|
||||
@@ -372,8 +372,8 @@ void Villager::addOffers(int addCount) {
|
||||
new ItemInstance(Tile::gravel, 10)),
|
||||
std::shared_ptr<ItemInstance>(
|
||||
new ItemInstance(Item::emerald)),
|
||||
std::make_shared<ItemInstance>(
|
||||
Item::flint_Id, 4 + random->nextInt(2), 0)));
|
||||
std::make_shared<ItemInstance>(Item::flint_Id,
|
||||
4 + random->nextInt(2), 0)));
|
||||
}
|
||||
break;
|
||||
case PROFESSION_BUTCHER:
|
||||
@@ -474,7 +474,7 @@ void Villager::addOffers(int addCount) {
|
||||
Enchantment::validEnchantments[random->nextInt(
|
||||
Enchantment::validEnchantments.size())];
|
||||
int level = random->nextInt(enchantment->getMinLevel(),
|
||||
enchantment->getMaxLevel());
|
||||
enchantment->getMaxLevel());
|
||||
std::shared_ptr<ItemInstance> book =
|
||||
Item::enchantedBook->createForEnchantment(
|
||||
new EnchantmentInstance(enchantment, level));
|
||||
@@ -668,8 +668,7 @@ void Villager::addItemForPurchase(MerchantRecipeList* list, int itemId,
|
||||
} else {
|
||||
rubyItem = std::shared_ptr<ItemInstance>(
|
||||
new ItemInstance(Item::emerald_Id, purchaseCost, 0));
|
||||
resultItem =
|
||||
std::make_shared<ItemInstance>(itemId, 1, 0);
|
||||
resultItem = std::make_shared<ItemInstance>(itemId, 1, 0);
|
||||
}
|
||||
list->push_back(new MerchantRecipe(rubyItem, resultItem));
|
||||
}
|
||||
@@ -729,8 +728,7 @@ std::shared_ptr<AgableMob> Villager::getBreedOffspring(
|
||||
std::shared_ptr<AgableMob> target) {
|
||||
// 4J - added limit to villagers that can be bred
|
||||
if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) {
|
||||
std::shared_ptr<Villager> villager =
|
||||
std::make_shared<Villager>(level);
|
||||
std::shared_ptr<Villager> villager = std::make_shared<Villager>(level);
|
||||
villager->finalizeMobSpawn(nullptr);
|
||||
return villager;
|
||||
} else {
|
||||
|
||||
@@ -28,8 +28,7 @@ Inventory::Inventory(Player* player) {
|
||||
this->player = player;
|
||||
}
|
||||
|
||||
Inventory::~Inventory() {
|
||||
}
|
||||
Inventory::~Inventory() {}
|
||||
|
||||
std::shared_ptr<ItemInstance> Inventory::getSelected() {
|
||||
// sanity checking to prevent exploits
|
||||
@@ -341,7 +340,8 @@ bool Inventory::add(std::shared_ptr<ItemInstance> item) {
|
||||
|
||||
std::shared_ptr<ItemInstance> Inventory::removeItem(unsigned int slot,
|
||||
int count) {
|
||||
std::vector<std::shared_ptr<ItemInstance>>& pile = (slot >= items.size()) ? armor : items;
|
||||
std::vector<std::shared_ptr<ItemInstance>>& pile =
|
||||
(slot >= items.size()) ? armor : items;
|
||||
if (slot >= items.size()) {
|
||||
slot -= items.size();
|
||||
}
|
||||
@@ -361,7 +361,8 @@ std::shared_ptr<ItemInstance> Inventory::removeItem(unsigned int slot,
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemInstance> Inventory::removeItemNoUpdate(int slot) {
|
||||
std::vector<std::shared_ptr<ItemInstance>>& pile = (slot >= (int)items.size()) ? armor : items;
|
||||
std::vector<std::shared_ptr<ItemInstance>>& pile =
|
||||
(slot >= (int)items.size()) ? armor : items;
|
||||
if (slot >= (int)items.size()) {
|
||||
slot -= items.size();
|
||||
}
|
||||
@@ -564,8 +565,7 @@ bool Inventory::isSame(std::shared_ptr<ItemInstance> a,
|
||||
}
|
||||
|
||||
std::shared_ptr<Inventory> Inventory::copy() {
|
||||
std::shared_ptr<Inventory> copy =
|
||||
std::make_shared<Inventory>(nullptr);
|
||||
std::shared_ptr<Inventory> copy = std::make_shared<Inventory>(nullptr);
|
||||
for (unsigned int i = 0; i < items.size(); i++) {
|
||||
copy->items[i] = items[i] != nullptr ? items[i]->copy() : nullptr;
|
||||
}
|
||||
|
||||
@@ -899,7 +899,7 @@ void Player::aiStep() {
|
||||
pickupArea = bb.grow(1, .5, 1);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
std::vector<std::shared_ptr<Entity>>* entities =
|
||||
level->getEntities(shared_from_this(), &pickupArea);
|
||||
if (entities != nullptr) {
|
||||
auto itEnd = entities->end();
|
||||
@@ -934,8 +934,7 @@ void Player::die(DamageSource* source) {
|
||||
|
||||
// 4J - TODO need to use a xuid
|
||||
if (app.isXuidNotch(m_xuid)) {
|
||||
drop(std::make_shared<ItemInstance>(Item::apple, 1),
|
||||
true);
|
||||
drop(std::make_shared<ItemInstance>(Item::apple, 1), true);
|
||||
}
|
||||
if (!level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY)) {
|
||||
inventory->dropAll();
|
||||
@@ -1012,8 +1011,10 @@ std::shared_ptr<ItemEntity> Player::drop(std::shared_ptr<ItemInstance> item,
|
||||
|
||||
} else {
|
||||
pow = 0.3f;
|
||||
thrownItem->xd = -sin(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi) * pow;
|
||||
thrownItem->zd = cos(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi) * pow;
|
||||
thrownItem->xd = -sin(yRot / 180 * std::numbers::pi) *
|
||||
cos(xRot / 180 * std::numbers::pi) * pow;
|
||||
thrownItem->zd = cos(yRot / 180 * std::numbers::pi) *
|
||||
cos(xRot / 180 * std::numbers::pi) * pow;
|
||||
thrownItem->yd = -sin(xRot / 180 * std::numbers::pi) * pow + 0.1f;
|
||||
pow = 0.02f;
|
||||
|
||||
@@ -1396,8 +1397,9 @@ void Player::attack(std::shared_ptr<Entity> entity) {
|
||||
delete damageSource;
|
||||
if (wasHurt) {
|
||||
if (knockback > 0) {
|
||||
entity->push(-sinf(yRot * std::numbers::pi / 180) * knockback * .5f, 0.1,
|
||||
cosf(yRot * std::numbers::pi / 180) * knockback * .5f);
|
||||
entity->push(
|
||||
-sinf(yRot * std::numbers::pi / 180) * knockback * .5f, 0.1,
|
||||
cosf(yRot * std::numbers::pi / 180) * knockback * .5f);
|
||||
xd *= 0.6;
|
||||
zd *= 0.6;
|
||||
setSprinting(false);
|
||||
@@ -1528,7 +1530,7 @@ Player::BedSleepingResult Player::startSleepInBed(int x, int y, int z,
|
||||
double vRange = 5;
|
||||
AABB monster_bb =
|
||||
AABB(x, y, z, x, y, z).grow(hRange, vRange, hRange);
|
||||
std::vector<std::shared_ptr<Entity> >* monsters =
|
||||
std::vector<std::shared_ptr<Entity>>* monsters =
|
||||
level->getEntitiesOfClass(typeid(Monster), &monster_bb);
|
||||
if (!monsters->empty()) {
|
||||
delete monsters;
|
||||
@@ -2241,7 +2243,9 @@ bool Player::isInvisibleTo(std::shared_ptr<Player> player) {
|
||||
return isInvisible();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ItemInstance>> Player::getEquipmentSlots() { return inventory->armor; }
|
||||
std::vector<std::shared_ptr<ItemInstance>> Player::getEquipmentSlots() {
|
||||
return inventory->armor;
|
||||
}
|
||||
|
||||
bool Player::isCapeHidden() { return getPlayerFlag(FLAG_HIDE_CAPE); }
|
||||
|
||||
|
||||
@@ -123,8 +123,10 @@ Arrow::Arrow(Level* level, std::shared_ptr<LivingEntity> mob, float power)
|
||||
setPos(x, y, z);
|
||||
heightOffset = 0;
|
||||
|
||||
xd = -sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi);
|
||||
zd = cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi);
|
||||
xd = -sinf(yRot / 180 * std::numbers::pi) *
|
||||
cosf(xRot / 180 * std::numbers::pi);
|
||||
zd = cosf(yRot / 180 * std::numbers::pi) *
|
||||
cosf(xRot / 180 * std::numbers::pi);
|
||||
yd = -sinf(xRot / 180 * std::numbers::pi);
|
||||
|
||||
shoot(xd, yd, zd, power * 1.5f, 1);
|
||||
|
||||
@@ -90,8 +90,12 @@ FishingHook::FishingHook(Level* level, std::shared_ptr<Player> mob)
|
||||
heightOffset = 0;
|
||||
|
||||
float speed = 0.4f;
|
||||
xd = (-sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi)) * speed;
|
||||
zd = (cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi)) * speed;
|
||||
xd = (-sinf(yRot / 180 * std::numbers::pi) *
|
||||
cosf(xRot / 180 * std::numbers::pi)) *
|
||||
speed;
|
||||
zd = (cosf(yRot / 180 * std::numbers::pi) *
|
||||
cosf(xRot / 180 * std::numbers::pi)) *
|
||||
speed;
|
||||
yd = (-sinf(xRot / 180 * std::numbers::pi)) * speed;
|
||||
|
||||
shoot(xd, yd, zd, 1.5f, 1);
|
||||
@@ -408,10 +412,9 @@ int FishingHook::retrieve() {
|
||||
ie->Entity::yd = ya * speed + sqrt(dist) * 0.08;
|
||||
ie->Entity::zd = za * speed;
|
||||
level->addEntity(ie);
|
||||
owner->level->addEntity(
|
||||
std::make_shared<ExperienceOrb>(
|
||||
owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f,
|
||||
random->nextInt(6) + 1)); // 4J Stu brought forward from 1.4
|
||||
owner->level->addEntity(std::make_shared<ExperienceOrb>(
|
||||
owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f,
|
||||
random->nextInt(6) + 1)); // 4J Stu brought forward from 1.4
|
||||
dmg = 1;
|
||||
}
|
||||
if (inGround) dmg = 2;
|
||||
|
||||
@@ -58,9 +58,14 @@ Throwable::Throwable(Level* level, std::shared_ptr<LivingEntity> mob)
|
||||
heightOffset = 0;
|
||||
|
||||
float speed = 0.4f;
|
||||
xd = (-sin(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi)) * speed;
|
||||
zd = (cos(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi)) * speed;
|
||||
yd = (-sin((xRot + getThrowUpAngleOffset()) / 180 * std::numbers::pi)) * speed;
|
||||
xd = (-sin(yRot / 180 * std::numbers::pi) *
|
||||
cos(xRot / 180 * std::numbers::pi)) *
|
||||
speed;
|
||||
zd = (cos(yRot / 180 * std::numbers::pi) *
|
||||
cos(xRot / 180 * std::numbers::pi)) *
|
||||
speed;
|
||||
yd = (-sin((xRot + getThrowUpAngleOffset()) / 180 * std::numbers::pi)) *
|
||||
speed;
|
||||
|
||||
shoot(xd, yd, zd, getThrowPower(), 1);
|
||||
}
|
||||
|
||||
@@ -77,15 +77,13 @@ float ThrownPotion::getThrowUpAngleOffset() { return -20; }
|
||||
|
||||
void ThrownPotion::setPotionValue(int potionValue) {
|
||||
if (potionItem == nullptr)
|
||||
potionItem =
|
||||
std::make_shared<ItemInstance>(Item::potion, 1, 0);
|
||||
potionItem = std::make_shared<ItemInstance>(Item::potion, 1, 0);
|
||||
potionItem->setAuxValue(potionValue);
|
||||
}
|
||||
|
||||
int ThrownPotion::getPotionValue() {
|
||||
if (potionItem == nullptr)
|
||||
potionItem =
|
||||
std::make_shared<ItemInstance>(Item::potion, 1, 0);
|
||||
potionItem = std::make_shared<ItemInstance>(Item::potion, 1, 0);
|
||||
return potionItem->getAuxValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ Slot* AbstractContainerMenu::addSlot(Slot* slot) {
|
||||
void AbstractContainerMenu::addSlotListener(ContainerListener* listener) {
|
||||
containerListeners.push_back(listener);
|
||||
|
||||
std::vector<std::shared_ptr<ItemInstance> >* items = getItems();
|
||||
std::vector<std::shared_ptr<ItemInstance>>* items = getItems();
|
||||
listener->refreshContainer(this, items);
|
||||
delete items;
|
||||
broadcastChanges();
|
||||
@@ -53,9 +53,9 @@ void AbstractContainerMenu::removeSlotListener(ContainerListener* listener) {
|
||||
if (it != containerListeners.end()) containerListeners.erase(it);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ItemInstance> >* AbstractContainerMenu::getItems() {
|
||||
std::vector<std::shared_ptr<ItemInstance> >* items =
|
||||
new std::vector<std::shared_ptr<ItemInstance> >();
|
||||
std::vector<std::shared_ptr<ItemInstance>>* AbstractContainerMenu::getItems() {
|
||||
std::vector<std::shared_ptr<ItemInstance>>* items =
|
||||
new std::vector<std::shared_ptr<ItemInstance>>();
|
||||
auto itEnd = slots.end();
|
||||
for (auto it = slots.begin(); it != itEnd; it++) {
|
||||
items->push_back((*it)->getItem());
|
||||
@@ -507,7 +507,8 @@ void AbstractContainerMenu::setItem(unsigned int slot,
|
||||
getSlot(slot)->set(item);
|
||||
}
|
||||
|
||||
void AbstractContainerMenu::setAll(std::vector<std::shared_ptr<ItemInstance>>* items) {
|
||||
void AbstractContainerMenu::setAll(
|
||||
std::vector<std::shared_ptr<ItemInstance>>* items) {
|
||||
for (unsigned int i = 0; i < items->size(); i++) {
|
||||
getSlot(i)->set((*items)[i]);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
static const int CONTAINER_ID_INVENTORY = 0;
|
||||
static const int CONTAINER_ID_CREATIVE = -2;
|
||||
|
||||
std::vector<std::shared_ptr<ItemInstance> > lastSlots;
|
||||
std::vector<std::shared_ptr<ItemInstance>> lastSlots;
|
||||
std::vector<Slot*> slots;
|
||||
int containerId;
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
virtual ~AbstractContainerMenu();
|
||||
virtual void addSlotListener(ContainerListener* listener);
|
||||
virtual void removeSlotListener(ContainerListener* listener);
|
||||
virtual std::vector<std::shared_ptr<ItemInstance> >* getItems();
|
||||
virtual std::vector<std::shared_ptr<ItemInstance>>* getItems();
|
||||
virtual void sendData(int id, int value);
|
||||
virtual void broadcastChanges();
|
||||
virtual bool needsRendered();
|
||||
|
||||
@@ -25,8 +25,7 @@ const int CraftingMenu::USE_ROW_SLOT_END = CraftingMenu::USE_ROW_SLOT_START + 9;
|
||||
CraftingMenu::CraftingMenu(std::shared_ptr<Inventory> inventory, Level* level,
|
||||
int xt, int yt, int zt)
|
||||
: AbstractContainerMenu() {
|
||||
craftSlots =
|
||||
std::make_shared<CraftingContainer>(this, 3, 3);
|
||||
craftSlots = std::make_shared<CraftingContainer>(this, 3, 3);
|
||||
resultSlots = std::make_shared<ResultContainer>();
|
||||
|
||||
this->level = level;
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
EnchantmentMenu::EnchantmentMenu(std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int xt, int yt, int zt) {
|
||||
enchantSlots =
|
||||
std::make_shared<EnchantmentContainer>(this);
|
||||
enchantSlots = std::make_shared<EnchantmentContainer>(this);
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
costs[i] = 0;
|
||||
|
||||
@@ -21,8 +21,7 @@ FireworksMenu::FireworksMenu(std::shared_ptr<Inventory> inventory, Level* level,
|
||||
m_canMakeCharge = false;
|
||||
m_canMakeFade = false;
|
||||
|
||||
craftSlots =
|
||||
std::make_shared<CraftingContainer>(this, 3, 3);
|
||||
craftSlots = std::make_shared<CraftingContainer>(this, 3, 3);
|
||||
resultSlots = std::make_shared<ResultContainer>();
|
||||
|
||||
this->level = level;
|
||||
|
||||
@@ -35,8 +35,7 @@ InventoryMenu::InventoryMenu(std::shared_ptr<Inventory> inventory, bool active,
|
||||
}
|
||||
|
||||
void InventoryMenu::_init(std::shared_ptr<Inventory> inventory, bool active) {
|
||||
craftSlots =
|
||||
std::make_shared<CraftingContainer>(this, 2, 2);
|
||||
craftSlots = std::make_shared<CraftingContainer>(this, 2, 2);
|
||||
resultSlots = std::make_shared<ResultContainer>();
|
||||
|
||||
this->active = active;
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
MenuBackup::MenuBackup(std::shared_ptr<Inventory> inventory,
|
||||
AbstractContainerMenu* menu) {
|
||||
backups = new std::unordered_map<short, std::vector<std::shared_ptr<ItemInstance>>*>();
|
||||
backups =
|
||||
new std::unordered_map<short,
|
||||
std::vector<std::shared_ptr<ItemInstance>>*>();
|
||||
|
||||
this->inventory = inventory;
|
||||
this->menu = menu;
|
||||
@@ -16,7 +18,8 @@ MenuBackup::MenuBackup(std::shared_ptr<Inventory> inventory,
|
||||
|
||||
void MenuBackup::save(short changeUid) {
|
||||
std::vector<std::shared_ptr<ItemInstance>>* backup =
|
||||
new std::vector<std::shared_ptr<ItemInstance>>((int)menu->slots.size() + 1);
|
||||
new std::vector<std::shared_ptr<ItemInstance>>((int)menu->slots.size() +
|
||||
1);
|
||||
(*backup)[0] = ItemInstance::clone(inventory->getCarried());
|
||||
for (unsigned int i = 0; i < menu->slots.size(); i++) {
|
||||
(*backup)[i + 1] = ItemInstance::clone(menu->slots.at(i)->getItem());
|
||||
|
||||
@@ -10,7 +10,8 @@ class ItemInstance;
|
||||
|
||||
class MenuBackup {
|
||||
private:
|
||||
std::unordered_map<short, std::vector<std::shared_ptr<ItemInstance>>*>* backups;
|
||||
std::unordered_map<short, std::vector<std::shared_ptr<ItemInstance>>*>*
|
||||
backups;
|
||||
std::shared_ptr<Inventory> inventory;
|
||||
AbstractContainerMenu* menu;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ MerchantContainer::MerchantContainer(std::shared_ptr<Player> player,
|
||||
selectionHint = 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned int MerchantContainer::getContainerSize() { return items.size(); }
|
||||
|
||||
std::shared_ptr<ItemInstance> MerchantContainer::getItem(unsigned int slot) {
|
||||
|
||||
@@ -14,8 +14,7 @@ ColoredTileItem::ColoredTileItem(int id, bool stackedByData) : TileItem(id) {
|
||||
}
|
||||
}
|
||||
|
||||
ColoredTileItem::~ColoredTileItem() {
|
||||
}
|
||||
ColoredTileItem::~ColoredTileItem() {}
|
||||
|
||||
int ColoredTileItem::getColor(std::shared_ptr<ItemInstance> item,
|
||||
int spriteLayer) {
|
||||
|
||||
@@ -24,7 +24,8 @@ public:
|
||||
virtual Icon* getIcon(int auxValue);
|
||||
virtual int getLevelDataForAuxValue(int auxValue);
|
||||
|
||||
ColoredTileItem* setDescriptionPostfixes(std::vector<int>& descriptionPostfixes);
|
||||
ColoredTileItem* setDescriptionPostfixes(
|
||||
std::vector<int>& descriptionPostfixes);
|
||||
virtual unsigned int getDescriptionId(
|
||||
std::shared_ptr<ItemInstance> instance);
|
||||
};
|
||||
|
||||
@@ -21,7 +21,8 @@ private:
|
||||
protected:
|
||||
const Tier* tier;
|
||||
|
||||
DiggerItem(int id, float attackDamage, const Tier* tier, std::vector<Tile*>* tiles);
|
||||
DiggerItem(int id, float attackDamage, const Tier* tier,
|
||||
std::vector<Tile*>* tiles);
|
||||
|
||||
public:
|
||||
virtual float getDestroySpeed(std::shared_ptr<ItemInstance> itemInstance,
|
||||
|
||||
@@ -22,7 +22,6 @@ std::shared_ptr<ItemInstance> EggItem::use(
|
||||
level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f,
|
||||
0.4f / (random->nextFloat() * 0.4f + 0.8f));
|
||||
if (!level->isClientSide)
|
||||
level->addEntity(
|
||||
std::make_shared<ThrownEgg>(level, player));
|
||||
level->addEntity(std::make_shared<ThrownEgg>(level, player));
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -108,8 +108,7 @@ void EnchantedBookItem::addEnchantment(std::shared_ptr<ItemInstance> item,
|
||||
|
||||
std::shared_ptr<ItemInstance> EnchantedBookItem::createForEnchantment(
|
||||
EnchantmentInstance* enchant) {
|
||||
std::shared_ptr<ItemInstance> item =
|
||||
std::make_shared<ItemInstance>(this);
|
||||
std::shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(this);
|
||||
addEnchantment(item, enchant);
|
||||
return item;
|
||||
}
|
||||
@@ -128,8 +127,8 @@ std::shared_ptr<ItemInstance> EnchantedBookItem::createForRandomLoot(
|
||||
Enchantment::validEnchantments.size())];
|
||||
std::shared_ptr<ItemInstance> book =
|
||||
std::make_shared<ItemInstance>(id, 1, 0);
|
||||
int level = random->nextInt(enchantment->getMinLevel(),
|
||||
enchantment->getMaxLevel());
|
||||
int level =
|
||||
random->nextInt(enchantment->getMinLevel(), enchantment->getMaxLevel());
|
||||
|
||||
addEnchantment(book, new EnchantmentInstance(enchantment, level));
|
||||
|
||||
@@ -148,8 +147,8 @@ WeighedTreasure* EnchantedBookItem::createForRandomTreasure(Random* random,
|
||||
Enchantment::validEnchantments.size())];
|
||||
std::shared_ptr<ItemInstance> book =
|
||||
std::make_shared<ItemInstance>(id, 1, 0);
|
||||
int level = random->nextInt(enchantment->getMinLevel(),
|
||||
enchantment->getMaxLevel());
|
||||
int level =
|
||||
random->nextInt(enchantment->getMinLevel(), enchantment->getMaxLevel());
|
||||
|
||||
addEnchantment(book, new EnchantmentInstance(enchantment, level));
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ class CompoundTag;
|
||||
class Enchantment;
|
||||
class Random;
|
||||
class WeighedTreasure;
|
||||
template <class T> class ListTag;
|
||||
template <class T>
|
||||
class ListTag;
|
||||
|
||||
class EnchantedBookItem : public Item {
|
||||
public:
|
||||
|
||||
@@ -94,7 +94,8 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag,
|
||||
}
|
||||
|
||||
// colors
|
||||
std::vector<int> colorList = expTag->getIntArray(FireworksItem::TAG_E_COLORS);
|
||||
std::vector<int> colorList =
|
||||
expTag->getIntArray(FireworksItem::TAG_E_COLORS);
|
||||
if (colorList.size() > 0) {
|
||||
bool first = true;
|
||||
std::wstring output = L"";
|
||||
@@ -124,7 +125,8 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag,
|
||||
}
|
||||
|
||||
// has fade?
|
||||
std::vector<int> fadeList = expTag->getIntArray(FireworksItem::TAG_E_FADECOLORS);
|
||||
std::vector<int> fadeList =
|
||||
expTag->getIntArray(FireworksItem::TAG_E_FADECOLORS);
|
||||
if (fadeList.size() > 0) {
|
||||
bool first = true;
|
||||
std::wstring output =
|
||||
|
||||
@@ -44,8 +44,7 @@ std::shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum,
|
||||
int aux = idNum;
|
||||
|
||||
id = std::wstring(L"map_") + _toString(aux);
|
||||
mapItemSavedData =
|
||||
std::make_shared<MapItemSavedData>(id);
|
||||
mapItemSavedData = std::make_shared<MapItemSavedData>(id);
|
||||
|
||||
level->setSavedData(id, (std::shared_ptr<SavedData>)mapItemSavedData);
|
||||
}
|
||||
@@ -69,8 +68,7 @@ std::shared_ptr<MapItemSavedData> MapItem::getSavedData(
|
||||
// itemInstance->setAuxValue(level->getFreeAuxValueFor(L"map"));
|
||||
|
||||
id = std::wstring(L"map_") + _toString(itemInstance->getAuxValue());
|
||||
mapItemSavedData =
|
||||
std::make_shared<MapItemSavedData>(id);
|
||||
mapItemSavedData = std::make_shared<MapItemSavedData>(id);
|
||||
|
||||
newData = true;
|
||||
}
|
||||
@@ -304,13 +302,12 @@ std::shared_ptr<Packet> MapItem::getUpdatePacket(
|
||||
std::shared_ptr<ItemInstance> itemInstance, Level* level,
|
||||
std::shared_ptr<Player> player) {
|
||||
std::vector<char> data = MapItem::getSavedData(itemInstance, level)
|
||||
->getUpdatePacket(itemInstance, level, player);
|
||||
->getUpdatePacket(itemInstance, level, player);
|
||||
|
||||
if (data.empty()) return nullptr;
|
||||
|
||||
std::shared_ptr<Packet> retval =
|
||||
std::make_shared<ComplexItemDataPacket>(
|
||||
(short)Item::map->id, (short)itemInstance->getAuxValue(), data);
|
||||
std::shared_ptr<Packet> retval = std::make_shared<ComplexItemDataPacket>(
|
||||
(short)Item::map->id, (short)itemInstance->getAuxValue(), data);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ TilePlanterItem::TilePlanterItem(int id, Tile* tile) : Item(id) {
|
||||
}
|
||||
|
||||
bool TilePlanterItem::useOn(std::shared_ptr<ItemInstance> instance,
|
||||
std::shared_ptr<Player> player, Level* level, int x,
|
||||
std::shared_ptr<Player> player, Level* level, int x,
|
||||
int y, int z, int face, float clickX, float clickY,
|
||||
float clickZ, bool bTestUseOnOnly) {
|
||||
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||
|
||||
@@ -24,7 +24,6 @@ std::shared_ptr<ItemInstance> SnowballItem::use(
|
||||
eSoundType_RANDOM_BOW, 0.5f,
|
||||
0.4f / (random->nextFloat() * 0.4f + 0.8f));
|
||||
if (!level->isClientSide)
|
||||
level->addEntity(
|
||||
std::make_shared<Snowball>(level, player));
|
||||
level->addEntity(std::make_shared<Snowball>(level, player));
|
||||
return instance;
|
||||
}
|
||||
@@ -148,10 +148,10 @@ void ArmorDyeRecipe::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) {
|
||||
TempIngReq.iIngValA = new int[3 * 3];
|
||||
TempIngReq.iIngAuxValA = new int[3 * 3];
|
||||
|
||||
memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngValA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngValA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngAuxValA, Recipes::ANY_AUX_VALUE, sizeof(int) * 9);
|
||||
memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9);
|
||||
memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9);
|
||||
|
||||
pIngReq->iIngIDA = new int[TempIngReq.iIngC];
|
||||
pIngReq->iIngValA = new int[TempIngReq.iIngC];
|
||||
|
||||
@@ -100,8 +100,7 @@ bool FireworksRecipe::matches(std::shared_ptr<CraftingContainer> craftSlots,
|
||||
|
||||
// create fireworks
|
||||
if (sulphurCount >= 1 && paperCount == 1 && chargeComponents == 0) {
|
||||
resultItem =
|
||||
std::make_shared<ItemInstance>(Item::fireworks);
|
||||
resultItem = std::make_shared<ItemInstance>(Item::fireworks);
|
||||
if (chargeCount > 0) {
|
||||
CompoundTag* itemTag = new CompoundTag();
|
||||
CompoundTag* fireTag =
|
||||
@@ -201,13 +200,11 @@ bool FireworksRecipe::matches(std::shared_ptr<CraftingContainer> craftSlots,
|
||||
CompoundTag* compound =
|
||||
resultItem->getTag()->getCompound(FireworksItem::TAG_EXPLOSION);
|
||||
if (compound == nullptr) {
|
||||
|
||||
setResultItem(resultItem);
|
||||
return false;
|
||||
}
|
||||
compound->putIntArray(FireworksItem::TAG_E_FADECOLORS, colorArray);
|
||||
} else {
|
||||
|
||||
setResultItem(resultItem);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1205,7 +1205,8 @@ std::shared_ptr<ItemInstance> Recipes::getItemForRecipe(Recipy* r) {
|
||||
|
||||
// 4J-PB - build the required ingredients for recipes
|
||||
void Recipes::buildRecipeIngredientsArray(void) {
|
||||
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
|
||||
// std::vector<Recipy*> *recipes = ((Recipes
|
||||
// *)Recipes::getInstance())->getRecipies();
|
||||
|
||||
int iRecipeC = (int)recipies->size();
|
||||
|
||||
|
||||
@@ -129,10 +129,10 @@ void ShapedRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) {
|
||||
TempIngReq.iIngValA = new int[9];
|
||||
TempIngReq.iIngAuxValA = new int[9];
|
||||
|
||||
memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngValA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngValA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngAuxValA, Recipes::ANY_AUX_VALUE, sizeof(int) * 9);
|
||||
memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9);
|
||||
memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9);
|
||||
|
||||
for (int x = 0; x < 3; x++) {
|
||||
for (int y = 0; y < 3; y++) {
|
||||
|
||||
@@ -106,10 +106,10 @@ void ShapelessRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) {
|
||||
TempIngReq.iIngValA = new int[3 * 3];
|
||||
TempIngReq.iIngAuxValA = new int[3 * 3];
|
||||
|
||||
memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngValA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngValA, 0, sizeof(int) * 9);
|
||||
memset(TempIngReq.iIngAuxValA, Recipes::ANY_AUX_VALUE, sizeof(int) * 9);
|
||||
memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9);
|
||||
memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9);
|
||||
|
||||
auto citEnd = ingredients->end();
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include "strings.h"
|
||||
|
||||
// Enchantment *Enchantment::enchantments[256];
|
||||
std::vector<Enchantment*> Enchantment::enchantments = std::vector<Enchantment*>(256);
|
||||
std::vector<Enchantment*> Enchantment::enchantments =
|
||||
std::vector<Enchantment*>(256);
|
||||
std::vector<Enchantment*> Enchantment::validEnchantments;
|
||||
|
||||
Enchantment* Enchantment::allDamageProtection = nullptr;
|
||||
|
||||
@@ -94,8 +94,8 @@ void EnchantmentHelper::setEnchantments(
|
||||
}
|
||||
}
|
||||
|
||||
int EnchantmentHelper::getEnchantmentLevel(int enchantmentId,
|
||||
std::vector<std::shared_ptr<ItemInstance>> inventory) {
|
||||
int EnchantmentHelper::getEnchantmentLevel(
|
||||
int enchantmentId, std::vector<std::shared_ptr<ItemInstance>> inventory) {
|
||||
if (inventory.empty()) return 0;
|
||||
int bestLevel = 0;
|
||||
// for (ItemInstance piece : inventory)
|
||||
@@ -130,7 +130,8 @@ void EnchantmentHelper::runIterationOnItem(
|
||||
}
|
||||
|
||||
void EnchantmentHelper::runIterationOnInventory(
|
||||
EnchantmentIterationMethod& method, std::vector<std::shared_ptr<ItemInstance>> inventory) {
|
||||
EnchantmentIterationMethod& method,
|
||||
std::vector<std::shared_ptr<ItemInstance>> inventory) {
|
||||
// for (ItemInstance piece : inventory)
|
||||
for (unsigned int i = 0; i < inventory.size(); ++i) {
|
||||
runIterationOnItem(method, inventory[i]);
|
||||
@@ -152,8 +153,8 @@ EnchantmentHelper::GetDamageProtectionIteration
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
int EnchantmentHelper::getDamageProtection(std::vector<std::shared_ptr<ItemInstance>> armor,
|
||||
DamageSource* source) {
|
||||
int EnchantmentHelper::getDamageProtection(
|
||||
std::vector<std::shared_ptr<ItemInstance>> armor, DamageSource* source) {
|
||||
getDamageProtectionIteration.sum = 0;
|
||||
getDamageProtectionIteration.source = source;
|
||||
|
||||
@@ -248,7 +249,8 @@ int EnchantmentHelper::getArmorThorns(std::shared_ptr<LivingEntity> source) {
|
||||
|
||||
std::shared_ptr<ItemInstance> EnchantmentHelper::getRandomItemWith(
|
||||
Enchantment* enchantment, std::shared_ptr<LivingEntity> source) {
|
||||
std::vector<std::shared_ptr<ItemInstance>> items = source->getEquipmentSlots();
|
||||
std::vector<std::shared_ptr<ItemInstance>> items =
|
||||
source->getEquipmentSlots();
|
||||
for (unsigned int i = 0; i < items.size(); ++i) {
|
||||
std::shared_ptr<ItemInstance> item = items[i];
|
||||
if (item != nullptr && getEnchantmentLevel(enchantment->id, item) > 0) {
|
||||
|
||||
@@ -24,8 +24,9 @@ public:
|
||||
static void setEnchantments(std::unordered_map<int, int>* enchantments,
|
||||
std::shared_ptr<ItemInstance> item);
|
||||
|
||||
static int getEnchantmentLevel(int enchantmentId,
|
||||
std::vector<std::shared_ptr<ItemInstance>> inventory);
|
||||
static int getEnchantmentLevel(
|
||||
int enchantmentId,
|
||||
std::vector<std::shared_ptr<ItemInstance>> inventory);
|
||||
|
||||
private:
|
||||
class EnchantmentIterationMethod {
|
||||
@@ -35,8 +36,9 @@ private:
|
||||
|
||||
static void runIterationOnItem(EnchantmentIterationMethod& method,
|
||||
std::shared_ptr<ItemInstance> piece);
|
||||
static void runIterationOnInventory(EnchantmentIterationMethod& method,
|
||||
std::vector<std::shared_ptr<ItemInstance>> inventory);
|
||||
static void runIterationOnInventory(
|
||||
EnchantmentIterationMethod& method,
|
||||
std::vector<std::shared_ptr<ItemInstance>> inventory);
|
||||
|
||||
class GetDamageProtectionIteration : public EnchantmentIterationMethod {
|
||||
public:
|
||||
@@ -56,8 +58,8 @@ private:
|
||||
* @return
|
||||
*/
|
||||
public:
|
||||
static int getDamageProtection(std::vector<std::shared_ptr<ItemInstance>> armor,
|
||||
DamageSource* source);
|
||||
static int getDamageProtection(
|
||||
std::vector<std::shared_ptr<ItemInstance>> armor, DamageSource* source);
|
||||
|
||||
private:
|
||||
class GetDamageBonusIteration : public EnchantmentIterationMethod {
|
||||
|
||||
@@ -204,7 +204,7 @@ void Explosion::finalizeExplosion(
|
||||
if (destroyBlocks) {
|
||||
// toBlowArray.addAll(toBlow);
|
||||
// TODO 4J Stu - Reverse iterator
|
||||
app.DebugPrintf("Finalizing explosion size %d\n", toBlow.size());
|
||||
app.DebugPrintf("Finalizing explosion size %d\n", toBlow.size());
|
||||
static const int MAX_EXPLODE_PARTICLES = 50;
|
||||
// 4J - try and make at most MAX_EXPLODE_PARTICLES pairs of particles
|
||||
int fraction = (int)toBlowArray->size() / MAX_EXPLODE_PARTICLES;
|
||||
@@ -283,7 +283,6 @@ void Explosion::finalizeExplosion(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (toBlowDirect == nullptr) delete toBlowArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -849,8 +849,6 @@ bool Level::setTileAndData(int x, int y, int z, int tile, int data,
|
||||
result = c->setTileAndData(x & 15, y, z & 15, tile, data);
|
||||
if (updateFlags != Tile::UPDATE_INVISIBLE_NO_LIGHT) {
|
||||
checkLight(x, y, z);
|
||||
|
||||
|
||||
}
|
||||
if (result) {
|
||||
if ((updateFlags & Tile::UPDATE_CLIENTS) != 0 &&
|
||||
@@ -983,22 +981,18 @@ void Level::tileUpdated(int x, int y, int z, int tile) {
|
||||
}
|
||||
|
||||
void Level::lightColumnChanged(int x, int z, int y0, int y1) {
|
||||
if (y0 > y1) {
|
||||
if (y0 > y1) {
|
||||
int tmp = y1;
|
||||
y1 = y0;
|
||||
y0 = tmp;
|
||||
}
|
||||
|
||||
if (!dimension->hasCeiling) {
|
||||
for (int y = y0; y <= y1; y++) {
|
||||
checkLight(LightLayer::Sky, x, y, z);
|
||||
|
||||
for (int y = y0; y <= y1; y++) {
|
||||
checkLight(LightLayer::Sky, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
setTilesDirty(x, y0, z, x, y1, z);
|
||||
|
||||
|
||||
setTilesDirty(x, y0, z, x, y1, z);
|
||||
}
|
||||
|
||||
void Level::setTileDirty(int x, int y, int z) {
|
||||
@@ -1704,8 +1698,8 @@ void Level::removeListener(LevelListener* listener) {
|
||||
|
||||
// 4J - added noEntities and blockAtEdge parameter
|
||||
std::vector<AABB>* Level::getCubes(std::shared_ptr<Entity> source, AABB* box,
|
||||
bool noEntities /* = false*/,
|
||||
bool blockAtEdge /* = false*/) {
|
||||
bool noEntities /* = false*/,
|
||||
bool blockAtEdge /* = false*/) {
|
||||
boxes.clear();
|
||||
int x0 = Mth::floor(box->x0);
|
||||
int x1 = Mth::floor(box->x1 + 1);
|
||||
@@ -1791,7 +1785,8 @@ std::vector<AABB>* Level::getCubes(std::shared_ptr<Entity> source, AABB* box,
|
||||
|
||||
// 4J Stu - Brought forward from 12w36 to fix #46282 - TU5: Gameplay: Exiting
|
||||
// the minecart in a tight corridor damages the player
|
||||
std::vector<AABB>* Level::getTileCubes(AABB* box, bool blockAtEdge /* = false */) {
|
||||
std::vector<AABB>* Level::getTileCubes(AABB* box,
|
||||
bool blockAtEdge /* = false */) {
|
||||
return getCubes(nullptr, box, true, blockAtEdge);
|
||||
// boxes.clear();
|
||||
// int x0 = Mth::floor(box->x0);
|
||||
@@ -2797,10 +2792,7 @@ void Level::setSpawnSettings(bool spawnEnemies, bool spawnFriendlies) {
|
||||
this->spawnFriendlies = spawnFriendlies;
|
||||
}
|
||||
|
||||
void Level::tick() {
|
||||
tickWeather();
|
||||
|
||||
}
|
||||
void Level::tick() { tickWeather(); }
|
||||
|
||||
void Level::prepareWeather() {
|
||||
if (levelData->isRaining()) {
|
||||
@@ -3770,8 +3762,9 @@ std::shared_ptr<Player> Level::getPlayerByUUID(const std::wstring& name) {
|
||||
}
|
||||
|
||||
// 4J Stu - Removed in 1.2.3 ?
|
||||
std::vector<uint8_t> Level::getBlocksAndData(int x, int y, int z, int xs, int ys, int zs,
|
||||
bool includeLighting /* = true*/) {
|
||||
std::vector<uint8_t> Level::getBlocksAndData(int x, int y, int z, int xs,
|
||||
int ys, int zs,
|
||||
bool includeLighting /* = true*/) {
|
||||
std::vector<uint8_t> result(xs * ys * zs * 5 / 2);
|
||||
int xc0 = x >> 4;
|
||||
int zc0 = z >> 4;
|
||||
@@ -3804,7 +3797,8 @@ std::vector<uint8_t> Level::getBlocksAndData(int x, int y, int z, int xs, int ys
|
||||
|
||||
// 4J Stu - Removed in 1.2.3 ?
|
||||
void Level::setBlocksAndData(int x, int y, int z, int xs, int ys, int zs,
|
||||
std::vector<uint8_t>& data, bool includeLighting /* = true*/) {
|
||||
std::vector<uint8_t>& data,
|
||||
bool includeLighting /* = true*/) {
|
||||
int xc0 = x >> 4;
|
||||
int zc0 = z >> 4;
|
||||
int xc1 = (x + xs - 1) >> 4;
|
||||
@@ -3839,8 +3833,7 @@ void Level::setBlocksAndData(int x, int y, int z, int xs, int ys, int zs,
|
||||
}
|
||||
if (forceUnshare) {
|
||||
int size = (x1 - x0) * (y1 - y0) * (z1 - z0);
|
||||
lc->stopSharingTilesAndData();
|
||||
|
||||
lc->stopSharingTilesAndData();
|
||||
}
|
||||
if (p < data.size())
|
||||
p = lc->setBlocksAndData(data, x0, y0, z0, x1, y1, z1, p,
|
||||
@@ -3848,10 +3841,9 @@ void Level::setBlocksAndData(int x, int y, int z, int xs, int ys, int zs,
|
||||
setTilesDirty(xc * 16 + x0, y0, zc * 16 + z0, xc * 16 + x1, y1,
|
||||
zc * 16 + z1);
|
||||
|
||||
if (g_NetworkManager.IsHost() && isClientSide) {
|
||||
if (g_NetworkManager.IsHost() && isClientSide) {
|
||||
lc->startSharingTilesAndData();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,9 @@ public:
|
||||
static constexpr int MAX_LEVEL_SIZE = 30000000;
|
||||
static constexpr int maxMovementHeight = 512; // 4J added
|
||||
|
||||
static constexpr int minBuildHeight = 0; // 4J - brought forward from 1.2.3
|
||||
static constexpr int maxBuildHeight = 256; // 4J - brought forward from 1.2.3
|
||||
static constexpr int minBuildHeight = 0; // 4J - brought forward from 1.2.3
|
||||
static constexpr int maxBuildHeight =
|
||||
256; // 4J - brought forward from 1.2.3
|
||||
static constexpr int genDepthBits = 7;
|
||||
static constexpr int genDepthBitsPlusFour = genDepthBits + 4;
|
||||
static constexpr int genDepth = 1 << genDepthBits;
|
||||
@@ -573,10 +574,11 @@ public:
|
||||
std::shared_ptr<Player> getPlayerByName(const std::wstring& name);
|
||||
std::shared_ptr<Player> getPlayerByUUID(
|
||||
const std::wstring& name); // 4J Added
|
||||
std::vector<uint8_t> getBlocksAndData(int x, int y, int z, int xs, int ys, int zs,
|
||||
bool includeLighting = true);
|
||||
std::vector<uint8_t> getBlocksAndData(int x, int y, int z, int xs, int ys,
|
||||
int zs, bool includeLighting = true);
|
||||
void setBlocksAndData(int x, int y, int z, int xs, int ys, int zs,
|
||||
std::vector<uint8_t>& data, bool includeLighting = true);
|
||||
std::vector<uint8_t>& data,
|
||||
bool includeLighting = true);
|
||||
virtual void disconnect(bool sendDisconnect = true);
|
||||
void checkSession();
|
||||
void setGameTime(int64_t time);
|
||||
|
||||
@@ -41,7 +41,6 @@ std::unordered_map<ChunkPos, bool, ChunkPosKeyHash, ChunkPosKeyEq>
|
||||
|
||||
const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies,
|
||||
bool spawnFriendlies, bool spawnPersistent) {
|
||||
|
||||
if (!spawnEnemies && !spawnFriendlies && !spawnPersistent) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ Region::Region(Level* level, int x1, int y1, int z1, int x2, int y2, int z2,
|
||||
int xc2 = (x2 + r) >> 4;
|
||||
int zc2 = (z2 + r) >> 4;
|
||||
|
||||
chunks = new std::vector<std::vector<LevelChunk*>>(xc2 - xc1 + 1, std::vector<LevelChunk*>(zc2 - zc1 + 1, nullptr));
|
||||
chunks = new std::vector<std::vector<LevelChunk*>>(
|
||||
xc2 - xc1 + 1, std::vector<LevelChunk*>(zc2 - zc1 + 1, nullptr));
|
||||
|
||||
allEmpty = true;
|
||||
for (int xc = xc1; xc <= xc2; xc++) {
|
||||
@@ -174,7 +175,7 @@ int Region::getRawBrightness(int x, int y, int z, bool propagate) {
|
||||
int zc = (z >> 4) - zc1;
|
||||
|
||||
return (*chunks)[xc][zc]->getRawBrightness(x & 15, y, z & 15,
|
||||
level->skyDarken);
|
||||
level->skyDarken);
|
||||
}
|
||||
|
||||
int Region::getData(int x, int y, int z) {
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#include "Minecraft.Client/Linux/Linux_App.h"
|
||||
|
||||
BiomeCache::Block::Block(int x, int z, BiomeCache* parent) {
|
||||
// temps = std::vector<float>(ZONE_SIZE * ZONE_SIZE, false); // MGH -
|
||||
// added "no clear" flag to arrayWithLength downfall =
|
||||
// temps = std::vector<float>(ZONE_SIZE * ZONE_SIZE, false);
|
||||
// // MGH - added "no clear" flag to arrayWithLength downfall =
|
||||
// std::vector<float>(ZONE_SIZE
|
||||
// * ZONE_SIZE, false); biomes = std::vector<Biome*>(ZONE_SIZE * ZONE_SIZE,
|
||||
// false);
|
||||
// * ZONE_SIZE, false); biomes = std::vector<Biome*>(ZONE_SIZE *
|
||||
// ZONE_SIZE, false);
|
||||
biomeIndices = std::vector<uint8_t>(ZONE_SIZE * ZONE_SIZE, false);
|
||||
|
||||
lastUse = 0;
|
||||
@@ -27,8 +27,7 @@ BiomeCache::Block::Block(int x, int z, BiomeCache* parent) {
|
||||
(unsigned)z << ZONE_SIZE_BITS, ZONE_SIZE, ZONE_SIZE, false);
|
||||
}
|
||||
|
||||
BiomeCache::Block::~Block() {
|
||||
}
|
||||
BiomeCache::Block::~Block() {}
|
||||
|
||||
Biome* BiomeCache::Block::getBiome(int x, int z) {
|
||||
// return biomes[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) <<
|
||||
|
||||
@@ -90,10 +90,9 @@ void BiomeDecorator::_init() {
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorate() {
|
||||
decorateOres();
|
||||
|
||||
decorateOres();
|
||||
|
||||
for (int i = 0; i < sandCount; i++) {
|
||||
for (int i = 0; i < sandCount; i++) {
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
sandFeature->place(level, random, x, level->getTopSolidBlock(x, z), z);
|
||||
@@ -110,9 +109,8 @@ void BiomeDecorator::decorate() {
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
sandFeature->place(level, random, x, level->getTopSolidBlock(x, z), z);
|
||||
}
|
||||
|
||||
|
||||
int forests = treeCount;
|
||||
int forests = treeCount;
|
||||
if (random->nextInt(10) == 0) forests += 1;
|
||||
|
||||
for (int i = 0; i < forests; i++) {
|
||||
@@ -123,9 +121,8 @@ void BiomeDecorator::decorate() {
|
||||
tree->place(level, random, x, level->getHeightmap(x, z), z);
|
||||
delete tree;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < hugeMushrooms; i++) {
|
||||
for (int i = 0; i < hugeMushrooms; i++) {
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
hugeMushroomFeature->place(level, random, x, level->getHeightmap(x, z),
|
||||
@@ -156,7 +153,7 @@ void BiomeDecorator::decorate() {
|
||||
grassFeature->place(level, random, x, y, z);
|
||||
delete grassFeature;
|
||||
}
|
||||
|
||||
|
||||
// 4J Stu - For some reason this was created each time round in the loop
|
||||
// I assume there is a case where deadBushCount could be 0
|
||||
DeadBushFeature* deadBushFeature = nullptr;
|
||||
@@ -240,8 +237,6 @@ void BiomeDecorator::decorate() {
|
||||
cactusFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (liquids) {
|
||||
// 4J Stu - For some reason this was created each time round in the loop
|
||||
SpringFeature* waterSpringFeature = new SpringFeature(Tile::water_Id);
|
||||
@@ -264,7 +259,6 @@ void BiomeDecorator::decorate() {
|
||||
}
|
||||
delete lavaSpringFeature;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorate(int count, Feature* feature) {
|
||||
|
||||
@@ -33,10 +33,10 @@ void BiomeSource::_init() {
|
||||
void BiomeSource::_init(int64_t seed, LevelType* generator) {
|
||||
_init();
|
||||
|
||||
std::vector<std::shared_ptr<Layer>> layers = Layer::getDefaultLayers(seed, generator);
|
||||
std::vector<std::shared_ptr<Layer>> layers =
|
||||
Layer::getDefaultLayers(seed, generator);
|
||||
layer = layers[0];
|
||||
zoomedLayer = layers[1];
|
||||
|
||||
}
|
||||
|
||||
BiomeSource::BiomeSource() { _init(); }
|
||||
@@ -66,7 +66,8 @@ float BiomeSource::getDownfall(int x, int z) const {
|
||||
|
||||
// 4J - note that caller is responsible for deleting returned array.
|
||||
// temperatures array is for output only.
|
||||
std::vector<float> BiomeSource::getDownfallBlock(int x, int z, int w, int h) const {
|
||||
std::vector<float> BiomeSource::getDownfallBlock(int x, int z, int w,
|
||||
int h) const {
|
||||
std::vector<float> downfalls;
|
||||
getDownfallBlock(downfalls, x, z, w, h);
|
||||
return downfalls;
|
||||
@@ -75,8 +76,8 @@ std::vector<float> BiomeSource::getDownfallBlock(int x, int z, int w, int h) con
|
||||
// 4J - note that caller is responsible for deleting returned array.
|
||||
// temperatures array is for output only. 4J - removal of separate temperature &
|
||||
// downfall layers brought forward from 1.2.3
|
||||
void BiomeSource::getDownfallBlock(std::vector<float>& downfalls, int x, int z, int w,
|
||||
int h) const {
|
||||
void BiomeSource::getDownfallBlock(std::vector<float>& downfalls, int x, int z,
|
||||
int w, int h) const {
|
||||
// if (downfalls == nullptr || downfalls->length < w * h)
|
||||
if (downfalls.empty() || downfalls.size() < (unsigned int)(w * h)) {
|
||||
downfalls = std::vector<float>(w * h);
|
||||
@@ -101,7 +102,8 @@ float BiomeSource::getTemperature(int x, int y, int z) const {
|
||||
// 4J - brought forward from 1.2.3
|
||||
float BiomeSource::scaleTemp(float temp, int y) const { return temp; }
|
||||
|
||||
std::vector<float> BiomeSource::getTemperatureBlock(int x, int z, int w, int h) const {
|
||||
std::vector<float> BiomeSource::getTemperatureBlock(int x, int z, int w,
|
||||
int h) const {
|
||||
std::vector<float> temperatures;
|
||||
getTemperatureBlock(temperatures, x, z, w, h);
|
||||
return temperatures;
|
||||
@@ -110,8 +112,8 @@ std::vector<float> BiomeSource::getTemperatureBlock(int x, int z, int w, int h)
|
||||
// 4J - note that caller is responsible for deleting returned array.
|
||||
// temperatures array is for output only. 4J - removal of separate temperature &
|
||||
// downfall layers brought forward from 1.2.3
|
||||
void BiomeSource::getTemperatureBlock(std::vector<float>& temperatures, int x, int z,
|
||||
int w, int h) const {
|
||||
void BiomeSource::getTemperatureBlock(std::vector<float>& temperatures, int x,
|
||||
int z, int w, int h) const {
|
||||
// if (temperatures == null || temperatures.size() < w * h) {
|
||||
if (temperatures.empty() || temperatures.size() < (unsigned int)(w * h)) {
|
||||
temperatures = std::vector<float>(w * h);
|
||||
@@ -126,23 +128,24 @@ void BiomeSource::getTemperatureBlock(std::vector<float>& temperatures, int x, i
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Biome*> BiomeSource::getRawBiomeBlock(int x, int z, int w, int h) const {
|
||||
std::vector<Biome*> BiomeSource::getRawBiomeBlock(int x, int z, int w,
|
||||
int h) const {
|
||||
std::vector<Biome*> biomes;
|
||||
getRawBiomeBlock(biomes, x, z, w, h);
|
||||
return biomes;
|
||||
}
|
||||
|
||||
// 4J added
|
||||
void BiomeSource::getRawBiomeIndices(std::vector<int>& biomes, int x, int z, int w,
|
||||
int h) const {
|
||||
void BiomeSource::getRawBiomeIndices(std::vector<int>& biomes, int x, int z,
|
||||
int w, int h) const {
|
||||
std::vector<int> result = layer->getArea(x, z, w, h);
|
||||
for (int i = 0; i < w * h; i++) {
|
||||
biomes[i] = result[i];
|
||||
}
|
||||
}
|
||||
|
||||
void BiomeSource::getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
|
||||
int h) const {
|
||||
void BiomeSource::getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z,
|
||||
int w, int h) const {
|
||||
// if (biomes == null || biomes.size() < w * h)
|
||||
if (biomes.empty() || biomes.size() < (unsigned int)(w * h)) {
|
||||
biomes = std::vector<Biome*>(w * h);
|
||||
@@ -160,7 +163,8 @@ void BiomeSource::getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z, in
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Biome*> BiomeSource::getBiomeBlock(int x, int z, int w, int h) const {
|
||||
std::vector<Biome*> BiomeSource::getBiomeBlock(int x, int z, int w,
|
||||
int h) const {
|
||||
if (w == 16 && h == 16 && (x & 0xf) == 0 && (z & 0xf) == 0) {
|
||||
return cache->getBiomeBlockAt(x, z);
|
||||
}
|
||||
@@ -170,8 +174,8 @@ std::vector<Biome*> BiomeSource::getBiomeBlock(int x, int z, int w, int h) const
|
||||
}
|
||||
|
||||
// 4J - caller is responsible for deleting biomes array
|
||||
void BiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w, int h,
|
||||
bool useCache) const {
|
||||
void BiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z,
|
||||
int w, int h, bool useCache) const {
|
||||
// if (biomes == null || biomes.size() < w * h)
|
||||
if (biomes.empty() || biomes.size() < w * h) {
|
||||
biomes = std::vector<Biome*>(w * h);
|
||||
@@ -180,8 +184,8 @@ void BiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w
|
||||
if (useCache && w == 16 && h == 16 && (x & 0xf) == 0 && (z & 0xf) == 0) {
|
||||
std::vector<Biome*> tmp = cache->getBiomeBlockAt(x, z);
|
||||
std::copy(tmp.begin(), tmp.begin() + w * h, biomes.begin());
|
||||
// the indices now. //4jcraft made it array delete
|
||||
// return biomes;
|
||||
// the indices now. //4jcraft made it array delete
|
||||
// return biomes;
|
||||
}
|
||||
|
||||
std::vector<int> result = zoomedLayer->getArea(x, z, w, h);
|
||||
@@ -190,7 +194,8 @@ void BiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<uint8_t> BiomeSource::getBiomeIndexBlock(int x, int z, int w, int h) const {
|
||||
std::vector<uint8_t> BiomeSource::getBiomeIndexBlock(int x, int z, int w,
|
||||
int h) const {
|
||||
if (w == 16 && h == 16 && (x & 0xf) == 0 && (z & 0xf) == 0) {
|
||||
return cache->getBiomeIndexBlockAt(x, z);
|
||||
}
|
||||
@@ -200,8 +205,8 @@ std::vector<uint8_t> BiomeSource::getBiomeIndexBlock(int x, int z, int w, int h)
|
||||
}
|
||||
|
||||
// 4J - caller is responsible for deleting biomes array
|
||||
void BiomeSource::getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, int x, int z,
|
||||
int w, int h, bool useCache) const {
|
||||
void BiomeSource::getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, int x,
|
||||
int z, int w, int h, bool useCache) const {
|
||||
// if (biomes == null || biomes.size() < w * h)
|
||||
if (biomeIndices.empty() || biomeIndices.size() < w * h) {
|
||||
biomeIndices = std::vector<uint8_t>(w * h);
|
||||
@@ -312,7 +317,8 @@ TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind,
|
||||
* Returns null if the biome wasn't found
|
||||
*/
|
||||
TilePos* BiomeSource::findBiome(int x, int z, int r,
|
||||
const std::vector<Biome*>& allowed, Random* random) {
|
||||
const std::vector<Biome*>& allowed,
|
||||
Random* random) {
|
||||
int x0 = ((x - r) >> 2);
|
||||
int z0 = ((z - r) >> 2);
|
||||
int x1 = ((x + r) >> 2);
|
||||
@@ -375,7 +381,8 @@ int64_t BiomeSource::findSeed(LevelType* generator) {
|
||||
static const int biomeOffset = -(biomeWidth / 2);
|
||||
|
||||
// Storage for our biome indices
|
||||
std::vector<int> indices = std::vector<int>(biomeWidth * biomeWidth);
|
||||
std::vector<int> indices =
|
||||
std::vector<int>(biomeWidth * biomeWidth);
|
||||
|
||||
// Storage for the fractional amounts of each biome that will be
|
||||
// calculated
|
||||
@@ -412,8 +419,8 @@ int64_t BiomeSource::findSeed(LevelType* generator) {
|
||||
tryCount, bestSeed);
|
||||
|
||||
BiomeSource* biomeSource = new BiomeSource(bestSeed);
|
||||
std::vector<Biome*> biomes = biomeSource->getBiomeBlock(-27 * 16, -27 * 16,
|
||||
54 * 16, 54 * 16);
|
||||
std::vector<Biome*> biomes = biomeSource->getBiomeBlock(
|
||||
-27 * 16, -27 * 16, 54 * 16, 54 * 16);
|
||||
|
||||
unsigned int* pixels = new unsigned int[54 * 16 * 54 * 16];
|
||||
for (int i = 0; i < 54 * 16 * 54 * 16; i++) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
BiomeSource(Level* level);
|
||||
|
||||
private:
|
||||
static bool getIsMatch(float* frac); // 4J added
|
||||
static bool getIsMatch(float* frac); // 4J added
|
||||
static void getFracs(std::vector<int>& indices, float* fracs); // 4J added
|
||||
public:
|
||||
static int64_t findSeed(LevelType* generator); // 4J added
|
||||
@@ -46,31 +46,36 @@ public:
|
||||
|
||||
// 4J - changed the interface for these methods, mainly for thread safety
|
||||
virtual float getDownfall(int x, int z) const;
|
||||
virtual std::vector<float> getDownfallBlock(int x, int z, int w, int h) const;
|
||||
virtual void getDownfallBlock(std::vector<float>& downfalls, int x, int z, int w,
|
||||
int h) const;
|
||||
virtual std::vector<float> getDownfallBlock(int x, int z, int w,
|
||||
int h) const;
|
||||
virtual void getDownfallBlock(std::vector<float>& downfalls, int x, int z,
|
||||
int w, int h) const;
|
||||
|
||||
// 4J - changed the interface for these methods, mainly for thread safety
|
||||
virtual BiomeCache::Block* getBlockAt(int x, int y);
|
||||
virtual float getTemperature(int x, int y, int z) const;
|
||||
float scaleTemp(float temp,
|
||||
int y) const; // 4J - brought forward from 1.2.3
|
||||
virtual std::vector<float> getTemperatureBlock(int x, int z, int w, int h) const;
|
||||
virtual void getTemperatureBlock(std::vector<float>& temperatures, int x, int z,
|
||||
int w, int h) const;
|
||||
virtual std::vector<float> getTemperatureBlock(int x, int z, int w,
|
||||
int h) const;
|
||||
virtual void getTemperatureBlock(std::vector<float>& temperatures, int x,
|
||||
int z, int w, int h) const;
|
||||
|
||||
virtual std::vector<Biome*> getRawBiomeBlock(int x, int z, int w, int h) const;
|
||||
virtual void getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
|
||||
int h) const;
|
||||
virtual void getRawBiomeIndices(std::vector<int>& biomes, int x, int z, int w,
|
||||
virtual std::vector<Biome*> getRawBiomeBlock(int x, int z, int w,
|
||||
int h) const;
|
||||
virtual void getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z,
|
||||
int w, int h) const;
|
||||
virtual void getRawBiomeIndices(std::vector<int>& biomes, int x, int z,
|
||||
int w,
|
||||
int h) const; // 4J added
|
||||
virtual std::vector<Biome*> getBiomeBlock(int x, int z, int w, int h) const;
|
||||
virtual void getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w, int h,
|
||||
bool useCache) const;
|
||||
virtual void getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
|
||||
int h, bool useCache) const;
|
||||
|
||||
virtual std::vector<uint8_t> getBiomeIndexBlock(int x, int z, int w, int h) const;
|
||||
virtual void getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, int x, int z,
|
||||
int w, int h, bool useCache) const;
|
||||
virtual std::vector<uint8_t> getBiomeIndexBlock(int x, int z, int w,
|
||||
int h) const;
|
||||
virtual void getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, int x,
|
||||
int z, int w, int h, bool useCache) const;
|
||||
|
||||
/**
|
||||
* Checks if an area around a block contains only the specified biomes.
|
||||
@@ -79,7 +84,8 @@ public:
|
||||
* This is a bit of a rough check, to make it as fast as possible. To ensure
|
||||
* NO other biomes, add a margin of at least four blocks to the radius
|
||||
*/
|
||||
virtual bool containsOnly(int x, int z, int r, const std::vector<Biome*>& allowed);
|
||||
virtual bool containsOnly(int x, int z, int r,
|
||||
const std::vector<Biome*>& allowed);
|
||||
|
||||
/**
|
||||
* Checks if an area around a block contains only the specified biome.
|
||||
@@ -105,7 +111,8 @@ public:
|
||||
*
|
||||
* Returns null if the biome wasn't found
|
||||
*/
|
||||
virtual TilePos* findBiome(int x, int z, int r, const std::vector<Biome*>& allowed,
|
||||
virtual TilePos* findBiome(int x, int z, int r,
|
||||
const std::vector<Biome*>& allowed,
|
||||
Random* random);
|
||||
|
||||
void update();
|
||||
|
||||
@@ -20,8 +20,8 @@ Biome* FixedBiomeSource::getBiome(int x, int z) { return biome; }
|
||||
|
||||
float FixedBiomeSource::getTemperature(int x, int z) { return temperature; }
|
||||
|
||||
void FixedBiomeSource::getTemperatureBlock(std::vector<float>& temperatures, int x,
|
||||
int z, int w, int h) const {
|
||||
void FixedBiomeSource::getTemperatureBlock(std::vector<float>& temperatures,
|
||||
int x, int z, int w, int h) const {
|
||||
if (temperatures.empty() || temperatures.size() < (unsigned int)(w * h)) {
|
||||
temperatures = std::vector<float>(w * h);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ void FixedBiomeSource::getTemperatureBlock(std::vector<float>& temperatures, int
|
||||
}
|
||||
|
||||
std::vector<float> FixedBiomeSource::getTemperatureBlock(int x, int z, int w,
|
||||
int h) const {
|
||||
int h) const {
|
||||
std::vector<float> temps(w * h);
|
||||
getTemperatureBlock(temps, x, z, w, h);
|
||||
return temps;
|
||||
@@ -38,15 +38,15 @@ std::vector<float> FixedBiomeSource::getTemperatureBlock(int x, int z, int w,
|
||||
|
||||
// 4J - note that caller is responsible for deleting returned array.
|
||||
// temperatures array is for output only.
|
||||
void FixedBiomeSource::getTemperatureBlock(std::vector<double>& temperatures, int x,
|
||||
int z, int w, int h) const {
|
||||
void FixedBiomeSource::getTemperatureBlock(std::vector<double>& temperatures,
|
||||
int x, int z, int w, int h) const {
|
||||
temperatures = std::vector<double>(w * h);
|
||||
|
||||
Arrays::fill(temperatures, 0, w * h, (double)temperature);
|
||||
}
|
||||
|
||||
void FixedBiomeSource::getDownfallBlock(std::vector<float>& downfalls, int x, int z,
|
||||
int w, int h) const {
|
||||
void FixedBiomeSource::getDownfallBlock(std::vector<float>& downfalls, int x,
|
||||
int z, int w, int h) const {
|
||||
if (downfalls.empty() || downfalls.size() < (unsigned int)(w * h)) {
|
||||
downfalls = std::vector<float>(w * h);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ void FixedBiomeSource::getDownfallBlock(std::vector<float>& downfalls, int x, in
|
||||
}
|
||||
|
||||
std::vector<float> FixedBiomeSource::getDownfallBlock(int x, int z, int w,
|
||||
int h) const {
|
||||
int h) const {
|
||||
std::vector<float> downfalls(w * h);
|
||||
getDownfallBlock(downfalls, x, z, w, h);
|
||||
return downfalls;
|
||||
@@ -62,8 +62,8 @@ std::vector<float> FixedBiomeSource::getDownfallBlock(int x, int z, int w,
|
||||
|
||||
float FixedBiomeSource::getDownfall(int x, int z) const { return downfall; }
|
||||
|
||||
void FixedBiomeSource::getDownfallBlock(std::vector<double>& downfalls, int x, int z,
|
||||
int w, int h) {
|
||||
void FixedBiomeSource::getDownfallBlock(std::vector<double>& downfalls, int x,
|
||||
int z, int w, int h) {
|
||||
if (downfalls.empty() || downfalls.size() < (unsigned int)(w * h)) {
|
||||
downfalls = std::vector<double>(w * h);
|
||||
}
|
||||
@@ -72,8 +72,8 @@ void FixedBiomeSource::getDownfallBlock(std::vector<double>& downfalls, int x, i
|
||||
|
||||
// 4J - caller is responsible for deleting biomes array, plus any optional
|
||||
// arrays output if pointers are passed in (_temperatures, _downfalls)
|
||||
void FixedBiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
|
||||
int h, bool useCache) const {
|
||||
void FixedBiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z,
|
||||
int w, int h, bool useCache) const {
|
||||
biomes = std::vector<Biome*>(w * h);
|
||||
|
||||
Arrays::fill(biomes, 0, w * h, biome);
|
||||
@@ -81,8 +81,9 @@ void FixedBiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z,
|
||||
|
||||
// 4J - caller is responsible for deleting biomes array, plus any optional
|
||||
// arrays output if pointers are passed in (_temperatures, _downfalls)
|
||||
void FixedBiomeSource::getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, int x, int z,
|
||||
int w, int h, bool useCache) const {
|
||||
void FixedBiomeSource::getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices,
|
||||
int x, int z, int w, int h,
|
||||
bool useCache) const {
|
||||
biomeIndices = std::vector<uint8_t>(w * h);
|
||||
int biomeIndex = biome->id;
|
||||
Arrays::fill(biomeIndices, 0, w * h, biomeIndex);
|
||||
@@ -91,8 +92,8 @@ void FixedBiomeSource::getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, in
|
||||
// 4J-PB added in from beyond 1.8.2
|
||||
// 4J - caller is responsible for deleting biomes array, plus any optional
|
||||
// arrays output if pointers are passed in (_temperatures, _downfalls)
|
||||
void FixedBiomeSource::getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
|
||||
int h) const {
|
||||
void FixedBiomeSource::getRawBiomeBlock(std::vector<Biome*>& biomes, int x,
|
||||
int z, int w, int h) const {
|
||||
biomes = std::vector<Biome*>(w * h);
|
||||
|
||||
Arrays::fill(biomes, 0, w * h, biome);
|
||||
@@ -102,7 +103,7 @@ void FixedBiomeSource::getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int
|
||||
// 4J - caller is responsible for deleting biomes array, plus any optional
|
||||
// arrays output if pointers are passed in (_temperatures, _downfalls)
|
||||
std::vector<Biome*> FixedBiomeSource::getRawBiomeBlock(int x, int z, int w,
|
||||
int h) const {
|
||||
int h) const {
|
||||
std::vector<Biome*> biomes;
|
||||
getRawBiomeBlock(biomes, x, z, w, h);
|
||||
return biomes;
|
||||
|
||||
@@ -19,32 +19,37 @@ public:
|
||||
virtual Biome* getBiome(ChunkPos* cp);
|
||||
virtual Biome* getBiome(int x, int z);
|
||||
virtual float getTemperature(int x, int z);
|
||||
virtual void getTemperatureBlock(std::vector<float>& temperatures, int x, int z,
|
||||
int w, int h) const;
|
||||
virtual std::vector<float> getTemperatureBlock(int x, int z, int w, int h) const;
|
||||
virtual void getTemperatureBlock(std::vector<double>& temperatures, int x, int z,
|
||||
int w, int h) const;
|
||||
virtual void getDownfallBlock(std::vector<float>& downfalls, int x, int z, int w,
|
||||
int h) const;
|
||||
virtual std::vector<float> getDownfallBlock(int x, int z, int w, int h) const;
|
||||
virtual void getTemperatureBlock(std::vector<float>& temperatures, int x,
|
||||
int z, int w, int h) const;
|
||||
virtual std::vector<float> getTemperatureBlock(int x, int z, int w,
|
||||
int h) const;
|
||||
virtual void getTemperatureBlock(std::vector<double>& temperatures, int x,
|
||||
int z, int w, int h) const;
|
||||
virtual void getDownfallBlock(std::vector<float>& downfalls, int x, int z,
|
||||
int w, int h) const;
|
||||
virtual std::vector<float> getDownfallBlock(int x, int z, int w,
|
||||
int h) const;
|
||||
virtual float getDownfall(int x, int z) const;
|
||||
virtual void getDownfallBlock(std::vector<double>& downfalls, int x, int z, int w,
|
||||
int h);
|
||||
virtual void getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w, int h,
|
||||
bool useCache) const;
|
||||
virtual void getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, int x, int z,
|
||||
int w, int h, bool useCache) const;
|
||||
virtual void getDownfallBlock(std::vector<double>& downfalls, int x, int z,
|
||||
int w, int h);
|
||||
virtual void getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
|
||||
int h, bool useCache) const;
|
||||
virtual void getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, int x,
|
||||
int z, int w, int h, bool useCache) const;
|
||||
|
||||
// 4J-PB added in from beyond 1.8.2
|
||||
virtual std::vector<Biome*> getRawBiomeBlock(int x, int z, int w, int h) const;
|
||||
virtual void getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
|
||||
int h) const;
|
||||
virtual std::vector<Biome*> getRawBiomeBlock(int x, int z, int w,
|
||||
int h) const;
|
||||
virtual void getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z,
|
||||
int w, int h) const;
|
||||
|
||||
////////////////////////////////////
|
||||
virtual TilePos* findBiome(int x, int z, int r, Biome* toFind,
|
||||
Random* random);
|
||||
virtual TilePos* findBiome(int x, int z, int r, const std::vector<Biome*>& allowed,
|
||||
virtual TilePos* findBiome(int x, int z, int r,
|
||||
const std::vector<Biome*>& allowed,
|
||||
Random* random);
|
||||
virtual bool containsOnly(int x, int z, int r, Biome* allowed);
|
||||
virtual bool containsOnly(int x, int z, int r, const std::vector<Biome*>& allowed);
|
||||
virtual bool containsOnly(int x, int z, int r,
|
||||
const std::vector<Biome*>& allowed);
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ Feature* JungleBiome::getGrassFeature(Random* random) {
|
||||
void JungleBiome::decorate(Level* level, Random* random, int xo, int zo) {
|
||||
Biome::decorate(level, random, xo, zo);
|
||||
|
||||
VinesFeature* vines = new VinesFeature();
|
||||
VinesFeature* vines = new VinesFeature();
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
@@ -68,5 +68,4 @@ void JungleBiome::decorate(Level* level, Random* random, int xo, int zo) {
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
vines->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
#include "BlockReplacements.h"
|
||||
#include "minecraft/world/level/tile/Tile.h"
|
||||
|
||||
std::vector<uint8_t> BlockReplacements::replacements = std::vector<uint8_t>(256);
|
||||
std::vector<uint8_t> BlockReplacements::replacements =
|
||||
std::vector<uint8_t>(256);
|
||||
|
||||
void BlockReplacements::staticCtor() {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
|
||||
@@ -49,7 +49,8 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage* copyFrom) {
|
||||
std::lock_guard<std::recursive_mutex> lock(cs_write);
|
||||
allocatedSize = copyFrom->allocatedSize;
|
||||
if (allocatedSize > 0) {
|
||||
indicesAndData = (unsigned char*)malloc(allocatedSize); //(unsigned char *)malloc(allocatedSize);
|
||||
indicesAndData = (unsigned char*)malloc(
|
||||
allocatedSize); //(unsigned char *)malloc(allocatedSize);
|
||||
memcpy(indicesAndData, copyFrom->indicesAndData, allocatedSize);
|
||||
} else {
|
||||
indicesAndData = nullptr;
|
||||
@@ -244,7 +245,8 @@ inline void CompressedTileStorage::getBlock(int* block, int x, int y, int z) {
|
||||
}
|
||||
|
||||
// Set all tile values from a data array of length 32768 (128 x 16 x 16).
|
||||
void CompressedTileStorage::setData(std::vector<uint8_t>& dataIn, unsigned int inOffset) {
|
||||
void CompressedTileStorage::setData(std::vector<uint8_t>& dataIn,
|
||||
unsigned int inOffset) {
|
||||
unsigned short _blockIndices[512];
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(cs_write);
|
||||
@@ -328,7 +330,8 @@ void CompressedTileStorage::setData(std::vector<uint8_t>& dataIn, unsigned int i
|
||||
// type8 / chunkTotal);
|
||||
|
||||
memToAlloc += 1024; // For the indices
|
||||
unsigned char* newIndicesAndData = (unsigned char*)malloc(memToAlloc); //(unsigned char *)malloc( memToAlloc );
|
||||
unsigned char* newIndicesAndData = (unsigned char*)malloc(
|
||||
memToAlloc); //(unsigned char *)malloc( memToAlloc );
|
||||
unsigned char* pucData = newIndicesAndData + 1024;
|
||||
unsigned short usDataOffset = 0;
|
||||
unsigned short* newIndices = (unsigned short*)newIndicesAndData;
|
||||
@@ -669,8 +672,8 @@ void CompressedTileStorage::set(int x, int y, int z, int val) {
|
||||
|
||||
// Sets a region of tile values with the data at offset position in the array
|
||||
// dataIn - external ordering compatible with java DataLayer
|
||||
int CompressedTileStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1,
|
||||
int CompressedTileStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int offset,
|
||||
tileUpdatedCallback callback,
|
||||
void* param, int yparam) {
|
||||
@@ -703,9 +706,9 @@ int CompressedTileStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0, i
|
||||
}
|
||||
|
||||
// Tests whether setting data would actually change anything
|
||||
bool CompressedTileStorage::testSetDataRegion(std::vector<uint8_t>& dataIn, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1,
|
||||
int offset) {
|
||||
bool CompressedTileStorage::testSetDataRegion(std::vector<uint8_t>& dataIn,
|
||||
int x0, int y0, int z0, int x1,
|
||||
int y1, int z1, int offset) {
|
||||
unsigned char* pucIn = &dataIn.data()[offset];
|
||||
for (int x = x0; x < x1; x++) {
|
||||
for (int z = z0; z < z1; z++) {
|
||||
@@ -721,9 +724,9 @@ bool CompressedTileStorage::testSetDataRegion(std::vector<uint8_t>& dataIn, int
|
||||
|
||||
// Updates the data at offset position dataInOut with a region of tile
|
||||
// information - external ordering compatible with java DataLayer
|
||||
int CompressedTileStorage::getDataRegion(std::vector<uint8_t>& dataInOut, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1,
|
||||
int offset) {
|
||||
int CompressedTileStorage::getDataRegion(std::vector<uint8_t>& dataInOut,
|
||||
int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int offset) {
|
||||
unsigned char* pucOut = &dataInOut.data()[offset];
|
||||
for (int x = x0; x < x1; x++) {
|
||||
for (int z = z0; z < z1; z++) {
|
||||
@@ -944,7 +947,8 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) {
|
||||
// If we need to do something here, then lets allocate some memory
|
||||
if (needsCompressed) {
|
||||
memToAlloc += 1024; // For the indices
|
||||
unsigned char* newIndicesAndData = (unsigned char*)malloc(memToAlloc); //(unsigned char *)malloc( memToAlloc );
|
||||
unsigned char* newIndicesAndData = (unsigned char*)malloc(
|
||||
memToAlloc); //(unsigned char *)malloc( memToAlloc );
|
||||
if (newIndicesAndData == nullptr) {
|
||||
uint32_t lastError = GetLastError();
|
||||
MEMORYSTATUS memStatus;
|
||||
@@ -1205,12 +1209,13 @@ void CompressedTileStorage::write(DataOutputStream* dos) {
|
||||
|
||||
// Write the rest of the data
|
||||
if (allocatedSize > 1024) {
|
||||
std::vector<uint8_t> dataWrapper(indicesAndData + 1024,
|
||||
indicesAndData + allocatedSize);
|
||||
std::vector<uint8_t> dataWrapper(
|
||||
indicesAndData + 1024, indicesAndData + allocatedSize);
|
||||
dos->write(dataWrapper);
|
||||
}
|
||||
} else {
|
||||
std::vector<uint8_t> wrapper(indicesAndData, indicesAndData + allocatedSize);
|
||||
std::vector<uint8_t> wrapper(indicesAndData,
|
||||
indicesAndData + allocatedSize);
|
||||
dos->write(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
class DataInputStream;
|
||||
class DataOutputStream;
|
||||
template <typename T> class XLockFreeStack;
|
||||
template <typename T>
|
||||
class XLockFreeStack;
|
||||
|
||||
// This class is used for the compressed storage of tile data. Unlike the
|
||||
// SparseLightingStorage class, data is split into 512 blocks of 4x4x4 tiles.
|
||||
@@ -134,17 +135,18 @@ public:
|
||||
typedef void (*tileUpdatedCallback)(int x, int y, int z, void* param,
|
||||
int yparam);
|
||||
int setDataRegion(
|
||||
std::vector<uint8_t>& dataIn, int x0, int y0, int z0, int x1, int y1, int z1,
|
||||
int offset, tileUpdatedCallback callback, void* param,
|
||||
std::vector<uint8_t>& dataIn, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int offset, tileUpdatedCallback callback, void* param,
|
||||
int yparam); // Sets a region of tile values with the data at offset
|
||||
// position in the array dataIn - external ordering
|
||||
// compatible with java DataLayer
|
||||
bool testSetDataRegion(std::vector<uint8_t>& dataIn, int x0, int y0, int z0, int x1,
|
||||
int y1, int z1,
|
||||
bool testSetDataRegion(std::vector<uint8_t>& dataIn, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1,
|
||||
int offset); // Tests whether setting data would
|
||||
// actually change anything
|
||||
int getDataRegion(
|
||||
std::vector<uint8_t>& dataInOut, int x0, int y0, int z0, int x1, int y1, int z1,
|
||||
std::vector<uint8_t>& dataInOut, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1,
|
||||
int offset); // Updates the data at offset position dataInOut with a
|
||||
// region of tile information - external ordering
|
||||
// compatible with java DataLayer
|
||||
|
||||
@@ -10,7 +10,6 @@ DataLayer::DataLayer(std::vector<uint8_t>& data, int depthBits)
|
||||
this->data = data;
|
||||
}
|
||||
|
||||
|
||||
int DataLayer::get(int x, int y, int z) {
|
||||
int pos = (x << depthBitsPlusFour | z << depthBits | y);
|
||||
int slot = pos >> 1;
|
||||
|
||||
@@ -17,7 +17,8 @@ EmptyLevelChunk::EmptyLevelChunk(Level* level, int x, int z)
|
||||
LevelChunk::sTerrainPostPostProcessed;
|
||||
}
|
||||
|
||||
EmptyLevelChunk::EmptyLevelChunk(Level* level, std::vector<uint8_t>& blocks, int x, int z)
|
||||
EmptyLevelChunk::EmptyLevelChunk(Level* level, std::vector<uint8_t>& blocks,
|
||||
int x, int z)
|
||||
: LevelChunk(level, blocks, x, z) {
|
||||
dontSave = true;
|
||||
// Set this as fully post-processed, so we don't try and run post-processing
|
||||
@@ -123,9 +124,9 @@ bool EmptyLevelChunk::shouldSave(bool force) { return false; }
|
||||
|
||||
void EmptyLevelChunk::setBlocks(std::vector<uint8_t>& newBlocks, int sub) {}
|
||||
|
||||
int EmptyLevelChunk::getBlocksAndData(std::vector<uint8_t>& data, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1, int p,
|
||||
bool includeLighting /* = true*/) {
|
||||
int EmptyLevelChunk::getBlocksAndData(std::vector<uint8_t>& data, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int p, bool includeLighting /* = true*/) {
|
||||
int xs = x1 - x0;
|
||||
int ys = y1 - y0;
|
||||
int zs = z1 - z0;
|
||||
@@ -142,9 +143,9 @@ int EmptyLevelChunk::getBlocksAndData(std::vector<uint8_t>& data, int x0, int y0
|
||||
return len;
|
||||
}
|
||||
|
||||
int EmptyLevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1, int p,
|
||||
bool includeLighting /* = true*/) {
|
||||
int EmptyLevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int p, bool includeLighting /* = true*/) {
|
||||
int xs = x1 - x0;
|
||||
int ys = y1 - y0;
|
||||
int zs = z1 - z0;
|
||||
@@ -157,9 +158,9 @@ int EmptyLevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0, int y0
|
||||
}
|
||||
}
|
||||
|
||||
bool EmptyLevelChunk::testSetBlocksAndData(std::vector<uint8_t>& data, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1,
|
||||
int p) {
|
||||
bool EmptyLevelChunk::testSetBlocksAndData(std::vector<uint8_t>& data, int x0,
|
||||
int y0, int z0, int x1, int y1,
|
||||
int z1, int p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,13 +63,16 @@ public:
|
||||
bool shouldSave(bool force);
|
||||
void setBlocks(std::vector<uint8_t>& newBlocks, int sub);
|
||||
int getBlocksAndData(
|
||||
std::vector<uint8_t>& data, int x0, int y0, int z0, int x1, int y1, int z1, int p,
|
||||
std::vector<uint8_t>& data, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int p,
|
||||
bool includeLighting = true); // 4J - added includeLighting parameter
|
||||
int setBlocksAndData(
|
||||
std::vector<uint8_t>& data, int x0, int y0, int z0, int x1, int y1, int z1, int p,
|
||||
std::vector<uint8_t>& data, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int p,
|
||||
bool includeLighting = true); // 4J - added includeLighting parameter
|
||||
bool testSetBlocksAndData(std::vector<uint8_t>& data, int x0, int y0, int z0, int x1,
|
||||
int y1, int z1, int p); // 4J added
|
||||
bool testSetBlocksAndData(std::vector<uint8_t>& data, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1,
|
||||
int p); // 4J added
|
||||
Random* getRandom(int64_t l);
|
||||
bool isEmpty();
|
||||
virtual void reSyncLighting() {}; // 4J added
|
||||
|
||||
@@ -94,7 +94,6 @@ void LevelChunk::init(Level* level, int x, int z) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lowestHeightmap = 256;
|
||||
inhabitedTime = 0;
|
||||
|
||||
@@ -278,7 +277,6 @@ void LevelChunk::stopSharingTilesAndData() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Changed to used compressed storage - these CTORs make deep copies of
|
||||
// the storage passed as a parameter
|
||||
lowerBlocks = new CompressedTileStorage(lowerBlocks);
|
||||
@@ -442,11 +440,9 @@ LevelChunk::~LevelChunk() {
|
||||
if (upperSkyLight) delete upperSkyLight;
|
||||
if (upperBlockLight) delete upperBlockLight;
|
||||
|
||||
|
||||
for (int i = 0; i < ENTITY_BLOCKS_LENGTH; ++i) delete entityBlocks[i];
|
||||
delete[] entityBlocks;
|
||||
|
||||
|
||||
#if defined(_LARGE_WORLDS)
|
||||
delete m_unloadedEntitiesTag;
|
||||
#endif
|
||||
@@ -832,12 +828,11 @@ void LevelChunk::recalcHeight(int x, int yStart, int z) {
|
||||
}
|
||||
if (height < lowestHeightmap) lowestHeightmap = height;
|
||||
if (!level->dimension->hasCeiling) {
|
||||
lightGap(xOffs - 1, zOffs, y1, y2);
|
||||
lightGap(xOffs - 1, zOffs, y1, y2);
|
||||
lightGap(xOffs + 1, zOffs, y1, y2);
|
||||
lightGap(xOffs, zOffs - 1, y1, y2);
|
||||
lightGap(xOffs, zOffs + 1, y1, y2);
|
||||
lightGap(xOffs, zOffs, y1, y2);
|
||||
|
||||
}
|
||||
|
||||
this->setUnsaved(true);
|
||||
@@ -896,8 +891,8 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) {
|
||||
if (old != 0 && !level->isClientSide) {
|
||||
Tile::tiles[old]->onRemoving(level, xOffs, y, zOffs, oldData);
|
||||
}
|
||||
blocks->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, tile);
|
||||
|
||||
blocks->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, tile);
|
||||
|
||||
if (old != 0) {
|
||||
if (!level->isClientSide) {
|
||||
Tile::tiles[old]->onRemove(level, xOffs, y, zOffs, old, oldData);
|
||||
@@ -905,8 +900,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) {
|
||||
level->removeTileEntity(xOffs, y, zOffs);
|
||||
}
|
||||
}
|
||||
data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, _data);
|
||||
|
||||
data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, _data);
|
||||
|
||||
// 4J added - flag if something emissive is being added. This is used during
|
||||
// level creation to determine what chunks need extra lighting processing
|
||||
@@ -914,30 +908,27 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) {
|
||||
emissiveAdded = true;
|
||||
}
|
||||
|
||||
// 4J - There isn't any point in recalculating heights or updating sky
|
||||
// 4J - There isn't any point in recalculating heights or updating sky
|
||||
// lighting if this tile has the same light-blocking capabilities as the one
|
||||
// it is replacing
|
||||
if (Tile::lightBlock[tile & 0xff] != Tile::lightBlock[old & 0xff]) {
|
||||
if (!level->dimension->hasCeiling) {
|
||||
if (Tile::lightBlock[tile & 0xff] != 0) {
|
||||
if (y >= oldHeight) {
|
||||
recalcHeight(x, y + 1, z);
|
||||
|
||||
recalcHeight(x, y + 1, z);
|
||||
}
|
||||
} else {
|
||||
if (y == oldHeight - 1) {
|
||||
recalcHeight(x, y, z);
|
||||
|
||||
recalcHeight(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// level.updateLight(LightLayer.Carried, xOffs, y, zOffs, xOffs, y,
|
||||
// zOffs);
|
||||
lightGaps(x, z);
|
||||
|
||||
lightGaps(x, z);
|
||||
}
|
||||
|
||||
|
||||
data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, _data);
|
||||
if (_tile != 0) {
|
||||
if (!level->isClientSide) {
|
||||
@@ -1450,7 +1441,7 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter
|
||||
// 4J Stu - Save out entities to a cached format that won't
|
||||
// interfere with other systems
|
||||
m_unloadedEntitiesTag = new CompoundTag();
|
||||
ListTag<CompoundTag>* entityTags = new ListTag<CompoundTag>();
|
||||
ListTag<CompoundTag>* entityTags = new ListTag<CompoundTag>();
|
||||
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_csEntities);
|
||||
@@ -1472,9 +1463,8 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter
|
||||
}
|
||||
|
||||
m_unloadedEntitiesTag->put(L"Entities", entityTags);
|
||||
|
||||
|
||||
ListTag<CompoundTag>* tileEntityTags = new ListTag<CompoundTag>();
|
||||
ListTag<CompoundTag>* tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
auto itEnd = tileEntities.end();
|
||||
for (std::unordered_map<TilePos, std::shared_ptr<TileEntity>,
|
||||
@@ -1490,7 +1480,6 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter
|
||||
tileEntities.clear();
|
||||
|
||||
m_unloadedEntitiesTag->put(L"TileEntities", tileEntityTags);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1645,8 +1634,8 @@ bool LevelChunk::shouldSave(bool force) {
|
||||
return m_unsaved;
|
||||
}
|
||||
|
||||
int LevelChunk::getBlocksAndData(std::vector<uint8_t>* data, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1, int p,
|
||||
int LevelChunk::getBlocksAndData(std::vector<uint8_t>* data, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1, int p,
|
||||
bool includeLighting /* = true*/) {
|
||||
int xs = x1 - x0;
|
||||
int ys = y1 - y0;
|
||||
@@ -1716,8 +1705,9 @@ int LevelChunk::getBlocksAndData(std::vector<uint8_t>* data, int x0, int y0, int
|
||||
}
|
||||
|
||||
// 4J added - return true if setBlocksAndData would change any blocks
|
||||
bool LevelChunk::testSetBlocksAndData(std::vector<uint8_t>& data, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1, int p) {
|
||||
bool LevelChunk::testSetBlocksAndData(std::vector<uint8_t>& data, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int p) {
|
||||
bool changed = false;
|
||||
|
||||
// 4J Stu - Added this because some "min" functions don't let us use our
|
||||
@@ -1745,8 +1735,8 @@ void LevelChunk::tileUpdatedCallback(int x, int y, int z, void* param,
|
||||
lc->level->checkLight(xx, yy, zz);
|
||||
}
|
||||
|
||||
int LevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0, int y0, int z0, int x1,
|
||||
int y1, int z1, int p,
|
||||
int LevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1, int p,
|
||||
bool includeLighting /* = true*/) {
|
||||
// If includeLighting is set, then this is a full chunk's worth of data that
|
||||
// we are receiving on the client. We'll have made this chunk initially as
|
||||
@@ -2336,8 +2326,9 @@ int LevelChunk::getHighestNonEmptyY() {
|
||||
return highestNonEmptyY;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z0, int xs,
|
||||
int& ys, int zs) {
|
||||
std::vector<uint8_t> LevelChunk::getReorderedBlocksAndData(int x0, int y0,
|
||||
int z0, int xs,
|
||||
int& ys, int zs) {
|
||||
int highestNonEmpty = getHighestNonEmptyY();
|
||||
|
||||
ys = std::min(highestNonEmpty - y0, ys);
|
||||
@@ -2350,7 +2341,8 @@ std::vector<uint8_t> LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z
|
||||
unsigned int tileCount = xs * ys * zs;
|
||||
unsigned int halfTileCount = tileCount / 2;
|
||||
|
||||
std::vector<uint8_t> data = std::vector<uint8_t>(tileCount + (3 * halfTileCount) + biomes.size());
|
||||
std::vector<uint8_t> data =
|
||||
std::vector<uint8_t>(tileCount + (3 * halfTileCount) + biomes.size());
|
||||
for (int x = 0; x < xs; x++) {
|
||||
for (int z = 0; z < zs; z++) {
|
||||
for (int y = 0; y < ys; y++) {
|
||||
@@ -2398,8 +2390,9 @@ std::vector<uint8_t> LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z
|
||||
|
||||
return data;
|
||||
|
||||
// std::vector<uint8_t> rawBuffer = std::vector<uint8_t>( Level::CHUNK_TILE_COUNT + (3*
|
||||
// Level::HALF_CHUNK_TILE_COUNT) ); for( int x = 0; x < 16; x++ )
|
||||
// std::vector<uint8_t> rawBuffer = std::vector<uint8_t>(
|
||||
// Level::CHUNK_TILE_COUNT + (3* Level::HALF_CHUNK_TILE_COUNT) ); for( int x
|
||||
// = 0; x < 16; x++ )
|
||||
//{
|
||||
// for( int z = 0; z < 16; z++ )
|
||||
// {
|
||||
@@ -2415,13 +2408,15 @@ std::vector<uint8_t> LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z
|
||||
// unsigned int offset = Level::CHUNK_TILE_COUNT;
|
||||
//// Don't bother reordering block data, block light or sky light as they
|
||||
/// don't seem to make much difference
|
||||
// std::vector<uint8_t> dataData = std::vector<uint8_t>(rawBuffer.data()+offset,
|
||||
// std::vector<uint8_t> dataData =
|
||||
// std::vector<uint8_t>(rawBuffer.data()+offset,
|
||||
// Level::HALF_CHUNK_TILE_COUNT); lc->getDataData(dataData); offset +=
|
||||
// Level::HALF_CHUNK_TILE_COUNT; std::vector<uint8_t> blockLightData =
|
||||
// std::vector<uint8_t>(rawBuffer.data() + offset, Level::HALF_CHUNK_TILE_COUNT); offset
|
||||
// std::vector<uint8_t>(rawBuffer.data() + offset,
|
||||
// Level::HALF_CHUNK_TILE_COUNT); offset
|
||||
// += Level::HALF_CHUNK_TILE_COUNT; std::vector<uint8_t> skyLightData =
|
||||
// std::vector<uint8_t>(rawBuffer.data() + offset, Level::HALF_CHUNK_TILE_COUNT);
|
||||
// lc->getBlockLightData(blockLightData);
|
||||
// std::vector<uint8_t>(rawBuffer.data() + offset,
|
||||
// Level::HALF_CHUNK_TILE_COUNT); lc->getBlockLightData(blockLightData);
|
||||
// lc->getSkyLightData(skyLightData);
|
||||
// return rawBuffer;
|
||||
}
|
||||
|
||||
@@ -65,11 +65,12 @@ private:
|
||||
CompressedTileStorage* upperBlocks; // 128 - 255
|
||||
public:
|
||||
bool isRenderChunkEmpty(int y);
|
||||
void setBlockData(std::vector<uint8_t>& data); // Set block data to that passed in in
|
||||
// the input array of size 32768
|
||||
void getBlockData(
|
||||
std::vector<uint8_t>& data); // Sets data in passed in array of size 32768, from
|
||||
// the block data in this chunk
|
||||
void setBlockData(
|
||||
std::vector<uint8_t>& data); // Set block data to that passed in in
|
||||
// the input array of size 32768
|
||||
void getBlockData(std::vector<uint8_t>&
|
||||
data); // Sets data in passed in array of size 32768,
|
||||
// from the block data in this chunk
|
||||
int getBlocksAllocatedSize(int* count0, int* count1, int* count2,
|
||||
int* count4, int* count8);
|
||||
|
||||
@@ -89,10 +90,12 @@ private:
|
||||
SparseDataStorage* lowerData; // 0 - 127
|
||||
SparseDataStorage* upperData; // 128 - 255
|
||||
public:
|
||||
void setDataData(std::vector<uint8_t>& data); // Set data to that passed in in the
|
||||
// input array of size 32768
|
||||
void getDataData(std::vector<uint8_t>& data); // Sets data in passed in array of size
|
||||
// 16384, from the data in this chunk
|
||||
void setDataData(
|
||||
std::vector<uint8_t>& data); // Set data to that passed in in the
|
||||
// input array of size 32768
|
||||
void getDataData(
|
||||
std::vector<uint8_t>& data); // Sets data in passed in array of size
|
||||
// 16384, from the data in this chunk
|
||||
|
||||
// DataLayer *data;
|
||||
private:
|
||||
@@ -109,17 +112,20 @@ public:
|
||||
data); // Get a byte array of length 16384 ( 128 x 16 x 16 x 0.5 ),
|
||||
// containing sky light data. Ordering same as java version.
|
||||
void getBlockLightData(
|
||||
std::vector<uint8_t>& data); // Get a byte array of length 16384 ( 128 x 16 x 16 x
|
||||
// 0.5 ), containing block light data. Ordering same
|
||||
// as java version.
|
||||
std::vector<uint8_t>&
|
||||
data); // Get a byte array of length 16384 ( 128 x 16 x 16 x
|
||||
// 0.5 ), containing block light data. Ordering same
|
||||
// as java version.
|
||||
void setSkyLightData(
|
||||
std::vector<uint8_t>& data); // Set sky light data to data passed in input byte
|
||||
// array of length 16384. This data must be in
|
||||
// original (java version) order
|
||||
std::vector<uint8_t>&
|
||||
data); // Set sky light data to data passed in input byte
|
||||
// array of length 16384. This data must be in
|
||||
// original (java version) order
|
||||
void setBlockLightData(
|
||||
std::vector<uint8_t>& data); // Set block light data to data passed in input byte
|
||||
// array of length 16384. This data must be in
|
||||
// original (java version) order
|
||||
std::vector<uint8_t>&
|
||||
data); // Set block light data to data passed in input byte
|
||||
// array of length 16384. This data must be in
|
||||
// original (java version) order
|
||||
void setSkyLightDataAllBright(); // Set sky light data to be all fully lit
|
||||
bool isLowerBlockStorageCompressed();
|
||||
int isLowerBlockLightStorageCompressed();
|
||||
@@ -271,15 +277,17 @@ public:
|
||||
virtual int countEntities();
|
||||
virtual bool shouldSave(bool force);
|
||||
virtual int getBlocksAndData(
|
||||
std::vector<uint8_t>* data, int x0, int y0, int z0, int x1, int y1, int z1, int p,
|
||||
std::vector<uint8_t>* data, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int p,
|
||||
bool includeLighting = true); // 4J - added includeLighting parameter
|
||||
static void tileUpdatedCallback(int x, int y, int z, void* param,
|
||||
int yparam); // 4J added
|
||||
virtual int setBlocksAndData(
|
||||
std::vector<uint8_t>& data, int x0, int y0, int z0, int x1, int y1, int z1, int p,
|
||||
std::vector<uint8_t>& data, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int p,
|
||||
bool includeLighting = true); // 4J - added includeLighting parameter
|
||||
virtual bool testSetBlocksAndData(std::vector<uint8_t>& data, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1,
|
||||
virtual bool testSetBlocksAndData(std::vector<uint8_t>& data, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int p); // 4J added
|
||||
virtual void setCheckAllLight();
|
||||
|
||||
@@ -315,8 +323,8 @@ public:
|
||||
void compressBlocks(); // 4J added
|
||||
void compressData(); // 4J added
|
||||
int getHighestNonEmptyY();
|
||||
std::vector<uint8_t> getReorderedBlocksAndData(int x, int y, int z, int xs, int& ys,
|
||||
int zs);
|
||||
std::vector<uint8_t> getReorderedBlocksAndData(int x, int y, int z, int xs,
|
||||
int& ys, int zs);
|
||||
static void reorderBlocksAndDataToXZY(int y0, int xs, int ys, int zs,
|
||||
std::vector<uint8_t>* data);
|
||||
#if defined(LIGHT_COMPRESSION_STATS)
|
||||
|
||||
@@ -14,8 +14,6 @@ ReadOnlyChunkCache::ReadOnlyChunkCache(Level* level, ChunkStorage* storage) {
|
||||
|
||||
ReadOnlyChunkCache::~ReadOnlyChunkCache() {
|
||||
for (unsigned int i = 0; i < chunks.size(); ++i) delete chunks[i];
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool ReadOnlyChunkCache::hasChunk(int x, int z) {
|
||||
|
||||
@@ -125,7 +125,8 @@ SparseDataStorage::SparseDataStorage(SparseDataStorage* copyFrom) {
|
||||
|
||||
// Set all data values from a data array of length 16384 (128 x 16 x 16 x 0.5).
|
||||
// Source data must have same order as original java game
|
||||
void SparseDataStorage::setData(std::vector<uint8_t>& dataIn, unsigned int inOffset) {
|
||||
void SparseDataStorage::setData(std::vector<uint8_t>& dataIn,
|
||||
unsigned int inOffset) {
|
||||
// Original order is defined as:
|
||||
// pos = (x << 11 | z << 7 | y);
|
||||
// slot = pos >> 1;
|
||||
@@ -203,7 +204,8 @@ void SparseDataStorage::setData(std::vector<uint8_t>& dataIn, unsigned int inOff
|
||||
|
||||
// Gets all data values into an array of length 16384. Destination data will
|
||||
// have same order as original java game.
|
||||
void SparseDataStorage::getData(std::vector<uint8_t>& retArray, unsigned int retOffset) {
|
||||
void SparseDataStorage::getData(std::vector<uint8_t>& retArray,
|
||||
unsigned int retOffset) {
|
||||
memset(retArray.data() + +retOffset, 0, 16384);
|
||||
unsigned char *planeIndices, *data;
|
||||
getPlaneIndicesAndData(&planeIndices, &data);
|
||||
@@ -303,10 +305,10 @@ void SparseDataStorage::set(int x, int y, int z, int val) {
|
||||
// packed in nyblles in this dimension, and the code didn't make any attempt to
|
||||
// unpack it. This behaviour is copied here for compatibility even though our
|
||||
// source data isn't packed this way. Returns size of data copied.
|
||||
int SparseDataStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1, int offset,
|
||||
tileUpdatedCallback callback, void* param,
|
||||
int yparam) {
|
||||
int SparseDataStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int offset, tileUpdatedCallback callback,
|
||||
void* param, int yparam) {
|
||||
// Actual setting of data happens when calling set method so no need to lock
|
||||
// here
|
||||
unsigned char* pucIn = &dataIn.data()[offset];
|
||||
@@ -363,8 +365,8 @@ int SparseDataStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0, int y
|
||||
// packed in nyblles in this dimension, and the code didn't make any attempt to
|
||||
// unpack it. This behaviour is copied here for compatibility even though our
|
||||
// source data isn't packed this way Returns size of data copied.
|
||||
int SparseDataStorage::getDataRegion(std::vector<uint8_t>& dataInOut, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1,
|
||||
int SparseDataStorage::getDataRegion(std::vector<uint8_t>& dataInOut, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int offset) {
|
||||
unsigned char* pucOut = &dataInOut.data()[offset];
|
||||
for (int x = x0; x < x1; x++) {
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
class TileCompressData_SPU;
|
||||
class DataInputStream;
|
||||
class DataOutputStream;
|
||||
template <typename T> class XLockFreeStack;
|
||||
template <typename T>
|
||||
class XLockFreeStack;
|
||||
|
||||
class SparseDataStorage {
|
||||
friend class TileCompressData_SPU;
|
||||
@@ -90,13 +91,14 @@ public:
|
||||
typedef void (*tileUpdatedCallback)(int x, int y, int z, void* param,
|
||||
int yparam);
|
||||
int setDataRegion(
|
||||
std::vector<uint8_t>& dataIn, int x0, int y0, int z0, int x1, int y1, int z1,
|
||||
int offset, tileUpdatedCallback callback, void* param,
|
||||
std::vector<uint8_t>& dataIn, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int offset, tileUpdatedCallback callback, void* param,
|
||||
int yparam); // Sets a region of data values with the data at offset
|
||||
// position in the array dataIn - external ordering
|
||||
// compatible with java DataLayer
|
||||
int getDataRegion(
|
||||
std::vector<uint8_t>& dataInOut, int x0, int y0, int z0, int x1, int y1, int z1,
|
||||
std::vector<uint8_t>& dataInOut, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1,
|
||||
int offset); // Updates the data at offset position dataInOut with a
|
||||
// region of data information - external ordering
|
||||
// compatible with java DataLayer
|
||||
|
||||
@@ -126,7 +126,8 @@ SparseLightStorage::SparseLightStorage(SparseLightStorage* copyFrom) {
|
||||
|
||||
// Set all lighting values from a data array of length 16384 (128 x 16 x 16 x
|
||||
// 0.5). Source data must have same order as original java game
|
||||
void SparseLightStorage::setData(std::vector<uint8_t>& dataIn, unsigned int inOffset) {
|
||||
void SparseLightStorage::setData(std::vector<uint8_t>& dataIn,
|
||||
unsigned int inOffset) {
|
||||
// Original order is defined as:
|
||||
// pos = (x << 11 | z << 7 | y);
|
||||
// slot = pos >> 1;
|
||||
@@ -205,7 +206,8 @@ void SparseLightStorage::setData(std::vector<uint8_t>& dataIn, unsigned int inOf
|
||||
|
||||
// Gets all lighting values into an array of length 16384. Destination data will
|
||||
// have same order as original java game.
|
||||
void SparseLightStorage::getData(std::vector<uint8_t>& retArray, unsigned int retOffset) {
|
||||
void SparseLightStorage::getData(std::vector<uint8_t>& retArray,
|
||||
unsigned int retOffset) {
|
||||
memset(retArray.data() + retOffset, 0, 16384);
|
||||
unsigned char *planeIndices, *data;
|
||||
getPlaneIndicesAndData(&planeIndices, &data);
|
||||
@@ -332,8 +334,9 @@ void SparseLightStorage::setAllBright() {
|
||||
// code didn't make any attempt to unpack it. This behaviour is copied here for
|
||||
// compatibility even though our source data isn't packed this way. Returns size
|
||||
// of data copied.
|
||||
int SparseLightStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1, int offset) {
|
||||
int SparseLightStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int offset) {
|
||||
// Actual setting of data happens when calling set method so no need to lock
|
||||
// here
|
||||
unsigned char* pucIn = &dataIn.data()[offset];
|
||||
@@ -364,8 +367,8 @@ int SparseLightStorage::setDataRegion(std::vector<uint8_t>& dataIn, int x0, int
|
||||
// packed in nyblles in this dimension, and the code didn't make any attempt to
|
||||
// unpack it. This behaviour is copied here for compatibility even though our
|
||||
// source data isn't packed this way Returns size of data copied.
|
||||
int SparseLightStorage::getDataRegion(std::vector<uint8_t>& dataInOut, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1,
|
||||
int SparseLightStorage::getDataRegion(std::vector<uint8_t>& dataInOut, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int offset) {
|
||||
unsigned char* pucOut = &dataInOut.data()[offset];
|
||||
for (int x = x0; x < x1; x++) {
|
||||
|
||||
@@ -59,7 +59,8 @@
|
||||
class TileCompressData_SPU;
|
||||
class DataInputStream;
|
||||
class DataOutputStream;
|
||||
template <typename T> class XLockFreeStack;
|
||||
template <typename T>
|
||||
class XLockFreeStack;
|
||||
|
||||
class SparseLightStorage {
|
||||
friend class TileCompressData_SPU;
|
||||
@@ -92,12 +93,14 @@ public:
|
||||
void set(int x, int y, int z, int val); // Set an individual lighting value
|
||||
void setAllBright(); // Set all lighting values to fully bright
|
||||
int setDataRegion(
|
||||
std::vector<uint8_t>& dataIn, int x0, int y0, int z0, int x1, int y1, int z1,
|
||||
std::vector<uint8_t>& dataIn, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1,
|
||||
int offset); // Sets a region of lighting values with the data at
|
||||
// offset position in the array dataIn - external ordering
|
||||
// compatible with java DataLayer
|
||||
int getDataRegion(
|
||||
std::vector<uint8_t>& dataInOut, int x0, int y0, int z0, int x1, int y1, int z1,
|
||||
std::vector<uint8_t>& dataInOut, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1,
|
||||
int offset); // Updates the data at offset position dataInOut with a
|
||||
// region of lighting information - external ordering
|
||||
// compatible with java DataLayer
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
class Entity;
|
||||
|
||||
WaterLevelChunk::WaterLevelChunk(Level* level, std::vector<uint8_t>& blocks, int x, int z)
|
||||
WaterLevelChunk::WaterLevelChunk(Level* level, std::vector<uint8_t>& blocks,
|
||||
int x, int z)
|
||||
: LevelChunk(level, blocks, x, z) {
|
||||
dontSave = true;
|
||||
// Set this as fully post-processed, so we don't try and run post-processing
|
||||
@@ -85,9 +86,9 @@ bool WaterLevelChunk::shouldSave(bool force) { return false; }
|
||||
|
||||
void WaterLevelChunk::setBlocks(std::vector<uint8_t>& newBlocks, int sub) {}
|
||||
|
||||
int WaterLevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0, int y0, int z0,
|
||||
int x1, int y1, int z1, int p,
|
||||
bool includeLighting /* = true*/) {
|
||||
int WaterLevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int p, bool includeLighting /* = true*/) {
|
||||
int xs = x1 - x0;
|
||||
int ys = y1 - y0;
|
||||
int zs = z1 - z0;
|
||||
@@ -101,9 +102,9 @@ int WaterLevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0, int y0
|
||||
}
|
||||
}
|
||||
|
||||
bool WaterLevelChunk::testSetBlocksAndData(std::vector<uint8_t>& data, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1,
|
||||
int p) {
|
||||
bool WaterLevelChunk::testSetBlocksAndData(std::vector<uint8_t>& data, int x0,
|
||||
int y0, int z0, int x1, int y1,
|
||||
int z1, int p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,11 @@ public:
|
||||
bool shouldSave(bool force);
|
||||
void setBlocks(std::vector<uint8_t>& newBlocks, int sub);
|
||||
int setBlocksAndData(
|
||||
std::vector<uint8_t>& data, int x0, int y0, int z0, int x1, int y1, int z1, int p,
|
||||
std::vector<uint8_t>& data, int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int p,
|
||||
bool includeLighting = true); // 4J - added includeLighting parameter;
|
||||
bool testSetBlocksAndData(std::vector<uint8_t>& data, int x0, int y0, int z0, int x1,
|
||||
int y1, int z1, int p);
|
||||
bool testSetBlocksAndData(std::vector<uint8_t>& data, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1, int p);
|
||||
Random* getRandom(int64_t l);
|
||||
virtual Biome* getBiome(int x, int z, BiomeSource* biomeSource);
|
||||
virtual void reSyncLighting() {}; // 4J added
|
||||
|
||||
@@ -202,45 +202,40 @@ void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) {
|
||||
// running saves on multiple threads these sections have a lot of
|
||||
// contention. Better to let each thread have its turn at a higher level of
|
||||
// granularity.
|
||||
DataOutputStream* output = RegionFileCache::getChunkDataOutputStream(
|
||||
DataOutputStream* output = RegionFileCache::getChunkDataOutputStream(
|
||||
m_saveFile, m_prefix, levelChunk->x, levelChunk->z);
|
||||
|
||||
|
||||
if (m_saveFile->getOriginalSaveVersion() >=
|
||||
SAVE_FILE_VERSION_COMPRESSED_CHUNK_STORAGE) {
|
||||
OldChunkStorage::save(levelChunk, level, output);
|
||||
|
||||
OldChunkStorage::save(levelChunk, level, output);
|
||||
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cs_memory);
|
||||
s_chunkDataQueue.push_back(output);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
CompoundTag* tag;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cs_memory);
|
||||
tag = new CompoundTag();
|
||||
tag = new CompoundTag();
|
||||
CompoundTag* levelData = new CompoundTag();
|
||||
tag->put(L"Level", levelData);
|
||||
OldChunkStorage::save(levelChunk, level, levelData);
|
||||
|
||||
NbtIo::write(tag, output);
|
||||
|
||||
|
||||
NbtIo::write(tag, output);
|
||||
}
|
||||
output->close();
|
||||
|
||||
output->close();
|
||||
|
||||
// 4J Stu - getChunkDataOutputStream makes a new DataOutputStream that
|
||||
// points to a new ChunkBuffer( ByteArrayOutputStream ) We should clean
|
||||
// these up when we are done
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cs_memory);
|
||||
output->deleteChildStream();
|
||||
output->deleteChildStream();
|
||||
delete output;
|
||||
delete tag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LevelData* levelInfo = level->getLevelData();
|
||||
@@ -258,11 +253,10 @@ void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) {
|
||||
|
||||
void McRegionChunkStorage::saveEntities(Level* level, LevelChunk* levelChunk) {
|
||||
#if defined(SPLIT_SAVES)
|
||||
// 4j added cast to unsigned and changed index to u
|
||||
// 4j added cast to unsigned and changed index to u
|
||||
uint64_t index = ((uint64_t)(uint32_t)(levelChunk->x) << 32) |
|
||||
(((uint64_t)(uint32_t)(levelChunk->z)));
|
||||
|
||||
|
||||
CompoundTag* newTag = new CompoundTag();
|
||||
bool savedEntities =
|
||||
OldChunkStorage::saveEntities(levelChunk, level, newTag);
|
||||
@@ -283,7 +277,7 @@ void McRegionChunkStorage::saveEntities(Level* level, LevelChunk* levelChunk) {
|
||||
}
|
||||
}
|
||||
delete newTag;
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -308,22 +302,21 @@ void McRegionChunkStorage::tick() { m_saveFile->tick(); }
|
||||
|
||||
void McRegionChunkStorage::flush() {
|
||||
#if defined(SPLIT_SAVES)
|
||||
ConsoleSavePath currentFile =
|
||||
ConsoleSavePath currentFile =
|
||||
ConsoleSavePath(m_prefix + std::wstring(L"entities.dat"));
|
||||
ConsoleSaveFileOutputStream fos =
|
||||
ConsoleSaveFileOutputStream(m_saveFile, currentFile);
|
||||
BufferedOutputStream bos(&fos, 1024 * 1024);
|
||||
DataOutputStream dos(&bos);
|
||||
|
||||
dos.writeInt(m_entityData.size());
|
||||
dos.writeInt(m_entityData.size());
|
||||
|
||||
for (auto it = m_entityData.begin(); it != m_entityData.end(); ++it) {
|
||||
dos.writeLong(it->first);
|
||||
dos.write(it->second, 0, it->second.size());
|
||||
}
|
||||
bos.flush();
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -373,11 +366,10 @@ int McRegionChunkStorage::runSaveThreadProc(void* lpParam) {
|
||||
lock.unlock();
|
||||
|
||||
if (dos) {
|
||||
// app.DebugPrintf("Compressing chunk data (%d left)\n",
|
||||
// app.DebugPrintf("Compressing chunk data (%d left)\n",
|
||||
// lastQueueSize - 1);
|
||||
dos->close();
|
||||
dos->deleteChildStream();
|
||||
|
||||
}
|
||||
delete dos;
|
||||
dos = nullptr;
|
||||
|
||||
@@ -45,8 +45,7 @@ OldChunkStorage::ThreadStorage::ThreadStorage() {
|
||||
blockLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
|
||||
}
|
||||
|
||||
OldChunkStorage::ThreadStorage::~ThreadStorage() {
|
||||
}
|
||||
OldChunkStorage::ThreadStorage::~ThreadStorage() {}
|
||||
|
||||
void OldChunkStorage::CreateNewThreadStorage() {
|
||||
ThreadStorage* tls = new ThreadStorage();
|
||||
@@ -246,26 +245,23 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level,
|
||||
dos->writeLong(level->getGameTime());
|
||||
dos->writeLong(lc->inhabitedTime);
|
||||
|
||||
lc->writeCompressedBlockData(dos);
|
||||
|
||||
lc->writeCompressedBlockData(dos);
|
||||
|
||||
lc->writeCompressedDataData(dos);
|
||||
|
||||
lc->writeCompressedDataData(dos);
|
||||
|
||||
lc->writeCompressedSkyLightData(dos);
|
||||
lc->writeCompressedSkyLightData(dos);
|
||||
lc->writeCompressedBlockLightData(dos);
|
||||
|
||||
|
||||
dos->write(lc->heightmap);
|
||||
dos->writeShort(lc->terrainPopulated);
|
||||
dos->write(lc->getBiomes());
|
||||
|
||||
CompoundTag* tag = new CompoundTag();
|
||||
CompoundTag* tag = new CompoundTag();
|
||||
#if !defined(SPLIT_SAVES)
|
||||
saveEntities(lc, level, tag);
|
||||
#endif
|
||||
|
||||
ListTag<CompoundTag>* tileEntityTags = new ListTag<CompoundTag>();
|
||||
ListTag<CompoundTag>* tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
auto itEnd = lc->tileEntities.end();
|
||||
for (std::unordered_map<TilePos, std::shared_ptr<TileEntity>,
|
||||
@@ -278,9 +274,8 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level,
|
||||
tileEntityTags->add(teTag);
|
||||
}
|
||||
tag->put(L"TileEntities", tileEntityTags);
|
||||
|
||||
|
||||
std::vector<TickNextTickData>* ticksInChunk =
|
||||
std::vector<TickNextTickData>* ticksInChunk =
|
||||
level->fetchTicksInChunk(lc, false);
|
||||
if (ticksInChunk != nullptr) {
|
||||
int64_t levelTime = level->getGameTime();
|
||||
@@ -300,11 +295,9 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level,
|
||||
tag->put(L"TileTicks", tickTags);
|
||||
}
|
||||
delete ticksInChunk;
|
||||
|
||||
|
||||
NbtIo::write(tag, dos);
|
||||
delete tag;
|
||||
|
||||
}
|
||||
|
||||
void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) {
|
||||
@@ -327,23 +320,20 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) {
|
||||
// moved to TLS
|
||||
ThreadStorage* tls = m_tlsStorage;
|
||||
|
||||
// static std::vector<uint8_t> blockData = std::vector<uint8_t>(32768);
|
||||
// static std::vector<uint8_t> blockData = std::vector<uint8_t>(32768);
|
||||
lc->getBlockData(tls->blockData);
|
||||
tag->putByteArray(L"Blocks", tls->blockData);
|
||||
|
||||
|
||||
// static std::vector<uint8_t> dataData = std::vector<uint8_t>(16384);
|
||||
// static std::vector<uint8_t> dataData = std::vector<uint8_t>(16384);
|
||||
lc->getDataData(tls->dataData);
|
||||
tag->putByteArray(L"Data", tls->dataData);
|
||||
|
||||
|
||||
// static std::vector<uint8_t> skyLightData = std::vector<uint8_t>(16384);
|
||||
// static std::vector<uint8_t> skyLightData = std::vector<uint8_t>(16384);
|
||||
// static std::vector<uint8_t> blockLightData = std::vector<uint8_t>(16384);
|
||||
lc->getSkyLightData(tls->skyLightData);
|
||||
lc->getBlockLightData(tls->blockLightData);
|
||||
tag->putByteArray(L"SkyLight", tls->skyLightData);
|
||||
tag->putByteArray(L"BlockLight", tls->blockLightData);
|
||||
|
||||
|
||||
tag->putByteArray(L"HeightMap", lc->heightmap);
|
||||
tag->putShort(
|
||||
@@ -354,11 +344,11 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) {
|
||||
std::vector<uint8_t> biomeData = lc->getBiomes();
|
||||
tag->putByteArray(L"Biomes", biomeData);
|
||||
|
||||
#if !defined(SPLIT_SAVES)
|
||||
#if !defined(SPLIT_SAVES)
|
||||
saveEntities(lc, level, tag);
|
||||
#endif
|
||||
|
||||
ListTag<CompoundTag>* tileEntityTags = new ListTag<CompoundTag>();
|
||||
ListTag<CompoundTag>* tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
auto itEnd = lc->tileEntities.end();
|
||||
for (std::unordered_map<TilePos, std::shared_ptr<TileEntity>,
|
||||
@@ -371,9 +361,8 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) {
|
||||
tileEntityTags->add(teTag);
|
||||
}
|
||||
tag->put(L"TileEntities", tileEntityTags);
|
||||
|
||||
|
||||
std::vector<TickNextTickData>* ticksInChunk =
|
||||
std::vector<TickNextTickData>* ticksInChunk =
|
||||
level->fetchTicksInChunk(lc, false);
|
||||
if (ticksInChunk != nullptr) {
|
||||
int64_t levelTime = level->getGameTime();
|
||||
@@ -394,8 +383,6 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) {
|
||||
tag->put(L"TileTicks", tickTags);
|
||||
}
|
||||
delete ticksInChunk;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void OldChunkStorage::loadEntities(LevelChunk* lc, Level* level,
|
||||
@@ -427,7 +414,7 @@ void OldChunkStorage::loadEntities(LevelChunk* lc, Level* level,
|
||||
}
|
||||
|
||||
LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) {
|
||||
short version = dis->readShort();
|
||||
short version = dis->readShort();
|
||||
int x = dis->readInt();
|
||||
int z = dis->readInt();
|
||||
int time = dis->readLong();
|
||||
@@ -475,7 +462,7 @@ LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) {
|
||||
loadEntities(levelChunk, level, tag);
|
||||
|
||||
if (tag->contains(L"TileTicks")) {
|
||||
ListTag<CompoundTag>* tileTicks =
|
||||
ListTag<CompoundTag>* tileTicks =
|
||||
(ListTag<CompoundTag>*)tag->getList(L"TileTicks");
|
||||
|
||||
if (tileTicks != nullptr) {
|
||||
@@ -488,13 +475,10 @@ LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) {
|
||||
teTag->getInt(L"t"), teTag->getInt(L"p"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delete tag;
|
||||
|
||||
|
||||
|
||||
return levelChunk;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ RegionFile::RegionFile(ConsoleSaveFile* saveFile, File* path) {
|
||||
unsigned int numberOfBytesWritten = 0;
|
||||
unsigned int bytesToWrite = 0x1000 - (fileEntry->getFileSize() & 0xfff);
|
||||
std::uint8_t* zeroBytes = new std::uint8_t[bytesToWrite];
|
||||
memset(zeroBytes, 0, bytesToWrite);
|
||||
memset(zeroBytes, 0, bytesToWrite);
|
||||
|
||||
/* the file size is not a multiple of 4KB, grow it */
|
||||
m_saveFile->writeFile(fileEntry, zeroBytes, bytesToWrite,
|
||||
@@ -271,8 +271,8 @@ DataInputStream* RegionFile::getChunkDataInputStream(
|
||||
// 4J - was InflaterInputStream in here too, but we've already decompressed
|
||||
std::vector<uint8_t> decompData(decomp, decomp + readDecompLength);
|
||||
delete[] decomp;
|
||||
DataInputStream* ret = new DataInputStream(
|
||||
new ByteArrayInputStream(decompData));
|
||||
DataInputStream* ret =
|
||||
new DataInputStream(new ByteArrayInputStream(decompData));
|
||||
return ret;
|
||||
|
||||
// } catch (IOException e) {
|
||||
@@ -337,7 +337,7 @@ void RegionFile::write(int x, int z, std::uint8_t* data,
|
||||
// better compressed until it is reused
|
||||
zero(sectorNumber, SECTOR_BYTES * sectorsAllocated);
|
||||
|
||||
/* scan for a free space large enough to store this chunk */
|
||||
/* scan for a free space large enough to store this chunk */
|
||||
int runStart =
|
||||
(int)(find(sectorFree->begin(), sectorFree->end(), true) -
|
||||
sectorFree
|
||||
@@ -359,7 +359,6 @@ void RegionFile::write(int x, int z, std::uint8_t* data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (runLength >= sectorsNeeded) {
|
||||
/* we found a free space large enough */
|
||||
@@ -392,7 +391,6 @@ void RegionFile::write(int x, int z, std::uint8_t* data,
|
||||
|
||||
write(sectorNumber, compData, length, compLength);
|
||||
setOffset(x, z, (sectorNumber << 8) | sectorsNeeded);
|
||||
|
||||
}
|
||||
}
|
||||
setTimestamp(x, z, (int)(System::currentTimeMillis() / 1000L));
|
||||
@@ -454,7 +452,7 @@ void RegionFile::insertInitialSectors() {
|
||||
m_saveFile->setFilePointer(fileEntry, 0, SaveFileSeekOrigin::Begin);
|
||||
unsigned int numberOfBytesWritten = 0;
|
||||
std::uint8_t zeroBytes[SECTOR_BYTES];
|
||||
memset(zeroBytes, 0, SECTOR_BYTES);
|
||||
memset(zeroBytes, 0, SECTOR_BYTES);
|
||||
|
||||
/* we need to write the chunk offset table */
|
||||
m_saveFile->writeFile(fileEntry, zeroBytes, SECTOR_BYTES,
|
||||
|
||||
@@ -50,7 +50,6 @@ ZoneFile::ZoneFile(int64_t key, File file, File entityFile)
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void ZoneFile::readHeader() {
|
||||
ZoneIo* zoneIo = new ZoneIo(channel, 0);
|
||||
ByteBuffer* bb = zoneIo->read(FILE_HEADER_SIZE);
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
#include "minecraft/world/level/tile/Tile.h"
|
||||
|
||||
void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs,
|
||||
std::vector<uint8_t>& blocks, double xCave, double yCave,
|
||||
double zCave, float thickness, float yRot,
|
||||
float xRot, int step, int dist, double yScale) {
|
||||
std::vector<uint8_t>& blocks, double xCave,
|
||||
double yCave, double zCave, float thickness,
|
||||
float yRot, float xRot, int step, int dist,
|
||||
double yScale) {
|
||||
Random* random = new Random(seed);
|
||||
double xMid = xOffs * 16 + 8;
|
||||
double zMid = zOffs * 16 + 8;
|
||||
@@ -43,7 +44,8 @@ void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs,
|
||||
}
|
||||
|
||||
for (; step < dist; step++) {
|
||||
double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1;
|
||||
double rad =
|
||||
1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1;
|
||||
double yRad = rad * yScale;
|
||||
|
||||
rad *= (random->nextFloat() * 0.25 + 0.75);
|
||||
|
||||
@@ -12,9 +12,10 @@ private:
|
||||
float rs[1024];
|
||||
|
||||
protected:
|
||||
void addTunnel(int64_t seed, int xOffs, int zOffs, std::vector<uint8_t>& blocks,
|
||||
double xCave, double yCave, double zCave, float thickness,
|
||||
float yRot, float xRot, int step, int dist, double yScale);
|
||||
void addTunnel(int64_t seed, int xOffs, int zOffs,
|
||||
std::vector<uint8_t>& blocks, double xCave, double yCave,
|
||||
double zCave, float thickness, float yRot, float xRot,
|
||||
int step, int dist, double yScale);
|
||||
virtual void addFeature(Level* level, int x, int z, int xOffs, int zOffs,
|
||||
std::vector<uint8_t>& blocks);
|
||||
};
|
||||
|
||||
@@ -40,7 +40,8 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed,
|
||||
#if defined(_OVERRIDE_HEIGHTMAP)
|
||||
m_XZSize = level->getLevelData()->getXZSize();
|
||||
|
||||
m_heightmapOverride = std::vector<uint8_t>((m_XZSize * 16) * (m_XZSize * 16));
|
||||
m_heightmapOverride =
|
||||
std::vector<uint8_t>((m_XZSize * 16) * (m_XZSize * 16));
|
||||
|
||||
std::filesystem::path path = "GameRules/heightmap.bin";
|
||||
std::ifstream file(path, std::ios::binary);
|
||||
@@ -53,14 +54,16 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed,
|
||||
app.DebugPrintf("Heightmap binary is too large!!\n");
|
||||
__debugbreak();
|
||||
}
|
||||
file.read(reinterpret_cast<char*>(m_heightmapOverride.data()), static_cast<std::streamsize>(fileSize));
|
||||
file.read(reinterpret_cast<char*>(m_heightmapOverride.data()),
|
||||
static_cast<std::streamsize>(fileSize));
|
||||
|
||||
if (!file) {
|
||||
app.FatalLoadError();
|
||||
}
|
||||
}
|
||||
|
||||
m_waterheightOverride = std::vector<uint8_t>((m_XZSize * 16) * (m_XZSize * 16));
|
||||
m_waterheightOverride =
|
||||
std::vector<uint8_t>((m_XZSize * 16) * (m_XZSize * 16));
|
||||
|
||||
std::filesystem::path waterHeightPath = "GameRules/waterheight.bin";
|
||||
std::ifstream waterHeightFile(waterHeightPath, std::ios::binary);
|
||||
@@ -74,7 +77,9 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed,
|
||||
app.DebugPrintf("waterheight binary is too large!!\n");
|
||||
__debugbreak();
|
||||
}
|
||||
waterHeightFile.read(reinterpret_cast<char*>(m_waterheightOverride.data()), static_cast<std::streamsize>(waterFileSize));
|
||||
waterHeightFile.read(
|
||||
reinterpret_cast<char*>(m_waterheightOverride.data()),
|
||||
static_cast<std::streamsize>(waterFileSize));
|
||||
|
||||
if (!waterHeightFile) {
|
||||
app.FatalLoadError();
|
||||
@@ -111,7 +116,8 @@ CustomLevelSource::~CustomLevelSource() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void CustomLevelSource::prepareHeights(int xOffs, int zOffs, std::vector<uint8_t>& blocks) {
|
||||
void CustomLevelSource::prepareHeights(int xOffs, int zOffs,
|
||||
std::vector<uint8_t>& blocks) {
|
||||
#if defined(_OVERRIDE_HEIGHTMAP)
|
||||
int xChunks = 16 / CHUNK_WIDTH;
|
||||
int yChunks = Level::maxBuildHeight / CHUNK_HEIGHT;
|
||||
@@ -232,7 +238,8 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, std::vector<uint8_t
|
||||
#endif
|
||||
}
|
||||
|
||||
void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, std::vector<uint8_t>& blocks,
|
||||
void CustomLevelSource::buildSurfaces(int xOffs, int zOffs,
|
||||
std::vector<uint8_t>& blocks,
|
||||
std::vector<Biome*>& biomes) {
|
||||
#if defined(_OVERRIDE_HEIGHTMAP)
|
||||
int waterHeight = level->seaLevel;
|
||||
@@ -241,9 +248,9 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, std::vector<uint8_t>
|
||||
|
||||
double s = 1 / 32.0;
|
||||
|
||||
std::vector<double> depthBuffer(16 *
|
||||
16); // 4J - used to be declared with class level
|
||||
// scope but moved here for thread safety
|
||||
std::vector<double> depthBuffer(
|
||||
16 * 16); // 4J - used to be declared with class level
|
||||
// scope but moved here for thread safety
|
||||
|
||||
depthBuffer = perlinNoise3->getRegion(depthBuffer, xOffs * 16, zOffs * 16,
|
||||
0, 16, 16, 1, s * 2, s * 2, s * 2);
|
||||
@@ -355,8 +362,10 @@ LevelChunk* CustomLevelSource::getChunk(int xOffs, int zOffs) {
|
||||
int blocksSize = Level::maxBuildHeight * 16 * 16;
|
||||
uint8_t* tileData = (uint8_t*)malloc(blocksSize);
|
||||
memset(tileData, 0, blocksSize);
|
||||
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
||||
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
||||
std::vector<uint8_t> blocks =
|
||||
std::vector<uint8_t>(tileData, tileData + blocksSize);
|
||||
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth *
|
||||
// 16);
|
||||
|
||||
// LevelChunk *levelChunk = new LevelChunk(level, blocks, xOffs, zOffs);
|
||||
// // 4J - moved to below
|
||||
@@ -371,7 +380,6 @@ LevelChunk* CustomLevelSource::getChunk(int xOffs, int zOffs) {
|
||||
|
||||
buildSurfaces(xOffs, zOffs, blocks, biomes);
|
||||
|
||||
|
||||
caveFeature->apply(this, level, xOffs, zOffs, blocks);
|
||||
// 4J Stu Design Change - 1.8 gen goes stronghold, mineshaft, village,
|
||||
// canyon this changed in 1.2 to canyon, mineshaft, village, stronghold This
|
||||
@@ -511,15 +519,14 @@ void CustomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) {
|
||||
|
||||
bool hasVillage = false;
|
||||
|
||||
if (generateStructures) {
|
||||
if (generateStructures) {
|
||||
mineShaftFeature->postProcess(level, pprandom, xt, zt);
|
||||
hasVillage = villageFeature->postProcess(level, pprandom, xt, zt);
|
||||
strongholdFeature->postProcess(level, pprandom, xt, zt);
|
||||
scatteredFeature->postProcess(level, random, xt, zt);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
int x = xo + pprandom->nextInt(16) + 8;
|
||||
int y = pprandom->nextInt(Level::maxBuildHeight);
|
||||
int z = zo + pprandom->nextInt(16) + 8;
|
||||
@@ -528,10 +535,8 @@ void CustomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) {
|
||||
}
|
||||
delete mrf;
|
||||
}
|
||||
|
||||
|
||||
biome->decorate(level, pprandom, xo, zo);
|
||||
|
||||
biome->decorate(level, pprandom, xo, zo);
|
||||
|
||||
app.processSchematics(parent->getChunk(xt, zt));
|
||||
|
||||
|
||||
@@ -13,10 +13,11 @@ void DungeonFeature::addRoom(int xOffs, int zOffs, std::vector<uint8_t>& blocks,
|
||||
1 + random->nextFloat() * 6, 0, 0, -1, -1, 0.5);
|
||||
}
|
||||
|
||||
void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector<uint8_t>& blocks,
|
||||
double xCave, double yCave, double zCave,
|
||||
float thickness, float yRot, float xRot,
|
||||
int step, int dist, double yScale) {
|
||||
void DungeonFeature::addTunnel(int xOffs, int zOffs,
|
||||
std::vector<uint8_t>& blocks, double xCave,
|
||||
double yCave, double zCave, float thickness,
|
||||
float yRot, float xRot, int step, int dist,
|
||||
double yScale) {
|
||||
double xMid = xOffs * 16 + 8;
|
||||
double zMid = zOffs * 16 + 8;
|
||||
|
||||
@@ -39,7 +40,8 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector<uint8_t>& block
|
||||
bool steep = random->nextInt(6) == 0;
|
||||
|
||||
for (; step < dist; step++) {
|
||||
double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1;
|
||||
double rad =
|
||||
1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1;
|
||||
double yRad = rad * yScale;
|
||||
|
||||
float xc = Mth::cos(xRot);
|
||||
@@ -65,11 +67,11 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector<uint8_t>& block
|
||||
|
||||
if (!singleStep && step == splitPoint && thickness > 1) {
|
||||
addTunnel(xOffs, zOffs, blocks, xCave, yCave, zCave,
|
||||
random->nextFloat() * 0.5f + 0.5f, yRot - std::numbers::pi / 2,
|
||||
xRot / 3, step, dist, 1.0);
|
||||
random->nextFloat() * 0.5f + 0.5f,
|
||||
yRot - std::numbers::pi / 2, xRot / 3, step, dist, 1.0);
|
||||
addTunnel(xOffs, zOffs, blocks, xCave, yCave, zCave,
|
||||
random->nextFloat() * 0.5f + 0.5f, yRot + std::numbers::pi / 2,
|
||||
xRot / 3, step, dist, 1.0);
|
||||
random->nextFloat() * 0.5f + 0.5f,
|
||||
yRot + std::numbers::pi / 2, xRot / 3, step, dist, 1.0);
|
||||
return;
|
||||
}
|
||||
if (!singleStep && random->nextInt(4) == 0) continue;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user