use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.
the class SoliniaZonesDynmapTimer method GetStripsX.
public static HashMap<String, List<Point>> GetStripsX(HashMap<Point, Boolean> rows) {
HashMap<String, List<Point>> strips = new HashMap<String, List<Point>>();
int minX = rows.keySet().stream().min(Comparator.comparing(v -> v.x)).get().x;
int minZ = rows.keySet().stream().min(Comparator.comparing(v -> v.y)).get().y;
int maxX = rows.keySet().stream().max(Comparator.comparing(v -> v.x)).get().x;
int maxZ = rows.keySet().stream().max(Comparator.comparing(v -> v.y)).get().y;
// System.out.println("minX: " + minX);
// System.out.println("minZ: " + minZ);
// System.out.println("maxX: " + maxX);
// System.out.println("maxZ: " + maxZ);
Tuple<String, List<Point>> newStrip = null;
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
// System.out.println("x: " + x + " z: " + z);
if (!rows.containsKey(new Point(x, z))) {
// Skip it and save last Strip
if (newStrip != null) {
strips.put(newStrip.a(), newStrip.b());
newStrip = null;
}
continue;
}
if (newStrip == null) {
newStrip = new Tuple<String, List<Point>>(x + "_" + z, new ArrayList<Point>());
}
newStrip.b().add(new Point(x, z));
}
// at end, we can write it if we havent already
if (newStrip != null) {
strips.put(newStrip.a(), newStrip.b());
newStrip = null;
}
}
return strips;
}
use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.
the class SoliniaLivingEntity method ApplySpellsBonuses.
private Tuple<Integer, Integer> ApplySpellsBonuses(int spellId, LivingEntity sourceEntity, LivingEntity targetEntity, SpellEffect effect, int sourceLevel, int ticksleft, int instrument_mod) {
int newbonus = 0;
int newbonus2 = 0;
try {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(spellId);
int effectid = effect.getSpellEffectId();
// this is remaining
int effect_value = spell.calcSpellEffectValue(effect, sourceEntity, targetEntity, sourceLevel, ticksleft, instrument_mod);
int base2 = effect.getBase2();
int max = effect.getMax();
switch(effect.getSpellEffectType()) {
case AttackSpeed:
{
if ((effect_value - 100) > 0) {
// Slowed - Don't apply haste
if (newbonus < 0)
break;
if ((effect_value - 100) > newbonus) {
newbonus = effect_value - 100;
}
} else if ((effect_value - 100) < 0) {
// Slow
int real_slow_value = (100 - effect_value) * -1;
real_slow_value -= ((real_slow_value * GetSlowMitigation() / 100));
if (real_slow_value < newbonus)
newbonus = real_slow_value;
}
break;
}
case AttackSpeed2:
{
if ((effect_value - 100) > 0) {
// Slowed - Don't apply haste2
if (newbonus < 0)
break;
if ((effect_value - 100) > newbonus) {
newbonus = effect_value - 100;
}
} else if ((effect_value - 100) < 0) {
// Slow
int real_slow_value = (100 - effect_value) * -1;
real_slow_value -= ((real_slow_value * GetSlowMitigation() / 100));
if (real_slow_value < newbonus)
newbonus = real_slow_value;
}
break;
}
case AttackSpeed3:
{
if (effect_value < 0) {
// Slow
effect_value -= ((effect_value * GetSlowMitigation() / 100));
if (effect_value < newbonus)
newbonus = effect_value;
} else if (effect_value > 0) {
// Haste V3 - Stacks and Overcaps
if (effect_value > newbonus) {
newbonus = effect_value;
}
}
break;
}
case AttackSpeed4:
{
// but have no effect on the mobs attack speed
if (getSpecialAbility(SpecialAbility.UNSLOWABLE) > 0)
break;
if (// A few spells use negative values(Descriptions all indicate it should be a slow)
effect_value < 0)
effect_value = effect_value * -1;
if (effect_value > 0 && effect_value > newbonus) {
effect_value -= ((effect_value * GetSlowMitigation() / 100));
if (effect_value > newbonus)
newbonus = effect_value;
}
break;
}
default:
// this is remaining
newbonus = spell.calcSpellEffectValue(effect, sourceEntity, targetEntity, sourceLevel, ticksleft, instrument_mod);
newbonus2 = effect.getBase2();
break;
}
} catch (CoreStateInitException e) {
}
return new Tuple<Integer, Integer>(newbonus, newbonus2);
}
use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getItemBonusesTuple.
public Tuple<Integer, Integer> getItemBonusesTuple(SpellEffectType spellEffectType, SpellResistType filterResistType) {
List<ISoliniaItem> equippedItems = this.getEquippedSoliniaItems();
int highest = 0;
int highest2 = 0;
// Check if item focus effect exists for the client.
if (equippedItems.size() > 0) {
ISoliniaItem TempItem = null;
// item focus
for (ISoliniaItem item : equippedItems) {
TempItem = item;
if (TempItem == null)
continue;
if (TempItem.getFocusEffectId() < 1) {
continue;
}
ISoliniaSpell spell = null;
try {
spell = StateManager.getInstance().getConfigurationManager().getSpell(item.getFocusEffectId());
if (spell == null)
continue;
if (!filterResistType.equals(SpellResistType.RESIST_NONE))
if (spell.isEffectInSpell(SpellEffectType.LimitResist)) {
try {
// For spells like Pet Focus where the spell type has type limits (ie fire resist = fire pet)
int resistTypeId = spell.getSpellEffectBase(SpellEffectType.LimitResist);
if (SpellUtils.getSpellResistType(resistTypeId) != filterResistType)
continue;
} catch (Exception e) {
e.printStackTrace();
}
}
if (!spell.isEffectInSpell(spellEffectType))
continue;
Tuple<Integer, Integer> spellBonuses = ApplySpellsBonuses(spell.getId(), getBukkitLivingEntity(), getBukkitLivingEntity(), spell.getSpellEffect(spellEffectType), getMentorLevel(), 0, 0);
if (spellBonuses.a() > highest) {
highest = spellBonuses.a();
highest2 = spellBonuses.b();
}
} catch (CoreStateInitException e) {
}
}
}
return new Tuple<Integer, Integer>(highest, highest2);
}
use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getSpellBonusesTuple.
// In EQEmu this gets done only once (ApplySpellsBonuses/NegateSpellBonuses), for now we should just work around it
@Override
public Tuple<Integer, Integer> getSpellBonusesTuple(SpellEffectType spellEffectType, Integer base2filter) {
int bonus = 0;
int bonus2 = 0;
for (ActiveSpellEffect effect : SpellUtils.getActiveSpellEffects(getBukkitLivingEntity(), spellEffectType)) {
Entity sentity = Bukkit.getEntity(effect.getSourceEntityUUID());
Entity tentity = Bukkit.getEntity(effect.getTargetEntityUUID());
if (sentity == null || tentity == null)
continue;
if (!(sentity instanceof LivingEntity) || !(sentity instanceof LivingEntity))
continue;
if (base2filter != null && effect.getBase2() != base2filter)
continue;
Tuple<Integer, Integer> spellBonuses = ApplySpellsBonuses(effect.getSpellId(), (LivingEntity) sentity, (LivingEntity) tentity, effect, effect.getSourceLevel(), effect.getTicksLeft(), effect.getInstrumentMod());
bonus += spellBonuses.a();
bonus2 += spellBonuses.b();
}
return new Tuple<Integer, Integer>(bonus, bonus2);
}
use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.
the class EntityManager method clearHateList.
@Override
public void clearHateList(UUID entityUuid) {
clearRampageList(entityUuid);
if (hateList.get(entityUuid) != null) {
if (hateList.get(entityUuid).size() == 0)
return;
// clear reverse hate list in advance
for (Entry<UUID, Tuple<Integer, Boolean>> entitesHateList : hateList.get(entityUuid).entrySet()) {
if (reverseHateList.get(entitesHateList.getKey()) == null)
continue;
if (reverseHateList.get(entitesHateList.getKey()).get(entityUuid) != null)
reverseHateList.get(entitesHateList.getKey()).remove(entityUuid);
}
}
hateList.put(entityUuid, new ConcurrentHashMap<UUID, Tuple<Integer, Boolean>>());
Entity entity = Bukkit.getEntity(entityUuid);
if (entity == null)
return;
if (entity instanceof Creature) {
try {
SoliniaLivingEntityAdapter.Adapt((Creature) entity).setAttackTarget(null);
} catch (CoreStateInitException e) {
}
}
}
Aggregations