From beec56d3be7a909977ad8f4f872a80cc80e7828e Mon Sep 17 00:00:00 2001 From: piebot <164795032+piebotc@users.noreply.github.com> Date: Fri, 13 Mar 2026 00:56:59 +0300 Subject: [PATCH] implement la's TU22 patch file --- Minecraft.Client/HumanoidModel.cpp | 4 +++- Minecraft.Client/LivingEntityRenderer.cpp | 2 +- Minecraft.Client/Minecraft.cpp | 5 +++-- Minecraft.Client/PlayerRenderer.cpp | 14 ++++++++++++-- Minecraft.Client/PlayerRenderer.h | 2 +- Minecraft.World/Animal.cpp | 8 +++++++- Minecraft.World/Animal.h | 1 + Minecraft.World/AttributeModifier.cpp | 9 ++++++++- Minecraft.World/Biome.cpp | 1 + Minecraft.World/EatTileGoal.cpp | 10 +++++++--- Minecraft.World/Entity.cpp | 9 +++++++-- Minecraft.World/HellBiome.cpp | 1 + Minecraft.World/Item.cpp | 2 +- Minecraft.World/Item.h | 10 +++++----- Minecraft.World/Level.h | 2 +- Minecraft.World/LivingEntity.cpp | 11 +++++++++-- Minecraft.World/McRegionLevelStorage.cpp | 9 +++++++++ Minecraft.World/Pig.cpp | 5 +++++ Minecraft.World/Pig.h | 1 + Minecraft.World/ScatteredFeaturePieces.cpp | 4 ++-- Minecraft.World/Villager.cpp | 1 + Minecraft.World/Wolf.cpp | 2 +- 22 files changed, 87 insertions(+), 26 deletions(-) diff --git a/Minecraft.Client/HumanoidModel.cpp b/Minecraft.Client/HumanoidModel.cpp index c6c6b9f4..06b796f5 100644 --- a/Minecraft.Client/HumanoidModel.cpp +++ b/Minecraft.Client/HumanoidModel.cpp @@ -241,7 +241,7 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float if (riding) { - if(uiBitmaskOverrideAnim&(1<xRot += -HALF_PI * 0.4f; arm1->xRot += -HALF_PI * 0.4f; @@ -256,6 +256,8 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float arm1->xRot += -HALF_PI * 0.4f; leg0->xRot = -HALF_PI * 0.4f; leg1->xRot = -HALF_PI * 0.4f; + leg0->yRot = HALF_PI * 0.2f; + leg1->yRot = -HALF_PI * 0.2f; } } else if(idle && !sneaking ) diff --git a/Minecraft.Client/LivingEntityRenderer.cpp b/Minecraft.Client/LivingEntityRenderer.cpp index b3478ba9..5309e664 100644 --- a/Minecraft.Client/LivingEntityRenderer.cpp +++ b/Minecraft.Client/LivingEntityRenderer.cpp @@ -501,7 +501,7 @@ void LivingEntityRenderer::renderNameTag(shared_ptr mob, const wst constexpr float s = 1 / 60.0f * size; glPushMatrix(); - glTranslatef(static_cast(x) + 0, static_cast(y) + mob->bbHeight + 0.5f, static_cast(z)); + glTranslatef(static_cast(x), static_cast(y) + mob->bbHeight + 0.5f, static_cast(z)); glNormal3f(0, 1, 0); glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0); diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index aa8fa1fa..7da9fffd 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -3142,14 +3142,15 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { *piUse=IDS_TOOLTIPS_UNLEASH; } - else if (heldItemId == Item::lead_Id) + // 4J: fix improper tooltips for TU20 + /*else if (heldItemId == Item::lead_Id) { if (!pig->isLeashed()) *piUse=IDS_TOOLTIPS_LEASH; } else if (heldItemId == Item::nameTag_Id) { *piUse = IDS_TOOLTIPS_NAME; - } + }*/ else if (pig->hasSaddle()) // does the pig have a saddle? { *piUse=IDS_TOOLTIPS_MOUNT; diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index a9b94544..215b8c1f 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -470,7 +470,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) } } -void PlayerRenderer::renderNameTags(shared_ptr player, double x, double y, double z, wstring msg, float scale, double dist) +void PlayerRenderer::renderNameTags(shared_ptr player, double x, double y, double z, const wstring &msg, float scale, double dist) { #if 0 if (dist < 10 * 10) @@ -496,7 +496,17 @@ void PlayerRenderer::renderNameTags(shared_ptr player, double x, d } #endif - LivingEntityRenderer::renderNameTags(player, x, y, z, msg, scale, dist); + shared_ptr pPlayer = dynamic_pointer_cast(player); + int color = getNametagColour(pPlayer->getPlayerIndex()); + + if (player->isSleeping()) + { + renderNameTag(player, msg, x, y - 1.5f, z, 64, color); + } + else + { + renderNameTag(player, msg, x, y, z, 64, color); + } } void PlayerRenderer::scale(shared_ptr player, float a) diff --git a/Minecraft.Client/PlayerRenderer.h b/Minecraft.Client/PlayerRenderer.h index 494ff795..775bac5d 100644 --- a/Minecraft.Client/PlayerRenderer.h +++ b/Minecraft.Client/PlayerRenderer.h @@ -34,7 +34,7 @@ public: protected: virtual void additionalRendering(shared_ptr _mob, float a); - void renderNameTags(shared_ptr player, double x, double y, double z, wstring msg, float scale, double dist); + void renderNameTags(shared_ptr player, double x, double y, double z, const wstring &msg, float scale, double dist); virtual void scale(shared_ptr _player, float a); public: diff --git a/Minecraft.World/Animal.cpp b/Minecraft.World/Animal.cpp index 68278162..d789aa5d 100644 --- a/Minecraft.World/Animal.cpp +++ b/Minecraft.World/Animal.cpp @@ -221,6 +221,12 @@ void Animal::readAdditionalSaveData(CompoundTag *tag) setDespawnProtected(); } +void Animal::dropLeash(bool synch, bool createItemDrop) +{ + setDespawnProtected(); + Mob::dropLeash(synch, createItemDrop); +} + shared_ptr Animal::findAttackTarget() { if (fleeTime > 0) return nullptr; @@ -301,7 +307,7 @@ int Animal::getAmbientSoundInterval() bool Animal::removeWhenFarAway() { - return !isDespawnProtected(); // 4J changed - was false + return !hasCustomName() && !isLeashed() && !isDespawnProtected(); } int Animal::getExperienceReward(shared_ptr killedBy) diff --git a/Minecraft.World/Animal.h b/Minecraft.World/Animal.h index 85a20439..100f974e 100644 --- a/Minecraft.World/Animal.h +++ b/Minecraft.World/Animal.h @@ -38,6 +38,7 @@ public: virtual bool hurt(DamageSource *source, float dmg); virtual void addAdditonalSaveData(CompoundTag *tag); virtual void readAdditionalSaveData(CompoundTag *tag); + virtual void dropLeash(bool synch, bool createItemDrop); protected: virtual shared_ptr findAttackTarget(); diff --git a/Minecraft.World/AttributeModifier.cpp b/Minecraft.World/AttributeModifier.cpp index 17090289..942170d6 100644 --- a/Minecraft.World/AttributeModifier.cpp +++ b/Minecraft.World/AttributeModifier.cpp @@ -123,7 +123,14 @@ HtmlString AttributeModifier::getHoverText(eATTRIBUTE_ID attribute) } wchar_t formatted[256]; - swprintf(formatted, 256, L"%ls%d%ls %ls", (amount > 0 ? L"+" : L"-"), static_cast(displayAmount), (percentage ? L"%" : L""), app.GetString(Attribute::getName(attribute))); + if (percentage) + { + swprintf(formatted, 256, L"%ls%d%ls %ls", (amount > 0 ? L"+" : L"-"), (int)displayAmount, L"%", app.GetString(Attribute::getName(attribute))); + } + else + { + swprintf(formatted, 256, L"%ls%.1g %ls", (amount > 0 ? L"+" : L"-"), displayAmount, app.GetString(Attribute::getName(attribute))); + } return HtmlString(formatted, color); } \ No newline at end of file diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index 66265765..9e3bc4c5 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -122,6 +122,7 @@ Biome::Biome(int id) : id(id) enemies.push_back(new MobSpawnerData(eTYPE_CREEPER, 10, 4, 4)); enemies.push_back(new MobSpawnerData(eTYPE_SLIME, 10, 4, 4)); enemies.push_back(new MobSpawnerData(eTYPE_ENDERMAN, 1, 1, 4)); + enemies.push_back(new MobSpawnerData(eTYPE_WITCH, 1, 1, 1)); // wolves are added to forests and taigas diff --git a/Minecraft.World/EatTileGoal.cpp b/Minecraft.World/EatTileGoal.cpp index c2cbd6bf..28ca95ed 100644 --- a/Minecraft.World/EatTileGoal.cpp +++ b/Minecraft.World/EatTileGoal.cpp @@ -60,13 +60,17 @@ void EatTileGoal::tick() if (level->getTile(xx, yy, zz) == Tile::tallgrass_Id) { - level->destroyTile(xx, yy, zz, false); + if (level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)) + level->destroyTile(xx, yy, zz, false); mob->ate(); } else if (level->getTile(xx, yy - 1, zz) == Tile::grass_Id) { - level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, xx, yy - 1, zz, Tile::grass_Id); - level->setTileAndData(xx, yy - 1, zz, Tile::dirt_Id, 0, Tile::UPDATE_CLIENTS); + if (level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)) + { + level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, xx, yy - 1, zz, Tile::grass_Id); + level->setTileAndData(xx, yy - 1, zz, Tile::dirt_Id, 0, Tile::UPDATE_CLIENTS); + } mob->ate(); } } \ No newline at end of file diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index d754330b..3a2a5645 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -1598,8 +1598,13 @@ void Entity::rideTick() // jeb: This caused the crosshair to "drift" while riding horses. For now I've just disabled it, // because I can't figure out what it's needed for. Riding boats and minecarts seem unaffected... - // yRot += yra; - // xRot += xra; + // + // 3UR: re-enabled this for TU20 but only for rideable minecarts + if (riding->instanceof(eTYPE_MINECART_RIDEABLE)) + { + yRot += yra; + xRot += xra; + } } void Entity::positionRider() diff --git a/Minecraft.World/HellBiome.cpp b/Minecraft.World/HellBiome.cpp index d023c01d..865b21d7 100644 --- a/Minecraft.World/HellBiome.cpp +++ b/Minecraft.World/HellBiome.cpp @@ -14,4 +14,5 @@ HellBiome::HellBiome(int id) : Biome(id) enemies.push_back(new MobSpawnerData(eTYPE_GHAST, 50, 4, 4)); enemies.push_back(new MobSpawnerData(eTYPE_PIGZOMBIE, 100, 4, 4)); enemies.push_back(new MobSpawnerData(eTYPE_LAVASLIME, 1, 4, 4)); + enemies.push_back(new MobSpawnerData(eTYPE_SKELETON, 1, 4, 4)); } \ No newline at end of file diff --git a/Minecraft.World/Item.cpp b/Minecraft.World/Item.cpp index 19baf20d..49ff63d8 100644 --- a/Minecraft.World/Item.cpp +++ b/Minecraft.World/Item.cpp @@ -1138,11 +1138,11 @@ const int Item::record_04_Id ; const int Item::record_05_Id ; const int Item::record_06_Id ; const int Item::record_07_Id ; +const int Item::record_08_Id ; const int Item::record_09_Id ; const int Item::record_10_Id ; const int Item::record_11_Id ; const int Item::record_12_Id ; -const int Item::record_08_Id ; const int Item::fireball_Id ; const int Item::itemFrame_Id ; const int Item::netherbrick_Id ; diff --git a/Minecraft.World/Item.h b/Minecraft.World/Item.h index 3a5b5be3..4990bab6 100644 --- a/Minecraft.World/Item.h +++ b/Minecraft.World/Item.h @@ -577,13 +577,13 @@ public: static const int record_05_Id = 2260; static const int record_06_Id = 2261; static const int record_07_Id = 2262; - static const int record_09_Id = 2263; - static const int record_10_Id = 2264; - static const int record_11_Id = 2265; - static const int record_12_Id = 2266; // 4J-PB - this one isn't playable in the PC game, but is fine in ours - static const int record_08_Id = 2267; + static const int record_08_Id = 2263; + static const int record_09_Id = 2264; + static const int record_10_Id = 2265; + static const int record_11_Id = 2266; + static const int record_12_Id = 2267; // TU9 static const int fireball_Id = 385; diff --git a/Minecraft.World/Level.h b/Minecraft.World/Level.h index eb750aff..ecf300a8 100644 --- a/Minecraft.World/Level.h +++ b/Minecraft.World/Level.h @@ -59,7 +59,7 @@ public: public: static const int MAX_XBOX_BOATS = 40; // Max number of boats - static const int MAX_CONSOLE_MINECARTS = 40; + static const int MAX_CONSOLE_MINECARTS = 250; static const int MAX_DISPENSABLE_FIREBALLS = 200; static const int MAX_DISPENSABLE_PROJECTILES = 300; diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index 3ace8806..42d3a229 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -259,9 +259,16 @@ void LivingEntity::baseTick() } // If lastHurtByMob is dead, remove it - if (lastHurtByMob != nullptr && !lastHurtByMob->isAlive()) + if (lastHurtByMob != NULL) { - setLastHurtByMob(nullptr); + if (!lastHurtByMob->isAlive()) + { + setLastHurtByMob(nullptr); + } + else if (tickCount - lastHurtByMobTimestamp > 100) + { + setLastHurtByMob(nullptr); + } } // Update effects diff --git a/Minecraft.World/McRegionLevelStorage.cpp b/Minecraft.World/McRegionLevelStorage.cpp index ec472fad..7588d51b 100644 --- a/Minecraft.World/McRegionLevelStorage.cpp +++ b/Minecraft.World/McRegionLevelStorage.cpp @@ -51,6 +51,15 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension) delete netherFiles; } #endif + vector *fortressFiles = m_saveFile->getFilesWithPrefix(L"data/Fortress"); + if(fortressFiles!=NULL) + { + for (auto& fortressFile : *fortressFiles) + { + m_saveFile->deleteFile(fortressFile); + } + delete fortressFiles; + } resetNetherPlayerPositions(); } diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp index a99af826..b8c87dcb 100644 --- a/Minecraft.World/Pig.cpp +++ b/Minecraft.World/Pig.cpp @@ -47,6 +47,11 @@ bool Pig::useNewAi() return true; } +bool Pig::removeWhenFarAway() +{ + return Animal::removeWhenFarAway() && !hasSaddle(); +} + void Pig::registerAttributes() { Animal::registerAttributes(); diff --git a/Minecraft.World/Pig.h b/Minecraft.World/Pig.h index 9b7183da..0dfbf38c 100644 --- a/Minecraft.World/Pig.h +++ b/Minecraft.World/Pig.h @@ -23,6 +23,7 @@ public: virtual bool useNewAi(); protected: + virtual bool removeWhenFarAway(); virtual void registerAttributes(); virtual void newServerAiStep(); diff --git a/Minecraft.World/ScatteredFeaturePieces.cpp b/Minecraft.World/ScatteredFeaturePieces.cpp index 07630ef7..fbe342f6 100644 --- a/Minecraft.World/ScatteredFeaturePieces.cpp +++ b/Minecraft.World/ScatteredFeaturePieces.cpp @@ -12,8 +12,8 @@ void ScatteredFeaturePieces::loadStatic() { StructureFeatureIO::setPieceId(eStructurePiece_DesertPyramidPiece, DesertPyramidPiece::Create, L"TeDP"); - StructureFeatureIO::setPieceId(eStructurePiece_JunglePyramidPiece, DesertPyramidPiece::Create, L"TeJP"); - StructureFeatureIO::setPieceId(eStructurePiece_SwamplandHut, DesertPyramidPiece::Create, L"TeSH"); + StructureFeatureIO::setPieceId(eStructurePiece_JunglePyramidPiece, JunglePyramidPiece::Create, L"TeJP"); + StructureFeatureIO::setPieceId(eStructurePiece_SwamplandHut, SwamplandHut::Create, L"TeSH"); } ScatteredFeaturePieces::ScatteredFeaturePiece::ScatteredFeaturePiece() diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp index 4e57affe..0a4e6424 100644 --- a/Minecraft.World/Villager.cpp +++ b/Minecraft.World/Villager.cpp @@ -472,6 +472,7 @@ void Villager::addOffers(int addCount) addItemForPurchase(newOffers, Tile::glass_Id, random, getRecipeChance(.2f)); addItemForPurchase(newOffers, Item::compass_Id, random, getRecipeChance(.2f)); addItemForPurchase(newOffers, Item::clock_Id, random, getRecipeChance(.2f)); + addItemForPurchase(newOffers, Item::nameTag_Id, random, getRecipeChance(.2f)); if (random->nextFloat() < getRecipeChance(0.07f)) { diff --git a/Minecraft.World/Wolf.cpp b/Minecraft.World/Wolf.cpp index 7588a67b..5545138a 100644 --- a/Minecraft.World/Wolf.cpp +++ b/Minecraft.World/Wolf.cpp @@ -509,7 +509,7 @@ void Wolf::setCollarColor(int color) // 4J-PB added for tooltips int Wolf::GetSynchedHealth() { - return getEntityData()->getInteger(DATA_HEALTH_ID); + return getEntityData()->getFloat(DATA_HEALTH_ID); } shared_ptr Wolf::getBreedOffspring(shared_ptr target)