diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java index a28dc8ee..9af5cddb 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java @@ -61,10 +61,11 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp @Override public void generateParticles(Caster source) { double range = getDrawDropOffRange(source); + Vec3d origin = getOrigin(source); - source.spawnParticles(getOrigin(source), new Sphere(false, range), 7, p -> { + source.spawnParticles(origin, new Sphere(false, range), 7, p -> { source.addParticle( - new FollowingParticleEffect(UParticles.HEALTH_DRAIN, source.asEntity(), 0.4F) + new FollowingParticleEffect(UParticles.HEALTH_DRAIN, origin, 0.4F) .withChild(ParticleTypes.AMBIENT_ENTITY_EFFECT), p, Vec3d.ZERO diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java index edf3b732..c8fb3a6d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java @@ -114,9 +114,10 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega if (getEventHorizonRadius() > 3) { double range = getDrawDropOffRange(source); - source.spawnParticles(getOrigin(source), new Sphere(false, range), 17, p -> { + Vec3d origin = getOrigin(source); + source.spawnParticles(origin, new Sphere(false, range), 17, p -> { source.addParticle( - new FollowingParticleEffect(UParticles.HEALTH_DRAIN, source.asEntity(), 0.4F) + new FollowingParticleEffect(UParticles.HEALTH_DRAIN, origin, 0.4F) .withChild(ParticleTypes.CAMPFIRE_SIGNAL_SMOKE), p, Vec3d.ZERO diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/CloudsEscapingParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/CloudsEscapingParticle.java index 50792cfe..32ff15f7 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/CloudsEscapingParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/CloudsEscapingParticle.java @@ -30,7 +30,7 @@ public class CloudsEscapingParticle extends GroundPoundParticle { ); double columnHeight = 1 + age / 30; - new Sphere(true, columnHeight, 1, 1, 1) + new Sphere(true, columnHeight) .translate(center) .randomPoints(random) .forEach(point -> { diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java index fd40922f..700963a6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java @@ -22,9 +22,9 @@ public class MagicParticle extends SpriteBillboardParticle { velocityX = vX; velocityY = vY; velocityZ = vZ; - startX = x;// + random.nextGaussian()/3; - startY = y;// + random.nextGaussian()/3; - startZ = z;// + random.nextGaussian()/3; + startX = x + random.nextGaussian()/3; + startY = y + random.nextGaussian()/3; + startZ = z + random.nextGaussian()/3; scale = random.nextFloat() * 0.12F; maxAge = (int)(Math.random() * 10) + 20; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/PlaneModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/model/PlaneModel.java new file mode 100644 index 00000000..bfbcfc24 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/client/render/model/PlaneModel.java @@ -0,0 +1,12 @@ +package com.minelittlepony.unicopia.client.render.model; + +public class PlaneModel extends BakedModel { + public static final PlaneModel INSTANCE = new PlaneModel(); + + private PlaneModel() { + addVertex(-1, -1, 0, 0, 0); + addVertex(-1, 1, 0, 1, 0); + addVertex( 1, 1, 0, 1, 1); + addVertex( 1, -1, 0, 0, 1); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/spell/DarkVortexSpellRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/spell/DarkVortexSpellRenderer.java index 98b32575..0389cfca 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/spell/DarkVortexSpellRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/spell/DarkVortexSpellRenderer.java @@ -1,12 +1,9 @@ package com.minelittlepony.unicopia.client.render.spell; -import org.joml.Vector3f; -import org.joml.Vector4f; - import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.effect.DarkVortexSpell; import com.minelittlepony.unicopia.client.render.RenderLayers; -import com.minelittlepony.unicopia.client.render.RenderUtil; +import com.minelittlepony.unicopia.client.render.model.PlaneModel; import com.minelittlepony.unicopia.client.render.model.SphereModel; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.RenderLayer; @@ -20,12 +17,13 @@ import net.minecraft.util.math.RotationAxis; public class DarkVortexSpellRenderer implements SpellRenderer { + private static final Identifier ECRETION_RING_TEXTURE = new Identifier("textures/misc/forcefield.png"); + private static float cameraDistortion; public static float getCameraDistortion() { cameraDistortion *= 0.9F; cameraDistortion = MathHelper.clamp(cameraDistortion, 0, 80); - System.out.println(cameraDistortion); return cameraDistortion; } @@ -79,20 +77,9 @@ public class DarkVortexSpellRenderer implements SpellRenderer { matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(45)); matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(animationProgress * 168)); + VertexConsumer buffer = vertices.getBuffer(RenderLayer.getEntityTranslucent(ECRETION_RING_TEXTURE)); - RenderUtil.Vertex[] CORNERS = new RenderUtil.Vertex[]{ - new RenderUtil.Vertex(new Vector3f(-1, -1, 0), 0, 0), - new RenderUtil.Vertex(new Vector3f(-1, 1, 0), 1, 0), - new RenderUtil.Vertex(new Vector3f( 1, 1, 0), 1, 1), - new RenderUtil.Vertex(new Vector3f( 1, -1, 0), 0, 1) - }; - - VertexConsumer buffer = vertices.getBuffer(RenderLayer.getEntityTranslucent(new Identifier("textures/misc/forcefield.png"))); - - for (var corner : CORNERS) { - Vector4f pos = corner.position(matrices); - buffer.vertex(pos.x, pos.y, pos.z, 1, 1, 1, 1, corner.u(), corner.v(), 0, light, 1, 1, 1); - } + PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, 1, 1, 1, 1); } matrices.pop(); } 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 142b11ac..4630912b 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 @@ -1,14 +1,11 @@ package com.minelittlepony.unicopia.client.render.spell; -import org.joml.Vector3f; -import org.joml.Vector4f; - import com.minelittlepony.common.util.Color; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.PlaceableSpell; import com.minelittlepony.unicopia.ability.magic.spell.Spell; -import com.minelittlepony.unicopia.client.render.RenderUtil; +import com.minelittlepony.unicopia.client.render.model.PlaneModel; import com.minelittlepony.unicopia.entity.mob.CastSpellEntity; import net.minecraft.client.render.RenderLayer; @@ -27,12 +24,6 @@ public class PlacedSpellRenderer implements SpellRenderer { Unicopia.id("textures/particles/runes_4.png"), Unicopia.id("textures/particles/runes_5.png") }; - private static final RenderUtil.Vertex[] CORNERS = new RenderUtil.Vertex[]{ - new RenderUtil.Vertex(new Vector3f(-1, -1, 0), 0, 0), - new RenderUtil.Vertex(new Vector3f(-1, 1, 0), 1, 0), - new RenderUtil.Vertex(new Vector3f( 1, 1, 0), 1, 1), - new RenderUtil.Vertex(new Vector3f( 1, -1, 0), 0, 1) - }; @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) { @@ -50,8 +41,6 @@ public class PlacedSpellRenderer implements SpellRenderer { float scale = (spell.getAge(tickDelta) / 25F) * 3; matrices.scale(scale, scale, scale); - float alpha = scale; - float angle = (animationProgress / 9F) % 360; int color = delegate.getType().getColor(); @@ -70,7 +59,7 @@ public class PlacedSpellRenderer implements SpellRenderer { matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(angle * ringSpeed)); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(angle * ringSpeed * dim)); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(angle * ringSpeed * dim)); - renderQuad(buffer, matrices, red, green, blue, alpha / ((float)(dim * 3) + 1), light); + PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, red, green, blue, scale / ((float)(dim * 3) + 1)); matrices.pop(); } } @@ -80,11 +69,4 @@ public class PlacedSpellRenderer implements SpellRenderer { SpellEffectsRenderDispatcher.INSTANCE.render(matrices, vertices, delegate, caster, light, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch); } } - - protected final void renderQuad(VertexConsumer buffer, MatrixStack matrices, float red, float green, float blue, float alpha, int light) { - for (var corner : CORNERS) { - Vector4f pos = corner.position(matrices); - buffer.vertex(pos.x, pos.y, pos.z, red, green, blue, alpha, corner.u(), corner.v(), 0, light, 1, 1, 1); - } - } } diff --git a/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java b/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java index 7ebf61af..c151b47c 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.util.shape; +import org.spongepowered.include.com.google.common.base.Objects; + import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.random.Random; @@ -102,6 +104,19 @@ public class Sphere implements Shape { return stretch.multiply(rad); } + @Override + public boolean equals(Object other) { + return other instanceof Sphere o + && Objects.equal(stretch, o.stretch) + && hollow == o.hollow + && Double.compare(rad, o.rad) == 0; + } + + @Override + public int hashCode() { + return Objects.hashCode(stretch, hollow, rad); + } + public static double computeEllipsoidArea(double rad, Vec3d stretch) { double p = 1.6075; double result = Math.pow(rad * stretch.x, p) * Math.pow(rad * stretch.y, p);