the whole game

This commit is contained in:
Kolyah35
2026-03-02 22:04:18 +03:00
parent 816e9060b4
commit f0617a5d22
2069 changed files with 581500 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
#ifndef NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__HurtByTargetGoal_H__
#define NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__HurtByTargetGoal_H__
//package net.minecraft.world.entity->ai.goal.target;
#include "TargetGoal.h"
#include "../../../../phys/AABB.h"
class HurtByTargetGoal: public TargetGoal
{
typedef TargetGoal super;
public:
HurtByTargetGoal(Monster* mob, bool alertSameType)
: super(mob, 16, false),
alertSameType(alertSameType)
{
setRequiredControlFlags(TargetGoal::TargetFlag);
}
bool canUse() {
return canAttack(mob->getLastHurtByMob(), true);
}
void start() {
mob->setTarget(mob->getLastHurtByMob());
// if (alertSameType) {
// List<Entity> nearby = mob.level->getEntitiesOfClass(mob.getClass(), AABB.newTemp(mob.x, mob.y, mob.z, mob.x + 1, mob.y + 1, mob.z + 1).grow(within, 4, within));
// for (Entity* ent : nearby) {
// Mob other = (Mob) ent;
// if (this->mob == other) continue;
// if (other.getTarget() != NULL) continue;
// other.setTarget(mob.getLastHurtByMob());
// }
// }
}
private:
bool alertSameType;
};
#endif /*NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__HurtByTargetGoal_H__*/

View File

@@ -0,0 +1,42 @@
#ifndef NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__NearestAttackableTargetGoal_H__
#define NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__NearestAttackableTargetGoal_H__
//package net.minecraft.world.entity->ai.goal.target;
/* import net.minecraft.world.entity->* */
#include "TargetGoal.h"
#include "../../../player/Player.h"
class NearestAttackableTargetGoal: public TargetGoal
{
typedef TargetGoal super;
public:
NearestAttackableTargetGoal(Monster* mob, int targetType, float within, int randomInterval, bool mustSee)
: super(mob, within, mustSee),
targetType(targetType),
randomInterval(randomInterval)
{
setRequiredControlFlags(TargetGoal::TargetFlag);
}
bool canUse() {
if (randomInterval > 0 && mob->random.nextInt(randomInterval) != 0) return false;
Mob* potentialTarget = NULL;
if (targetType == 1) potentialTarget = mob->level->getNearestPlayer(mob, within); //@todo: targetType
//else potentialTarget = (Mob*) mob->level->getClosestEntityOfClass(targetType, mob->bb.grow(within, 4, within), mob);
if (!canAttack(potentialTarget, false)) return false;
target = potentialTarget;
return true;
}
void start() {
mob->setTarget(target);
}
private:
Mob* target;
int targetType;
int randomInterval;
};
#endif /*NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__NearestAttackableTargetGoal_H__*/

View File

@@ -0,0 +1,57 @@
#ifndef NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__TargetGoal_H__
#define NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__TargetGoal_H__
//package net.minecraft.world.entity->ai.goal.target;
/* import net.minecraft.world.entity->* */
#include "../Goal.h"
/* import net.minecraft.world.entity->monster.* */
#include "../../../player/Player.h"
class Monster;
class TargetGoal: public Goal
{
public:
static const int TargetFlag = 1;
TargetGoal(Monster* mob, float within, bool mustSee)
: mob(mob),
within(within),
mustSee(mustSee)
{}
bool canContinueToUse() {
Mob* target = mob->getTarget();
if (target == NULL) return false;
if (!target->isAlive()) return false;
if (mob->distanceToSqr(target) > within * within) return false;
if (mustSee && !mob->sensing->canSee(target)) return false;
return true;
}
void stop() {
mob->setTarget(NULL);
}
protected:
bool canAttack(Mob* target, bool allowInvulnerable) {
if (target == NULL) return false;
if (target == mob) return false;
if (!target->isAlive()) return false;
if (target->bb.y1 <= mob->bb.y0 || target->bb.y0 >= mob->bb.y1) return false;
//if (target instanceof Creeper || target instanceof Ghast) return false;
if (target->isPlayer()) {
if (!allowInvulnerable && ((Player*) target)->abilities.invulnerable) return false;
}
if (mustSee && !mob->sensing->canSee(target)) return false;
return true;
}
Monster* mob;
float within;
bool mustSee;
};
#endif /*NET_MINECRAFT_WORLD_ENTITY_AI_GOAL_TARGET__TargetGoal_H__*/