Skip to content

Commit

Permalink
important fixes to aoe and teleport
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jan 31, 2025
1 parent 0d46f3e commit 1a85597
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ public static final class TeleportEffectProperties {
public static int minimumLevel = 10;

@ConfigEntry(id = "procsOnce", type = EntryType.BOOLEAN, translation = "config.arcanuscontinuum.procsOnce")
public static boolean procsOnce = false;
public static boolean procsOnce = true;

@ConfigEntry(id = "baseTeleportDistance", type = EntryType.DOUBLE, translation = "config.arcanuscontinuum.baseTeleportDistance")
@DoubleRange(min = 0, max = 32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void tick() {
if(!level().isClientSide()) {
int baseLifeSpan = ArcanusConfig.SpellShapes.AOEShapeProperties.baseLifeSpan;
int timesToApplyEffects = ArcanusConfig.SpellShapes.AOEShapeProperties.timesToApplyEffects;
int timesToCastNextShape = spellGroups.get(groupIndex + 1).shape().singleCastOnly() ? 1 : ArcanusConfig.SpellShapes.AOEShapeProperties.timesToCastNextShape;
int timesToCastNextShape = timesToCastNextShape();
int actualLifeSpan = (int) (baseLifeSpan * 0.9);

if(trueAge > 0) {
Expand Down Expand Up @@ -198,4 +198,13 @@ public void setProperties(UUID casterId, Vec3 pos, ItemStack stack, List<SpellEf
this.potency = potency;
this.trueAge = random.nextInt(3);
}

private int timesToCastNextShape() {
if(spellGroups.size() <= groupIndex + 1)
return 0;
else if(spellGroups.get(groupIndex + 1).shape().singleCastOnly())
return 1;

return ArcanusConfig.SpellShapes.AOEShapeProperties.timesToCastNextShape;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,25 @@ public TeleportSpellEffect() {

@Override
public void effect(@Nullable LivingEntity caster, @Nullable Entity sourceEntity, Level level, HitResult target, List<SpellEffect> effects, ItemStack stack, double potency) {
if(caster != null && caster.position().distanceTo(target.getLocation()) <= ArcanusConfig.MovementEffects.TeleportEffectProperties.baseTeleportDistance * effects.stream().filter(ArcanusSpellComponents.TELEPORT::is).count() * potency) {
if(caster != null) {
Vec3 pos = target.getLocation();
double maxDistance = ArcanusConfig.MovementEffects.TeleportEffectProperties.baseTeleportDistance * effects.stream().filter(ArcanusSpellComponents.TELEPORT::is).count() * potency;

if(target.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockHit = (BlockHitResult) target;
pos = pos.add(blockHit.getDirection().getStepX() * 0.5, blockHit.getDirection() == Direction.DOWN ? -2 : 0, blockHit.getDirection().getStepZ() * 0.5);
pos = pos.add(blockHit.getDirection().getStepX() * 0.5, blockHit.getDirection() == Direction.DOWN ? -caster.getBbHeight() : 0, blockHit.getDirection().getStepZ() * 0.5);
}

level.broadcastEntityEvent(caster, EntityEvent.TELEPORT);
if(caster.position().distanceTo(pos) <= maxDistance) {
level.broadcastEntityEvent(caster, EntityEvent.TELEPORT);

if(caster.isPassenger())
caster.dismountTo(pos.x(), pos.y(), pos.z());
else
caster.teleportTo(pos.x(), pos.y(), pos.z());
if(caster.isPassenger())
caster.dismountTo(pos.x(), pos.y(), pos.z());
else
caster.teleportTo(pos.x(), pos.y(), pos.z());

level.broadcastEntityEvent(caster, EntityEvent.TELEPORT);
level.broadcastEntityEvent(caster, EntityEvent.TELEPORT);
}
}
}
}

0 comments on commit 1a85597

Please sign in to comment.