From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: feat: TU19 (Dec 2014) Features & Content (#155) * try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki --- Minecraft.World/ThrownPotion.cpp | 52 ++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 13 deletions(-) (limited to 'Minecraft.World/ThrownPotion.cpp') diff --git a/Minecraft.World/ThrownPotion.cpp b/Minecraft.World/ThrownPotion.cpp index 7375d661..f99a0ecb 100644 --- a/Minecraft.World/ThrownPotion.cpp +++ b/Minecraft.World/ThrownPotion.cpp @@ -19,7 +19,7 @@ void ThrownPotion::_init() // the derived version of the function is called this->defineSynchedData(); - potionValue = 0; + potionItem = nullptr; } ThrownPotion::ThrownPotion(Level *level) : Throwable(level) @@ -27,17 +27,32 @@ ThrownPotion::ThrownPotion(Level *level) : Throwable(level) _init(); } -ThrownPotion::ThrownPotion(Level *level, shared_ptr mob, int potionValue) : Throwable(level,mob) +ThrownPotion::ThrownPotion(Level *level, shared_ptr mob, int potionValue) : Throwable(level,mob) { _init(); - this->potionValue = potionValue; + potionItem = shared_ptr( new ItemInstance(Item::potion, 1, potionValue)); +} + +ThrownPotion::ThrownPotion(Level *level, shared_ptr mob, shared_ptr potion) : Throwable(level, mob) +{ + _init(); + + potionItem = potion; } ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, int potionValue) : Throwable(level,x,y,z) { _init(); - this->potionValue = potionValue; + + potionItem = shared_ptr( new ItemInstance(Item::potion, 1, potionValue)); +} + +ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, shared_ptr potion) : Throwable(level, x, y, z) +{ + _init(); + + potionItem = potion; } float ThrownPotion::getGravity() @@ -57,24 +72,26 @@ float ThrownPotion::getThrowUpAngleOffset() void ThrownPotion::setPotionValue(int potionValue) { - this->potionValue = potionValue; + if (potionItem == NULL) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); + potionItem->setAuxValue(potionValue); } int ThrownPotion::getPotionValue() { - return potionValue; + if (potionItem == NULL) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); + return potionItem->getAuxValue(); } void ThrownPotion::onHit(HitResult *res) { if (!level->isClientSide) { - vector *mobEffects = Item::potion->getMobEffects(potionValue); + vector *mobEffects = Item::potion->getMobEffects(potionItem); if (mobEffects != NULL && !mobEffects->empty()) { AABB *aoe = bb->grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE); - vector > *entitiesOfClass = level->getEntitiesOfClass(typeid(Mob), aoe); + vector > *entitiesOfClass = level->getEntitiesOfClass(typeid(LivingEntity), aoe); if (entitiesOfClass != NULL && !entitiesOfClass->empty()) { @@ -82,7 +99,7 @@ void ThrownPotion::onHit(HitResult *res) for(AUTO_VAR(it, entitiesOfClass->begin()); it != entitiesOfClass->end(); ++it) { //shared_ptr e = *it; - shared_ptr e = dynamic_pointer_cast( *it ); + shared_ptr e = dynamic_pointer_cast( *it ); double dist = distanceToSqr(e); if (dist < SPLASH_RANGE_SQ) { @@ -99,7 +116,7 @@ void ThrownPotion::onHit(HitResult *res) int id = effect->getId(); if (MobEffect::effects[id]->isInstantenous()) { - MobEffect::effects[id]->applyInstantenousEffect(this->owner, e, effect->getAmplifier(), scale); + MobEffect::effects[id]->applyInstantenousEffect(getOwner(), e, effect->getAmplifier(), scale); } else { @@ -115,7 +132,7 @@ void ThrownPotion::onHit(HitResult *res) } delete entitiesOfClass; } - level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), potionValue); + level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), getPotionValue() ); remove(); } @@ -125,12 +142,21 @@ void ThrownPotion::readAdditionalSaveData(CompoundTag *tag) { Throwable::readAdditionalSaveData(tag); - potionValue = tag->getInt(L"potionValue"); + if (tag->contains(L"Potion")) + { + potionItem = ItemInstance::fromTag(tag->getCompound(L"Potion")); + } + else + { + setPotionValue(tag->getInt(L"potionValue")); + } + + if (potionItem == NULL) remove(); } void ThrownPotion::addAdditonalSaveData(CompoundTag *tag) { Throwable::addAdditonalSaveData(tag); - tag->putInt(L"potionValue", potionValue); + if (potionItem != NULL) tag->putCompound(L"Potion", potionItem->save(new CompoundTag())); } \ No newline at end of file -- cgit v1.2.3