From 4c821a521cd91c86630defd120f1fd92548ad878 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 25 Jan 2024 22:57:23 +0000 Subject: [PATCH] Change cast spells to be easier to reach and change the center to be the center of the entity not its base position --- .../minelittlepony/unicopia/EntityConvertable.java | 2 +- .../ability/magic/spell/effect/PortalSpell.java | 2 +- .../client/render/spell/PlacedSpellRenderer.java | 10 +++++++--- .../unicopia/entity/mob/CastSpellEntity.java | 13 +++++++++++-- .../unicopia/entity/mob/UEntities.java | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/EntityConvertable.java b/src/main/java/com/minelittlepony/unicopia/EntityConvertable.java index d21ac152..6a0ffce7 100644 --- a/src/main/java/com/minelittlepony/unicopia/EntityConvertable.java +++ b/src/main/java/com/minelittlepony/unicopia/EntityConvertable.java @@ -25,7 +25,7 @@ public interface EntityConvertable extends WorldConvertable { * Gets the center position where this caster is located. */ default Vec3d getOriginVector() { - return asEntity().getPos(); + return asEntity().getPos().add(0, asEntity().getHeight() * 0.5F, 0); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java index dfdd204f..c067300c 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java @@ -216,7 +216,7 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme LivingEntity caster = source.getMaster(); Vec3d targetPos = caster.getRotationVector().multiply(3).add(caster.getEyePos()); parent.setOrientation(pitch, yaw); - entity.setPos(targetPos.x, caster.getEyePos().y, targetPos.z); + entity.setPos(targetPos.x, caster.getEyePos().y - (entity.getHeight() * 0.5F), targetPos.z); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/spell/PlacedSpellRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/spell/PlacedSpellRenderer.java index 7c4d09c3..fbdfce47 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/spell/PlacedSpellRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/spell/PlacedSpellRenderer.java @@ -27,8 +27,6 @@ public class PlacedSpellRenderer extends SpellRenderer { @Override public void render(MatrixStack matrices, VertexConsumerProvider vertices, PlaceableSpell spell, Caster caster, int light, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { - - if (!(caster.asEntity() instanceof CastSpellEntity castSpell)) { return; } @@ -36,13 +34,16 @@ public class PlacedSpellRenderer extends SpellRenderer { matrices.push(); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-castSpell.getYaw())); + for (Spell delegate : spell.getDelegates()) { renderAmbientEffects(matrices, vertices, spell, delegate, caster, light, animationProgress, tickDelta); matrices.push(); + float height = caster.asEntity().getHeight(); + matrices.translate(0, (-spell.pitch / 90F) * height * 0.5F, 0); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-spell.pitch)); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - spell.yaw)); - SpellEffectsRenderDispatcher.INSTANCE.render(matrices, vertices, delegate, caster, light, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch); + SpellEffectsRenderDispatcher.INSTANCE.render(matrices, vertices, delegate, caster, light, spell.getScale(tickDelta), limbDistance, tickDelta, animationProgress, headYaw, headPitch); matrices.pop(); } @@ -53,6 +54,9 @@ public class PlacedSpellRenderer extends SpellRenderer { matrices.push(); matrices.translate(0, 0.001, 0); + float height = caster.asEntity().getHeight(); + matrices.translate(0, (-spell.pitch / 90F) * height * 0.5F, 0); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-spell.pitch)); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - spell.yaw)); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90)); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/mob/CastSpellEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/mob/CastSpellEntity.java index 9677a123..92b1a909 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/mob/CastSpellEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/mob/CastSpellEntity.java @@ -6,6 +6,7 @@ import com.minelittlepony.unicopia.ability.magic.Levelled; import com.minelittlepony.unicopia.ability.magic.SpellContainer; import com.minelittlepony.unicopia.ability.magic.spell.Situation; import com.minelittlepony.unicopia.ability.magic.spell.Spell; +import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.entity.EntityPhysics; import com.minelittlepony.unicopia.entity.EntityReference; import com.minelittlepony.unicopia.entity.MagicImmune; @@ -13,6 +14,8 @@ import com.minelittlepony.unicopia.entity.Physics; import com.minelittlepony.unicopia.network.datasync.EffectSync; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.data.DataTracker; @@ -72,8 +75,9 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster spell.getScale(1)).orElse(1F)); } @Override @@ -117,6 +121,11 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster CAST_SPELL = register("cast_spell", FabricEntityTypeBuilder.create(SpawnGroup.MISC, CastSpellEntity::new) .trackRangeBlocks(200) - .dimensions(EntityDimensions.fixed(1, 1))); + .dimensions(EntityDimensions.changing(4, 4))); EntityType TWITTERMITE = register("twittermite", FabricEntityTypeBuilder.create(SpawnGroup.MISC, FairyEntity::new) .trackRangeBlocks(200) .dimensions(EntityDimensions.fixed(0.1F, 0.1F)));