Skip to content

Commit

Permalink
bug fixing for projectile shape
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jan 1, 2024
1 parent a9d8b1e commit f9661ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public class ArcanusConfig extends MidnightConfig {

@Entry public static SpellShapeProperties selfShapeProperties = new SpellShapeProperties(true, Weight.VERY_LIGHT, 0, 0.85, 10, 1, 0);
@Entry public static SpellShapeProperties touchShapeProperties = new SpellShapeProperties(true, Weight.VERY_LIGHT, 0, 1, 15, 1, 0.2);
@Entry public static SpellShapeProperties projectileShapeProperties = new SpellShapeProperties(true, Weight.LIGHT, 0, 1, 10, 3, -0.5) {
@Entry public static SpellShapeProperties projectileShapeProperties = new SpellShapeProperties(true, Weight.LIGHT, 0, 1, 10, 3, -0.75) {
@Entry public float projectileSpeed = 4f;
@Entry public int lifeSpan = 20;
};
@Entry public static SpellShapeProperties lobShapeProperties = new SpellShapeProperties(true, Weight.LIGHT, 0, 1, 20, 3, 0) {
@Entry public float projectileSpeed = 2f;
};
@Entry public static SpellShapeProperties boltShapeProperties = new SpellShapeProperties(true, Weight.MEDIUM, 0, 1, 20, 5, 0) {
@Entry public static SpellShapeProperties boltShapeProperties = new SpellShapeProperties(true, Weight.MEDIUM, 0, 1, 15, 5, 0) {
@Entry public double range = 8;
};
@Entry public static SpellShapeProperties beamShapeProperties = new SpellShapeProperties(true, Weight.MEDIUM, 0, 1.25, 30, 5, 0.25) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dev.tr7zw.firstperson.api.FirstPersonAPI;

public class FirstPersonCompat {

public static void init() {
ArcanusClient.FIRST_PERSON_MODEL_ENABLED = FirstPersonAPI::isEnabled;
ArcanusClient.FIRST_PERSON_SHOW_HANDS = FirstPersonModelCore.instance::showVanillaHands;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
import dev.cammiescorner.arcanuscontinuum.common.entities.magic.MagicProjectileEntity;
import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusEntities;
import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusSpellComponents;
import dev.cammiescorner.arcanuscontinuum.common.util.ArcanusHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.TypeFilter;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.Nullable;

import java.util.HashSet;
import java.util.List;

public class ProjectileSpellShape extends SpellShape {
Expand All @@ -30,19 +36,30 @@ public void cast(@Nullable LivingEntity caster, Vec3d castFrom, @Nullable Entity

if(caster != null) {
List<? extends MagicProjectileEntity> list = world.getEntitiesByType(TypeFilter.instanceOf(MagicProjectileEntity.class), entity -> caster.equals(entity.getOwner()));
Entity sourceEntity = castSource != null ? castSource : caster;
HitResult target = ArcanusHelper.raycast(sourceEntity, 4.5, true, true);

for(int i = 0; i < list.size() - 20; i++)
list.get(i).kill();

MagicProjectileEntity projectile = ArcanusEntities.MAGIC_PROJECTILE.get().create(world);
if(ArcanusSpellComponents.PROJECTILE.is(this) && target instanceof EntityHitResult hitResult) {
for(SpellEffect effect : new HashSet<>(effects))
effect.effect(caster, sourceEntity, world, target, effects, stack, potency);

if(projectile != null) {
projectile.setProperties(caster, castSource, this, stack, effects, spellGroups, groupIndex, potency, ArcanusSpellComponents.LOB.is(this) ? 2F : 4F, !ArcanusSpellComponents.LOB.is(this), Arcanus.DEFAULT_MAGIC_COLOUR);
SpellShape.castNext(caster, target.getPos(), hitResult.getEntity(), world, stack, spellGroups, groupIndex, potency);
world.playSound(hitResult.getEntity(), hitResult.getEntity().getBlockPos(), SoundEvents.ENTITY_ARROW_HIT, SoundCategory.NEUTRAL, 1F, 1.2F / (world.random.nextFloat() * 0.2F + 0.9F));
}
else {
MagicProjectileEntity projectile = ArcanusEntities.MAGIC_PROJECTILE.get().create(world);

if(projectile != null) {
projectile.setProperties(caster, castSource, this, stack, effects, spellGroups, groupIndex, potency, ArcanusSpellComponents.LOB.is(this) ? 2F : 4F, !ArcanusSpellComponents.LOB.is(this), Arcanus.DEFAULT_MAGIC_COLOUR);

if(caster instanceof PlayerEntity player)
projectile.setColour(Arcanus.getMagicColour(player.getGameProfile().getId()));
if(caster instanceof PlayerEntity player)
projectile.setColour(Arcanus.getMagicColour(player.getGameProfile().getId()));

world.spawnEntity(projectile);
world.spawnEntity(projectile);
}
}
}
}
Expand Down

0 comments on commit f9661ec

Please sign in to comment.