feat: tu43 entity sounds, spawner fixes, and a 16x16 region toolset

This commit is contained in:
Fireblade
2026-07-23 19:47:55 -04:00
parent 1488469cb2
commit a045d994fb
135 changed files with 416 additions and 20 deletions
+5
View File
@@ -16,6 +16,7 @@
#include "ParticleTypes.h"
#include "Random.h"
#include "AABB.h"
#include "SoundTypes.h"
#include "../Minecraft.World/LevelChunk.h"
const Rotations ArmorStand::DEFAULT_HEAD_POSE (0.0f, 0.0f, 0.0f);
@@ -386,6 +387,7 @@ bool ArmorStand::hurt(DamageSource* source, float damage)
if (source->isExplosion())
{
playSound(eSoundType_ENTITY_ARMORSTAND_BREAK, 1.0f, 1.0f);
spawnAtLocation(Item::armor_stand_Id, 1);
brokenByAnything();
remove();
@@ -398,6 +400,7 @@ bool ArmorStand::hurt(DamageSource* source, float damage)
if (attacker && attacker->instanceof(eTYPE_PLAYER) &&
dynamic_pointer_cast<Player>(attacker)->abilities.instabuild)
{
playSound(eSoundType_ENTITY_ARMORSTAND_BREAK, 1.0f, 1.0f);
level->broadcastEntityEvent(shared_from_this(), (byte)31);
remove();
return true;
@@ -417,6 +420,7 @@ bool ArmorStand::hurt(DamageSource* source, float damage)
return false;
}
playSound(eSoundType_ENTITY_ARMORSTAND_HIT, 1.0f, 1.0f);
hurtDir = -hurtDir;
standDamage += damage * 10.0f;
lastHit = (long long)tickCount;
@@ -424,6 +428,7 @@ bool ArmorStand::hurt(DamageSource* source, float damage)
if (standDamage >= 40.0f)
{
playSound(eSoundType_ENTITY_ARMORSTAND_BREAK, 1.0f, 1.0f);
spawnAtLocation(Item::armor_stand_Id, 1);
brokenByAnything();
remove();
+32 -7
View File
@@ -131,6 +131,8 @@ void BaseMobSpawner::tick()
shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entity)
{
if (entity == nullptr) return nullptr;
if (getNextSpawnData() != nullptr)
{
CompoundTag *data = new CompoundTag();
@@ -155,6 +157,7 @@ shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entit
{
CompoundTag *ridingTag = data->getCompound(Entity::RIDING_TAG);
shared_ptr<Entity> mount = EntityIO::newEntity(ridingTag->getString(L"id"), entity->level);
if (mount != nullptr)
{
CompoundTag *mountData = new CompoundTag();
@@ -230,7 +233,8 @@ void BaseMobSpawner::load(CompoundTag *tag)
if (tag->contains(L"SpawnData"))
{
setNextSpawnData(new SpawnData(tag->getCompound(L"SpawnData"), entityId));
CompoundTag *spawnDataTag = tag->getCompound(L"SpawnData");
setNextSpawnData(new SpawnData(spawnDataTag, entityId));
}
else
{
@@ -250,7 +254,10 @@ void BaseMobSpawner::load(CompoundTag *tag)
requiredPlayerRange = tag->getShort(L"RequiredPlayerRange");
}
if (tag->contains(L"SpawnRange")) spawnRange = tag->getShort(L"SpawnRange");
if (tag->contains(L"SpawnRange"))
{
spawnRange = tag->getShort(L"SpawnRange");
}
if (getLevel() != nullptr && getLevel()->isClientSide)
{
@@ -328,8 +335,21 @@ void BaseMobSpawner::setNextSpawnData(SpawnData *nextSpawnData)
BaseMobSpawner::SpawnData::SpawnData(CompoundTag *base) : WeighedRandomItem(base->getInt(L"Weight"))
{
CompoundTag *tag = base->getCompound(L"Properties");
wstring _type = base->getString(L"Type");
CompoundTag *tag = nullptr;
wstring _type;
if (!base->contains(L"Entity"))
{
CompoundTag *propertiesTag = base->getCompound(L"Properties");
tag = propertiesTag != nullptr ? static_cast<CompoundTag *>(propertiesTag->copy()) : nullptr;
_type = base->getString(L"Type");
}
else
{
CompoundTag *entityTag = base->getCompound(L"Entity");
tag = entityTag != nullptr ? static_cast<CompoundTag *>(entityTag->copy()) : nullptr;
_type = entityTag != nullptr ? entityTag->getString(L"id") : L"";
}
if (_type.compare(L"Minecart") == 0)
{
@@ -360,6 +380,11 @@ BaseMobSpawner::SpawnData::SpawnData(CompoundTag *base) : WeighedRandomItem(base
BaseMobSpawner::SpawnData::SpawnData(CompoundTag *tag, wstring _type) : WeighedRandomItem(1)
{
if (_type.empty() && tag != nullptr && tag->contains(L"id"))
{
_type = tag->getString(L"id");
}
if (_type.compare(L"Minecart") == 0)
{
if (tag != nullptr)
@@ -383,7 +408,7 @@ BaseMobSpawner::SpawnData::SpawnData(CompoundTag *tag, wstring _type) : WeighedR
}
}
this->tag = tag;
this->tag = tag != nullptr ? static_cast<CompoundTag *>(tag->copy()) : nullptr;
this->type = _type;
}
@@ -396,9 +421,9 @@ CompoundTag *BaseMobSpawner::SpawnData::save()
{
CompoundTag *result = new CompoundTag();
result->putCompound(L"Properties", tag);
result->putCompound(L"Properties", tag != nullptr ? static_cast<CompoundTag *>(tag->copy()) : nullptr);
result->putString(L"Type", type);
result->putInt(L"Weight", randomWeight);
return result;
}
}
+2
View File
@@ -13,6 +13,7 @@
#include "Cow.h"
#include "../Minecraft.Client/Textures.h"
#include "MobCategory.h"
#include "SoundTypes.h"
@@ -111,6 +112,7 @@ bool Cow::mobInteract(shared_ptr<Player> player)
if (item != nullptr && item->id == Item::bucket->id && !player->abilities.instabuild)
{
player->awardStat(GenericStats::cowsMilked(),GenericStats::param_cowsMilked());
playSound(eSoundType_ENTITY_COW_MILK, 1.0f, 1.0f);
if (item->count-- == 0)
{
+1 -1
View File
@@ -303,9 +303,9 @@ public:
protected:
virtual bool repositionEntityAfterLoad();
const wstring getEncodeId();
public:
const wstring getEncodeId();
virtual void readAdditionalSaveData(CompoundTag *tag) = 0;
virtual void addAdditonalSaveData(CompoundTag *tag) = 0;
/**
+1 -1
View File
@@ -405,7 +405,7 @@ void EntityHorse::dropBags()
void EntityHorse::eatingHorse()
{
openMouth();
level->playEntitySound(shared_from_this(), eSoundType_EATING, 1.0f, 1.0f + (random->nextFloat() - random->nextFloat()) * 0.2f);
level->playEntitySound(shared_from_this(), eSoundType_ENTITY_HORSE_EAT, 1.0f, 1.0f + (random->nextFloat() - random->nextFloat()) * 0.2f);
}
/**
+6
View File
@@ -10,6 +10,7 @@
#include "Painting.h"
#include "GenericStats.h"
#include "ItemFrame.h"
#include "SoundTypes.h"
HangingEntityItem::HangingEntityItem(int id, eINSTANCEOF eClassType) : Item(id)
@@ -41,6 +42,11 @@ bool HangingEntityItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Play
{
if(level->addEntity(entity)==TRUE)
{
if (eType==eTYPE_ITEM_FRAME)
{
entity->playSound(eSoundType_ENTITY_ITEMFRAME_PLACE, 1.0f, 1.0f);
}
// 4J-JEV: Hook for durango 'BlockPlaced' event.
if (eType==eTYPE_PAINTING) player->awardStat(GenericStats::blocksPlaced(Item::painting_Id), GenericStats::param_blocksPlaced(Item::painting_Id,instance->getAuxValue(),1));
else if (eType==eTYPE_ITEM_FRAME) player->awardStat(GenericStats::blocksPlaced(Item::item_frame_Id), GenericStats::param_blocksPlaced(Item::item_frame_Id,instance->getAuxValue(),1));
+7 -2
View File
@@ -12,6 +12,7 @@
#include "ItemFrame.h"
#include "DamageSource.h"
#include "Level.h"
#include "SoundTypes.h"
@@ -174,6 +175,7 @@ bool ItemFrame::interact(shared_ptr<Player> player)
if (!level->isClientSide)//isClientSide)
{
setItem(item);
playSound(eSoundType_ENTITY_ITEMFRAME_ADD_ITEM, 1.0f, 1.0f);
if (!player->abilities.instabuild)
{
@@ -190,6 +192,7 @@ bool ItemFrame::interact(shared_ptr<Player> player)
if (!level->isClientSide)//isClientSide)
{
setRotation(getRotation() + 1);
playSound(eSoundType_ENTITY_ITEMFRAME_ROTATE_ITEM, 1.0f, 1.0f);
}
}
@@ -226,11 +229,13 @@ bool ItemFrame::hurt(DamageSource *source, float damage)
removeFramedMap(copy);
spawnAtLocation(copy, 0);
}
playSound(eSoundType_ENTITY_ITEMFRAME_REMOVE_ITEM, 1.0f, 1.0f);
setItem(nullptr);
return true;
}
playSound(eSoundType_ENTITY_ITEMFRAME_BREAK, 1.0f, 1.0f);
return HangingEntity::hurt(source, damage);
}
+13
View File
@@ -4,6 +4,7 @@
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.phys.h"
#include "LeashFenceKnotEntity.h"
#include "SoundTypes.h"
void LeashFenceKnotEntity::_init()
{
@@ -92,8 +93,13 @@ bool LeashFenceKnotEntity::interact(shared_ptr<Player> player)
}
}
}
if (!level->isClientSide && attachedMob)
{
playSound(eSoundType_ENTITY_LEASHKNOT_PLACE, 1.0f, 1.0f);
}
if (!level->isClientSide && !attachedMob)
{
playSound(eSoundType_ENTITY_LEASHKNOT_BREAK, 1.0f, 1.0f);
remove();
if (player->abilities.instabuild)
@@ -129,6 +135,13 @@ bool LeashFenceKnotEntity::survives()
return false;
}
bool LeashFenceKnotEntity::hurt(DamageSource *source, float damage)
{
if (level->isClientSide) return false;
playSound(eSoundType_ENTITY_LEASHKNOT_BREAK, 1.0f, 1.0f);
return HangingEntity::hurt(source, damage);
}
shared_ptr<LeashFenceKnotEntity> LeashFenceKnotEntity::createAndAddKnot(Level *level, int x, int y, int z)
{
shared_ptr<LeashFenceKnotEntity> knot = std::make_shared<LeashFenceKnotEntity>(level, x, y, z);
+1
View File
@@ -30,6 +30,7 @@ public:
void addAdditonalSaveData(CompoundTag *tag);
void readAdditionalSaveData(CompoundTag *tag);
bool interact(shared_ptr<Player> player);
virtual bool hurt(DamageSource *source, float damage);
virtual bool survives();
static shared_ptr<LeashFenceKnotEntity> createAndAddKnot(Level *level, int x, int y, int z);
static shared_ptr<LeashFenceKnotEntity> findKnotAt(Level *level, int x, int y, int z);
+8
View File
@@ -34,6 +34,7 @@ bool LeashItem::bindPlayerMobs(shared_ptr<Player> player, Level *level, int x, i
// look for entities that can be attached to the fence
bool foundMobs = false;
bool knotCreated = false;
double range = 7;
vector<shared_ptr<Entity> > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range));
if (mobs != nullptr)
@@ -46,12 +47,19 @@ bool LeashItem::bindPlayerMobs(shared_ptr<Player> player, Level *level, int x, i
if (activeKnot == nullptr)
{
activeKnot = LeashFenceKnotEntity::createAndAddKnot(level, x, y, z);
knotCreated = true;
}
mob->setLeashedTo(activeKnot, true);
foundMobs = true;
}
}
}
if (foundMobs && knotCreated)
{
activeKnot->playSound(eSoundType_ENTITY_LEASHKNOT_PLACE, 1.0f, 1.0f);
}
return foundMobs;
}
+10 -1
View File
@@ -8,6 +8,7 @@
#include "com.mojang.nbt.h"
#include "Painting.h"
#include "Material.h"
#include "SoundTypes.h"
@@ -101,6 +102,7 @@ void Painting::PaintingPostConstructor(int dir, int motive)
this->motive = survivableMotives->at(random->nextInt(static_cast<int>(survivableMotives->size())));
}
setDir(dir);
playSound(eSoundType_ENTITY_PAINTING_PLACE, 1.0f, 1.0f);
}
}
@@ -165,4 +167,11 @@ void Painting::dropItem(shared_ptr<Entity> causedBy)
}
spawnAtLocation(std::make_shared<ItemInstance>(Item::painting), 0.0f);
}
}
bool Painting::hurt(DamageSource *source, float damage)
{
if (level->isClientSide) return false;
playSound(eSoundType_ENTITY_PAINTING_BREAK, 1.0f, 1.0f);
return HangingEntity::hurt(source, damage);
}
+1 -1
View File
@@ -100,7 +100,7 @@ public:
//virtual void tick();
//bool survives();
//virtual bool isPickable();
//virtual bool hurt(DamageSource *source, int damage);
virtual bool hurt(DamageSource *source, float damage);
virtual void addAdditonalSaveData(CompoundTag *tag);
virtual void readAdditionalSaveData(CompoundTag *tag);
//static Motive *randomMotive();
+10
View File
@@ -83,6 +83,16 @@ void SnowMan::aiStep()
}
}
int SnowMan::getHurtSound()
{
return eSoundType_ENTITY_SNOWMAN_HURT;
}
int SnowMan::getDeathSound()
{
return eSoundType_ENTITY_SNOWMAN_DEATH;
}
int SnowMan::getDeathLoot()
{
return Item::snowball_Id;
+2
View File
@@ -20,6 +20,8 @@ public:
virtual void aiStep();
protected:
virtual int getHurtSound();
virtual int getDeathSound();
virtual int getDeathLoot();
// virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel);
+41
View File
@@ -283,6 +283,47 @@ enum eSOUND_TYPE
eSoundType_MOB_POLARBEAR_STEP,
eSoundType_MOB_POLARBEAR_WARNING,
// tu43
// witch sounds
eSoundType_ENTITY_WITCH_AMBIENT,
eSoundType_ENTITY_WITCH_HURT,
eSoundType_ENTITY_WITCH_DEATH,
eSoundType_ENTITY_WITCH_THROW,
// squid sounds
eSoundType_ENTITY_SQUID_AMBIENT,
eSoundType_ENTITY_SQUID_HURT,
eSoundType_ENTITY_SQUID_DEATH,
// snowman sounds
eSoundType_ENTITY_SNOWMAN_HURT,
eSoundType_ENTITY_SNOWMAN_DEATH,
// armor stand sounds
eSoundType_ENTITY_ARMORSTAND_BREAK,
eSoundType_ENTITY_ARMORSTAND_HIT,
// cow sounds
eSoundType_ENTITY_COW_MILK,
// horse sounds
eSoundType_ENTITY_HORSE_EAT,
// item frame sounds
eSoundType_ENTITY_ITEMFRAME_ADD_ITEM,
eSoundType_ENTITY_ITEMFRAME_BREAK,
eSoundType_ENTITY_ITEMFRAME_PLACE,
eSoundType_ENTITY_ITEMFRAME_REMOVE_ITEM,
eSoundType_ENTITY_ITEMFRAME_ROTATE_ITEM,
// leash sounds
eSoundType_ENTITY_LEASHKNOT_BREAK,
eSoundType_ENTITY_LEASHKNOT_PLACE,
// painting sounds
eSoundType_ENTITY_PAINTING_PLACE,
eSoundType_ENTITY_PAINTING_BREAK,
eSoundType_MAX
};
+4 -3
View File
@@ -9,6 +9,7 @@
#include "net.minecraft.world.entity.monster.h"
#include "SharedConstants.h"
#include "Squid.h"
#include "SoundTypes.h"
#include "../Minecraft.Client/Textures.h"
void Squid::_init()
@@ -48,17 +49,17 @@ void Squid::registerAttributes()
int Squid::getAmbientSound()
{
return -1;
return eSoundType_ENTITY_SQUID_AMBIENT;
}
int Squid::getHurtSound()
{
return -1;
return eSoundType_ENTITY_SQUID_HURT;
}
int Squid::getDeathSound()
{
return -1;
return eSoundType_ENTITY_SQUID_DEATH;
}
float Squid::getSoundVolume()
+5 -3
View File
@@ -12,6 +12,7 @@
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.phys.h"
#include "Witch.h"
#include "SoundTypes.h"
AttributeModifier *Witch::SPEED_MODIFIER_DRINKING = (new AttributeModifier(eModifierId_MOB_WITCH_DRINKSPEED, -0.25f, AttributeModifier::OPERATION_ADDITION))->setSerialize(false);
@@ -48,17 +49,17 @@ void Witch::defineSynchedData()
int Witch::getAmbientSound()
{
return eSoundType_MOB_WITCH_IDLE; //"mob.witch.idle";
return eSoundType_ENTITY_WITCH_AMBIENT;
}
int Witch::getHurtSound()
{
return eSoundType_MOB_WITCH_HURT; //"mob.witch.hurt";
return eSoundType_ENTITY_WITCH_HURT;
}
int Witch::getDeathSound()
{
return eSoundType_MOB_WITCH_DEATH; //"mob.witch.death";
return eSoundType_ENTITY_WITCH_DEATH;
}
void Witch::setUsingItem(bool isUsing)
@@ -211,6 +212,7 @@ void Witch::performRangedAttack(shared_ptr<LivingEntity> target, float power)
}
potion->shoot(xd, yd + dist * 0.2f, zd, 0.75f, 8);
playSound(eSoundType_ENTITY_WITCH_THROW, 1.0f, 1.0f);
level->addEntity(potion);
}