aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/CombatEntry.cpp
blob: 5fe2e6d3259bd1e8a11fb6a7f2d7dfd3d3a2421b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#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 = nullptr;
	if(source != nullptr)
	{
		// 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() == nullptr ? L"" : getSource()->getEntity()->getNetworkName();
}

float CombatEntry::getFallDistance()
{
	if (source == DamageSource::outOfWorld) return Float::MAX_VALUE;
	return fallDistance;
}