Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,22 @@ public static BlockPos getRandomPos(ServerLevel sl, EntityType<?> type, LivingEn
@SerialClass.SerialField(toClient = true)
public ArrayList<Minion> data = new ArrayList<>();

private record MinionKey(EntityType<?> type, double masterMaxHealthPercentage) {}

@SerialClass.SerialField
private LinkedHashMap<EntityType<?>, Data> map = new LinkedHashMap<>();
private LinkedHashMap<MinionKey, Data> map = new LinkedHashMap<>();

public boolean tick(MobTraitCap cap, Mob mob) {
var config = MasterTrait.getConfig(mob.getType());
if (config == null) return false;
for (var e : config.minions())
map.computeIfAbsent(e.type(), k -> new Data()).setup(e);
map.computeIfAbsent(new MinionKey(e.type(), e.maxHealthPercentage()), k -> new Data()).setup(e);
boolean updated = data.removeIf(e -> {
e.tick(mob);
if (e.minion == null) {
return !mob.level().isClientSide();
} else {
var ent = map.get(e.minion.getType());
var ent = map.get(new MinionKey(e.minion.getType(), e.masterMaxHealthPercentage));
if (ent != null) ent.count++;
return false;
}
Expand Down Expand Up @@ -112,6 +114,9 @@ public static class Minion {
@SerialClass.SerialField(toClient = true)
public int id;

@SerialClass.SerialField
public double masterMaxHealthPercentage;

public Mob minion;

public void tick(Mob mob) {
Expand Down Expand Up @@ -187,6 +192,7 @@ public Minion spawn(MobTraitCap parent, ServerLevel sl, Mob mob) {
ans.minion = m;
ans.uuid = m.getUUID();
ans.id = m.getId();
ans.masterMaxHealthPercentage = config.maxHealthPercentage();
return ans;
}

Expand Down