Ritual of Speed bugfix and cleanup (#70)

Co-authored-by: Maya <[email protected]>
This commit is contained in:
koolkrafter5andMaya authored and GitHub committed 2025-04-09 04:42:00 +00:00
1 parent a1f62e0db6
commit 8762c24331
1 file changed
+92 -132
@@ -18,10 +18,15 @@ import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class RitualEffectLeap extends RitualEffect {
// Throws mobs with twice the horizontal speed
public static final int aetherDrain = 10;
// Throws mobs with half the vertical speed
public static final int terraeDrain = 10;
// Grants 3 seconds of fall immunity
public static final int reductusDrain = 10;
// Only throws adults (and non-sneaking players)
public static final int tenebraeDrain = 10;
// Only throws babies (and non-sneaking players)
public static final int sanctusDrain = 10;
@Override
@@ -39,152 +44,107 @@ public class RitualEffectLeap extends RitualEffect {
List<EntityLivingBase> livingList = SpellHelper
.getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range);
if (livingList == null) {
if (livingList == null || livingList.isEmpty()) {
return;
}
if (currentEssence < this.getCostPerRefresh() * livingList.size()) {
SoulNetworkHandler.causeNauseaToPlayer(owner);
} else {
boolean hasAether = this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false);
boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false);
boolean hasReductus = this
.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
boolean hasTenebrae = this
.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, false);
boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
return;
}
int direction = ritualStone.getDirection();
boolean hasAether = true;
boolean hasTerrae = true;
boolean hasReductus = true;
boolean hasTenebrae = true;
boolean hasSanctus = true;
int flag = 0;
int direction = ritualStone.getDirection();
for (EntityLivingBase livingEntity : livingList) {
if (livingEntity.isSneaking()) {
continue;
int count = 0;
for (EntityLivingBase livingEntity : livingList) {
if (livingEntity.isSneaking()) {
continue;
}
hasReductus = hasReductus
&& this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
hasTenebrae = hasTenebrae
&& this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, false);
hasSanctus = hasSanctus
&& this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
// Sanctus only makes it work on children and tenebrae only with adults.
// Both being present prevents the ritual from working for any NPCs.
if (((hasSanctus && !livingEntity.isChild()) || (hasTenebrae && livingEntity.isChild()))
&& !(livingEntity instanceof EntityPlayer)) {
continue;
}
hasAether = hasAether
&& this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true);
hasTerrae = hasTerrae
&& this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true);
double motionY = hasTerrae ? 0.6 : 1.2;
double speed = hasAether ? 6.0 : 3.0;
livingEntity.motionY = motionY;
livingEntity.fallDistance = 0;
count++;
if (livingEntity instanceof EntityPlayer) {
switch (direction) {
case 1:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, -speed);
break;
case 2:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, speed, motionY, 0);
break;
case 3:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, speed);
break;
case 4:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, -speed, motionY, 0);
break;
}
} else {
switch (direction) {
case 1:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 2:
livingEntity.motionX = speed;
livingEntity.motionZ = 0.0;
break;
case 3:
livingEntity.motionX = 0.0;
livingEntity.motionZ = speed;
break;
case 4:
livingEntity.motionX = -speed;
livingEntity.motionZ = 0.0;
break;
}
hasAether = hasAether
&& this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false);
hasTerrae = hasTerrae
&& this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false);
hasReductus = hasReductus
&& this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
hasTenebrae = hasTenebrae
&& this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, false);
hasSanctus = hasSanctus
&& this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
double motionY = hasTerrae ? 0.6 : 1.2;
double speed = hasAether ? 6.0 : 3.0;
if (!(hasTenebrae || hasSanctus) || livingEntity instanceof EntityPlayer) {
livingEntity.motionY = motionY;
livingEntity.fallDistance = 0;
if (livingEntity instanceof EntityPlayer) {
switch (direction) {
case 1:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, -speed);
break;
case 2:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, speed, motionY, 0);
break;
case 3:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, speed);
break;
case 4:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, -speed, motionY, 0);
break;
}
} else {
livingEntity.motionY = motionY;
switch (direction) {
case 1:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 2:
livingEntity.motionX = speed;
livingEntity.motionZ = 0.0;
break;
case 3:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 4:
livingEntity.motionX = -speed;
livingEntity.motionZ = 0.0;
break;
}
}
flag++;
} else {
if ((hasSanctus && !livingEntity.isChild()) || (hasTenebrae && livingEntity.isChild())) {
continue;
}
livingEntity.motionY = motionY;
switch (direction) {
case 1:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 2:
livingEntity.motionX = speed;
livingEntity.motionZ = 0.0;
break;
case 3:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 4:
livingEntity.motionX = -speed;
livingEntity.motionZ = 0.0;
break;
}
if (hasTenebrae) {
this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, true);
}
if (hasSanctus) {
this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true);
}
livingEntity.fallDistance = 0;
flag++;
}
if (hasAether) {
this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true);
}
if (hasTerrae) {
this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true);
}
if (hasReductus) {
if (!livingEntity.isPotionActive(AlchemicalWizardry.customPotionFeatherFall)) {
livingEntity.addPotionEffect(
new PotionEffect(AlchemicalWizardry.customPotionFeatherFall.id, 3 * 20, 0));
this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true);
}
if (hasTenebrae) {
this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, true);
} else if (hasSanctus) {
this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true);
}
}
if (flag > 0) {
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * flag);
if (hasReductus && !livingEntity.isPotionActive(AlchemicalWizardry.customPotionFeatherFall)) {
livingEntity
.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionFeatherFall.id, 3 * 20, 0));
this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true);
}
}
if (count > 0) {
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * count);
}
}
@Override
@@ -194,7 +154,7 @@ public class RitualEffectLeap extends RitualEffect {
@Override
public List<RitualComponent> getRitualComponentList() {
ArrayList<RitualComponent> leapingRitual = new ArrayList();
ArrayList<RitualComponent> leapingRitual = new ArrayList<>();
leapingRitual.add(new RitualComponent(0, 0, -2, RitualComponent.DUSK));
leapingRitual.add(new RitualComponent(1, 0, -1, RitualComponent.AIR));
leapingRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.AIR));