Files
MinecraftConsoles/Minecraft.World/CombatEntry.cpp
Loki Rautio 087b7e7abf Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.

This reverts commit a9be52c41a.
2026-03-07 21:12:22 -06:00

71 lines
1.4 KiB
C++

#include "stdafx.h"
#include "net.minecraft.world.damagesource.h"
#include "net.minecraft.world.entity.h"
#include "BasicTypeContainers.h"
#include "CombatEntry.h"
CombatEntry::CombatEntry(DamageSource *source, int time, float health, float damage, CombatTracker::eLOCATION location, float fallDistance)
{
this->source = NULL;
if(source != NULL)
{
// 4J: this might actually be a derived damage source so use copy func
this->source = source->copy();
}
this->time = time;
this->damage = damage;
this->health = health;
this->location = location;
this->fallDistance = fallDistance;
}
CombatEntry::~CombatEntry()
{
delete source;
}
DamageSource *CombatEntry::getSource()
{
return source;
}
int CombatEntry::getTime()
{
return time;
}
float CombatEntry::getDamage()
{
return damage;
}
float CombatEntry::getHealthBeforeDamage()
{
return health;
}
float CombatEntry::getHealthAfterDamage()
{
return health - damage;
}
bool CombatEntry::isCombatRelated()
{
return source->getEntity() && source->getEntity()->instanceof(eTYPE_LIVINGENTITY);
}
CombatTracker::eLOCATION CombatEntry::getLocation()
{
return location;
}
wstring CombatEntry::getAttackerName()
{
return getSource()->getEntity() == NULL ? L"" : getSource()->getEntity()->getNetworkName();
}
float CombatEntry::getFallDistance()
{
if (source == DamageSource::outOfWorld) return Float::MAX_VALUE;
return fallDistance;
}