Skip to content

Commit

Permalink
because i wont be able to work on this for a few days
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jan 6, 2024
1 parent fbb58d9 commit 21107d3
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.cammiescorner.arcanuscontinuum.common.enchantments;

import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusTags;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ItemStack;

public class EffectTypeProficiencyEnchantment extends Enchantment {
public EffectTypeProficiencyEnchantment(Rarity weight, EquipmentSlot[] slotTypes) {
super(weight, EnchantmentTarget.TRIDENT, slotTypes);
}

@Override
public boolean isAcceptableItem(ItemStack stack) {
return stack.isIn(ArcanusTags.STAVES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public void setProperties(@Nullable LivingEntity caster, LivingEntity target, It
EntityAttributeInstance maxMana = caster.getAttributeInstance(ArcanusEntityAttributes.MAX_MANA.get());
EntityAttributeInstance manaLock = caster.getAttributeInstance(ArcanusEntityAttributes.MANA_LOCK.get());

// FIXME move over to component
if(maxMana != null && manaLock != null) {
double maximumManaLock = ArcanusConfig.SpellShapes.GuardianOrbShapeProperties.maximumManaLock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ public MagicProjectileEntity(EntityType<? extends PersistentProjectileEntity> en
public void tick() {
int lifeSpan = ArcanusConfig.SpellShapes.ProjectileShapeProperties.baseLifeSpan;

if(!getWorld().isClient() && (getOwner() == null || !getOwner().isAlive() || (ArcanusSpellComponents.PROJECTILE.is(getShape()) && age >= lifeSpan))) {
if(getWorld() instanceof ServerWorld server && (getOwner() == null || !getOwner().isAlive() || (ArcanusSpellComponents.PROJECTILE.is(getShape()) && age >= lifeSpan))) {
EntityHitResult target = new EntityHitResult(this);

for(SpellEffect effect : new HashSet<>(effects))
effect.effect((LivingEntity) getOwner(), this, getWorld(), target, effects, stack, potency);

if(getOwner() instanceof LivingEntity caster)
SpellShape.castNext(caster, target.getPos(), null, server, stack, spellGroups, groupIndex, potency);

kill();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ private ItemStack applySpells(ItemStack stack, List<Spell> spells) {

for(int i = 0; i < spells.size(); i++) {
Spell spell = spells.get(i);

if(spell.getComponentGroups().get(0).isEmpty())
continue;

list.set(i, spell.toNbt());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public NecromancySpellEffect(boolean isEnabled, SpellType type, Weight weight, d

@Override
public void effect(@Nullable LivingEntity caster, @Nullable Entity sourceEntity, World world, HitResult target, List<SpellEffect> effects, ItemStack stack, double potency) {
if(target.getType() != HitResult.Type.MISS && caster != null) {
if(caster != null) {
NecroSkeletonEntity skeleton = ArcanusEntities.NECRO_SKELETON.get().create(world);
int effectCount = (int) effects.stream().filter(ArcanusSpellComponents.NECROMANCY::is).count();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@ public TeleportSpellEffect(boolean isEnabled, SpellType type, Weight weight, dou

@Override
public void effect(@Nullable LivingEntity caster, @Nullable Entity sourceEntity, World world, HitResult target, List<SpellEffect> effects, ItemStack stack, double potency) {
if(target.getType() != HitResult.Type.MISS) {
if(caster != null && caster.getPos().distanceTo(target.getPos()) <= ArcanusConfig.MovementEffects.TeleportEffectProperties.baseTeleportDistance * effects.stream().filter(ArcanusSpellComponents.TELEPORT::is).count() * potency) {
Vec3d pos = target.getPos();
if(caster != null && caster.getPos().distanceTo(target.getPos()) <= ArcanusConfig.MovementEffects.TeleportEffectProperties.baseTeleportDistance * effects.stream().filter(ArcanusSpellComponents.TELEPORT::is).count() * potency) {
Vec3d pos = target.getPos();

if(target.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockHit = (BlockHitResult) target;
pos = pos.add(blockHit.getSide().getOffsetX() * 0.5, blockHit.getSide() == Direction.DOWN ? -2 : 0, blockHit.getSide().getOffsetZ() * 0.5);
}

caster.requestTeleportAndDismount(pos.getX(), pos.getY(), pos.getZ());
world.sendEntityStatus(caster, EntityStatuses.ADD_PORTAL_PARTICLES);
if(target.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockHit = (BlockHitResult) target;
pos = pos.add(blockHit.getSide().getOffsetX() * 0.5, blockHit.getSide() == Direction.DOWN ? -2 : 0, blockHit.getSide().getOffsetZ() * 0.5);
}

caster.requestTeleportAndDismount(pos.getX(), pos.getY(), pos.getZ());
world.sendEntityStatus(caster, EntityStatuses.ADD_PORTAL_PARTICLES);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ public void cast(@Nullable LivingEntity caster, Vec3d castFrom, @Nullable Entity
Entity sourceEntity = castSource != null ? castSource : caster;
HitResult target = ArcanusHelper.raycast(sourceEntity, range, true, true);

if(target.getType() != HitResult.Type.MISS) {
if(target.getType() != HitResult.Type.MISS)
for(SpellEffect effect : new HashSet<>(effects))
effect.effect(caster, sourceEntity, world, target, effects, stack, potency);
}

Entity targetEntity = target.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) target).getEntity() : castSource;
castNext(caster, target.getPos(), targetEntity, world, stack, spellGroups, groupIndex, potency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public static HitResult raycast(Entity origin, double maxDistance, boolean inclu
Vec3d endPos = startPos.add(rotation.multiply(maxDistance));
HitResult hitResult = origin.getWorld().raycast(new RaycastContext(startPos, endPos, RaycastContext.ShapeType.COLLIDER, includeFluids ? RaycastContext.FluidHandling.ANY : RaycastContext.FluidHandling.NONE, origin));

if(hitResult.getType() != HitResult.Type.MISS)
endPos = hitResult.getPos();

endPos = hitResult.getPos();
maxDistance *= maxDistance;
HitResult entityHitResult = ProjectileUtil.raycast(origin, startPos, endPos, origin.getBoundingBox().stretch(rotation.multiply(maxDistance)).expand(1.0D, 1D, 1D), entity -> !entity.isSpectator() && entity instanceof Targetable targetable && targetable.arcanuscontinuum$canBeTargeted(), maxDistance);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dev.cammiescorner.arcanuscontinuum.mixin.common;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentLevelEntry;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.List;

@Mixin(EnchantmentHelper.class)
public class EnchantmentHelperMixin {
@Inject(method = "getPossibleEntries", at = @At("HEAD"))
private static void arcanuscontinuum$captureStack(int power, ItemStack stack, boolean treasureAllowed, CallbackInfoReturnable<List<EnchantmentLevelEntry>> info, @Share("stack") LocalRef<ItemStack> ref) {
ref.set(stack);
}

@ModifyExpressionValue(method = "getPossibleEntries", at = @At(value = "INVOKE",
target = "Lnet/minecraft/enchantment/EnchantmentTarget;isAcceptableItem(Lnet/minecraft/item/Item;)Z"
))
private static boolean arcanuscontinuum$patchEnchantStuff(boolean original, @Local(ordinal = 0) Enchantment enchantment, @Share("stack") LocalRef<ItemStack> ref) {
return enchantment.isAcceptableItem(ref.get());
}
}
1 change: 1 addition & 0 deletions src/main/resources/arcanuscontinuum.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"common.AbstractBlockStateMixin",
"common.EnchantmentHelperMixin",
"common.EntityPartMixin",
"common.EntityViewMixin",
"common.ExplosionMixin",
Expand Down

0 comments on commit 21107d3

Please sign in to comment.