Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay/leap fix #1275

Closed
wants to merge 13 commits into from
Closed
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ dependencies {
runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-common:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")

implementation fg.deobf("curse.maven:curios-309927:4583413")
implementation fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")

implementation fg.deobf("curse.maven:terrablender-563928:4590487")

Expand All @@ -191,7 +191,7 @@ dependencies {
implementation fg.deobf("curse.maven:aphoattr-898963:4688147")
// runtimeOnly fg.deobf("curse.maven:byg-247560:4027228") // BYG
// runtimeOnly fg.deobf("curse.maven:bop-220318:4034263") // BOP
// compileOnly fg.deobf("curse.maven:ars_elemental-561470:4345275") // ars elemental
implementation fg.deobf("curse.maven:ars_elemental-561470:5255908") // ars elemental
// runtimeOnly fg.deobf("curse.maven:tmg-560595:4001247") // toomanyglyphs

// implementation fg.deobf("curse.maven:cyanide-541676:3832812") // Cyanide
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false
mc_version=1.20.1
jei_version=15.0.0.12
curios_version=5.1.1.0
curios_version=5.7.0+1.20.1
gecko_version=4.4.4
mixin_extras_version=0.2.0-beta.8
mixin_extras_version=0.2.2
forge_version=47.1.64
patchouli_version=1.20.1-83-FORGE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2024-06-17T21:27:35.535636215 Languages: en_us
690a45fdce5b19e9c6788d3dc9cf53c8b81319ee assets/ars_nouveau/lang/en_us.json
// 1.20.1 2024-08-06T12:10:16.0506894 Languages: en_us
d4fb8d7f00fe69d159137d55b4654e3492960ac1 assets/ars_nouveau/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class DelayedSpellEvent implements ITimedEvent {
public final Level world;

@Deprecated(forRemoval = true)
public DelayedSpellEvent(int delay, Spell spell, HitResult result, Level world, @Nullable LivingEntity shooter, SpellContext resolver) {
this(delay, result, world, new SpellResolver(resolver));
public DelayedSpellEvent(int delay, Spell spell, HitResult result, Level world, @Nullable LivingEntity shooter, SpellContext context) {
this(delay, result, world, new SpellResolver(context));
}

public DelayedSpellEvent(int delay, HitResult result, Level world, SpellResolver resolver) {
Expand All @@ -37,7 +37,7 @@ public void tick(boolean serverSide) {
if (duration <= 0 && serverSide) {
resolveSpell();
} else if (!serverSide && result != null) {
BlockPos hitVec = result instanceof EntityHitResult ? ((EntityHitResult) result).getEntity().blockPosition() : BlockPos.containing(result.getLocation());
BlockPos hitVec = result instanceof EntityHitResult entityHitResult ? entityHitResult.getEntity().blockPosition() : BlockPos.containing(result.getLocation());
ParticleUtil.spawnTouch((ClientLevel) world, hitVec, resolver.spellContext.getColors());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class SpellContext implements Cloneable {

public SpellContext(Level level,@NotNull Spell spell, @Nullable LivingEntity caster, IWrappedCaster wrappedCaster) {
this.level = level;
this.spell = spell;
this.spell = spell.clone();
this.caster = caster;
this.colors = spell.color.clone();
this.wrappedCaster = wrappedCaster;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void sendPacket(Level world, HitResult rayTraceResult, @Nullable LivingEn
double randomize = spellStats.getBuffCount(AugmentRandomize.INSTANCE) * RANDOMIZE_CHANCE.get();
duration = world.random.nextIntBetweenInclusive((int) (duration * (1 - randomize)), (int) (duration * (1 + randomize)));
}

var delayEvent = new DelayedSpellEvent(duration, rayTraceResult, world, spellResolver);
spellContext.delay(delayEvent);

Expand All @@ -61,7 +62,7 @@ public void onResolveEntity(EntityHitResult rayTraceResult, Level world, @NotNul
@Override
public void buildConfig(ForgeConfigSpec.Builder builder) {
super.buildConfig(builder);
addExtendTimeConfig(builder, 1);
addExtendTimeTicksConfig(builder, 20);
addGenericInt(builder, 20, "The base duration of the delay effect in ticks.", "base_duration");
addRandomizeConfig(builder, 0.25f);
}
Expand All @@ -71,7 +72,7 @@ public int getDefaultManaCost() {
return 0;
}

@NotNull
@NotNull
@Override
public Set<AbstractAugment> getCompatibleAugments() {
return augmentSetOf(AugmentExtendTime.INSTANCE, AugmentDurationDown.INSTANCE, AugmentRandomize.INSTANCE);
Expand All @@ -82,12 +83,7 @@ public String getBookDescription() {
return "Delays the resolution of effects placed to the right of this spell for a few moments. The delay may be increased with the Extend Time augment, or decreased with Duration Down.";
}

@Override
public SpellTier defaultTier() {
return SpellTier.ONE;
}

@NotNull
@NotNull
@Override
public Set<SpellSchool> getSchools() {
return setOf(SpellSchools.MANIPULATION);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.hollingsworth.arsnouveau.common.spell.effect;

import com.hollingsworth.arsnouveau.api.spell.*;
import com.hollingsworth.arsnouveau.api.spell.wrapped_caster.IWrappedCaster;
import com.hollingsworth.arsnouveau.api.spell.wrapped_caster.LivingCaster;
import com.hollingsworth.arsnouveau.api.spell.wrapped_caster.TileCaster;
import com.hollingsworth.arsnouveau.api.util.SpellUtil;
import com.hollingsworth.arsnouveau.common.block.tile.BasicSpellTurretTile;
import com.hollingsworth.arsnouveau.common.block.tile.RotatingTurretTile;
import com.hollingsworth.arsnouveau.common.block.tile.RuneTile;
import com.hollingsworth.arsnouveau.common.entity.EnchantedFallingBlock;
import com.hollingsworth.arsnouveau.common.items.curios.ShapersFocus;
import com.hollingsworth.arsnouveau.common.lib.GlyphLib;
Expand All @@ -12,6 +18,7 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
Expand All @@ -21,6 +28,8 @@
import java.util.List;
import java.util.Set;

import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;

public class EffectKnockback extends AbstractEffect {
public static EffectKnockback INSTANCE = new EffectKnockback();

Expand All @@ -32,7 +41,7 @@ private EffectKnockback() {
public void onResolveEntity(EntityHitResult rayTraceResult, Level world, @NotNull LivingEntity shooter, SpellStats spellStats, SpellContext spellContext, SpellResolver resolver) {

float strength = (float) (GENERIC_DOUBLE.get() + AMP_VALUE.get() * spellStats.getAmpMultiplier());
knockback(rayTraceResult.getEntity(), shooter, strength);
knockback(rayTraceResult.getEntity(), spellContext.getCaster(), strength);
rayTraceResult.getEntity().hurtMarked = true;

}
Expand All @@ -46,14 +55,23 @@ public void onResolveBlock(BlockHitResult rayTraceResult, Level world, @NotNull
for (BlockPos p : posList) {
EnchantedFallingBlock fallingBlock = EnchantedFallingBlock.fall(world, p, shooter, spellContext, resolver, spellStats);
if (fallingBlock != null) {
knockback(fallingBlock, shooter, strength);
knockback(fallingBlock, spellContext.getCaster(), strength);
ShapersFocus.tryPropagateEntitySpell(fallingBlock, world, shooter, spellContext, resolver);
}
}
}

public void knockback(Entity target, LivingEntity shooter, float strength) {
knockback(target, strength, Mth.sin(shooter.yRot * ((float) Math.PI / 180F)), -Mth.cos(shooter.yRot * ((float) Math.PI / 180F)));
public void knockback(Entity target, @NotNull IWrappedCaster shooter, float strength) {
float v = 0;
if (shooter instanceof TileCaster tc) {
BlockEntity tile = tc.getTile();
if (tile instanceof RotatingTurretTile rotatingTurretTile) {
v = rotatingTurretTile.getRotationY();
} else if (tile instanceof BasicSpellTurretTile || tile instanceof RuneTile) {
v = tile.getBlockState().getValue(FACING).toYRot();
}
} else if (shooter instanceof LivingCaster lc) v = lc.livingEntity.yRot;
knockback(target, strength, Mth.sin(v * ((float) Math.PI / 180F)), -Mth.cos(v * ((float) Math.PI / 180F)));
}

public void knockback(Entity entity, double strength, double xRatio, double zRatio) {
Expand All @@ -79,7 +97,7 @@ public int getDefaultManaCost() {
return 15;
}

@NotNull
@NotNull
@Override
public Set<AbstractAugment> getCompatibleAugments() {
return augmentSetOf(AugmentAmplify.INSTANCE, AugmentDampen.INSTANCE, AugmentAOE.INSTANCE, AugmentPierce.INSTANCE, AugmentSensitive.INSTANCE);
Expand All @@ -90,7 +108,7 @@ public String getBookDescription() {
return "Knocks a target or block away a short distance from the caster. Sensitive will stop this spell from launching blocks.";
}

@NotNull
@NotNull
@Override
public Set<SpellSchool> getSchools() {
return setOf(SpellSchools.ELEMENTAL_AIR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.hollingsworth.arsnouveau.common.spell.effect;

import com.hollingsworth.arsnouveau.api.spell.*;
import com.hollingsworth.arsnouveau.api.spell.wrapped_caster.TileCaster;
import com.hollingsworth.arsnouveau.api.util.SpellUtil;
import com.hollingsworth.arsnouveau.common.block.tile.BasicSpellTurretTile;
import com.hollingsworth.arsnouveau.common.block.tile.RotatingTurretTile;
import com.hollingsworth.arsnouveau.common.block.tile.RuneTile;
import com.hollingsworth.arsnouveau.common.entity.EnchantedFallingBlock;
import com.hollingsworth.arsnouveau.common.items.curios.ShapersFocus;
import com.hollingsworth.arsnouveau.common.lib.GlyphLib;
Expand All @@ -13,6 +17,7 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
Expand All @@ -22,6 +27,8 @@
import java.util.List;
import java.util.Set;

import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;

public class EffectLeap extends AbstractEffect {
public static EffectLeap INSTANCE = new EffectLeap();

Expand All @@ -34,28 +41,40 @@ public void onResolveEntity(EntityHitResult rayTraceResult, Level world, @NotNul
Entity entity = rayTraceResult.getEntity();
double bonus;
Vec3 vector;
if (NERF.get() && entity == shooter && !shooter.onGround()) {
return;
}
if (NERF.get() && entity == shooter && !shooter.onGround()) return;
if (entity instanceof LivingEntity) {
vector = entity.getLookAngle();
bonus = Math.max(0, GENERIC_DOUBLE.get() + AMP_VALUE.get() * spellStats.getAmpMultiplier());
} else {
vector = shooter.getLookAngle();
vector = getLookVector(shooter, spellContext);
bonus = GENERIC_DOUBLE.get() + AMP_VALUE.get() * spellStats.getAmpMultiplier();
}
entity.setDeltaMovement(vector.x * bonus, vector.y * bonus, vector.z * bonus);
entity.fallDistance = 0.0f;
entity.hurtMarked = true;
}

public static Vec3 getLookVector(@NotNull LivingEntity shooter, SpellContext spellContext) {
Vec3 vector;
vector = shooter.getLookAngle();
if (spellContext.getCaster() instanceof TileCaster tc) {
BlockEntity tile = tc.getTile();
if (tile instanceof RotatingTurretTile rotatingTurretTile) {
vector = rotatingTurretTile.getShootAngle();
} else if (tile instanceof BasicSpellTurretTile || tile instanceof RuneTile) {
vector = new Vec3(tile.getBlockState().getValue(FACING).step());
}
}
return vector;
}

@Override
public void onResolveBlock(BlockHitResult rayTraceResult, Level world, @NotNull LivingEntity shooter, SpellStats spellStats, SpellContext spellContext, SpellResolver resolver) {
List<BlockPos> posList = SpellUtil.calcAOEBlocks(shooter, rayTraceResult.getBlockPos(), rayTraceResult, spellStats);
for (BlockPos pos1 : posList) {
EnchantedFallingBlock entity = EnchantedFallingBlock.fall(world, pos1, shooter, spellContext, resolver, spellStats);
if (entity != null) {
Vec3 vector = shooter.getLookAngle();
Vec3 vector = getLookVector(shooter, spellContext);
double bonus = GENERIC_DOUBLE.get() + AMP_VALUE.get() * spellStats.getAmpMultiplier();
entity.setDeltaMovement(vector.x * bonus, vector.y * bonus, vector.z * bonus);
entity.hurtMarked = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ConfigUtil {
* Expected format is "string=int"
* Example: "fortune=3"
*/
public static final Pattern STRING_INT_MAP = Pattern.compile("([^/=]+)=(\\p{Digit}+)");
public static final Pattern STRING_INT_MAP = Pattern.compile("(.+?)=(\\d+)");

/** Parse glyph_limits into a Map from augment glyph tags to limits. */
public static Map<String, Integer> parseMapConfig(ForgeConfigSpec.ConfigValue<List<? extends String>> configValue) {
Expand Down