mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Fixed dark vortex particles not going to its actual center
This commit is contained in:
parent
134db120cd
commit
8cb3ba298d
8 changed files with 44 additions and 46 deletions
|
@ -61,10 +61,11 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp
|
||||||
@Override
|
@Override
|
||||||
public void generateParticles(Caster<?> source) {
|
public void generateParticles(Caster<?> source) {
|
||||||
double range = getDrawDropOffRange(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(
|
source.addParticle(
|
||||||
new FollowingParticleEffect(UParticles.HEALTH_DRAIN, source.asEntity(), 0.4F)
|
new FollowingParticleEffect(UParticles.HEALTH_DRAIN, origin, 0.4F)
|
||||||
.withChild(ParticleTypes.AMBIENT_ENTITY_EFFECT),
|
.withChild(ParticleTypes.AMBIENT_ENTITY_EFFECT),
|
||||||
p,
|
p,
|
||||||
Vec3d.ZERO
|
Vec3d.ZERO
|
||||||
|
|
|
@ -114,9 +114,10 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
||||||
|
|
||||||
if (getEventHorizonRadius() > 3) {
|
if (getEventHorizonRadius() > 3) {
|
||||||
double range = getDrawDropOffRange(source);
|
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(
|
source.addParticle(
|
||||||
new FollowingParticleEffect(UParticles.HEALTH_DRAIN, source.asEntity(), 0.4F)
|
new FollowingParticleEffect(UParticles.HEALTH_DRAIN, origin, 0.4F)
|
||||||
.withChild(ParticleTypes.CAMPFIRE_SIGNAL_SMOKE),
|
.withChild(ParticleTypes.CAMPFIRE_SIGNAL_SMOKE),
|
||||||
p,
|
p,
|
||||||
Vec3d.ZERO
|
Vec3d.ZERO
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class CloudsEscapingParticle extends GroundPoundParticle {
|
||||||
);
|
);
|
||||||
|
|
||||||
double columnHeight = 1 + age / 30;
|
double columnHeight = 1 + age / 30;
|
||||||
new Sphere(true, columnHeight, 1, 1, 1)
|
new Sphere(true, columnHeight)
|
||||||
.translate(center)
|
.translate(center)
|
||||||
.randomPoints(random)
|
.randomPoints(random)
|
||||||
.forEach(point -> {
|
.forEach(point -> {
|
||||||
|
|
|
@ -22,9 +22,9 @@ public class MagicParticle extends SpriteBillboardParticle {
|
||||||
velocityX = vX;
|
velocityX = vX;
|
||||||
velocityY = vY;
|
velocityY = vY;
|
||||||
velocityZ = vZ;
|
velocityZ = vZ;
|
||||||
startX = x;// + random.nextGaussian()/3;
|
startX = x + random.nextGaussian()/3;
|
||||||
startY = y;// + random.nextGaussian()/3;
|
startY = y + random.nextGaussian()/3;
|
||||||
startZ = z;// + random.nextGaussian()/3;
|
startZ = z + random.nextGaussian()/3;
|
||||||
scale = random.nextFloat() * 0.12F;
|
scale = random.nextFloat() * 0.12F;
|
||||||
maxAge = (int)(Math.random() * 10) + 20;
|
maxAge = (int)(Math.random() * 10) + 20;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.client.render.spell;
|
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.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.DarkVortexSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.DarkVortexSpell;
|
||||||
import com.minelittlepony.unicopia.client.render.RenderLayers;
|
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 com.minelittlepony.unicopia.client.render.model.SphereModel;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
@ -20,12 +17,13 @@ import net.minecraft.util.math.RotationAxis;
|
||||||
|
|
||||||
public class DarkVortexSpellRenderer implements SpellRenderer<DarkVortexSpell> {
|
public class DarkVortexSpellRenderer implements SpellRenderer<DarkVortexSpell> {
|
||||||
|
|
||||||
|
private static final Identifier ECRETION_RING_TEXTURE = new Identifier("textures/misc/forcefield.png");
|
||||||
|
|
||||||
private static float cameraDistortion;
|
private static float cameraDistortion;
|
||||||
|
|
||||||
public static float getCameraDistortion() {
|
public static float getCameraDistortion() {
|
||||||
cameraDistortion *= 0.9F;
|
cameraDistortion *= 0.9F;
|
||||||
cameraDistortion = MathHelper.clamp(cameraDistortion, 0, 80);
|
cameraDistortion = MathHelper.clamp(cameraDistortion, 0, 80);
|
||||||
System.out.println(cameraDistortion);
|
|
||||||
return cameraDistortion;
|
return cameraDistortion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,20 +77,9 @@ public class DarkVortexSpellRenderer implements SpellRenderer<DarkVortexSpell> {
|
||||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(45));
|
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(45));
|
||||||
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(animationProgress * 168));
|
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(animationProgress * 168));
|
||||||
|
|
||||||
|
VertexConsumer buffer = vertices.getBuffer(RenderLayer.getEntityTranslucent(ECRETION_RING_TEXTURE));
|
||||||
|
|
||||||
RenderUtil.Vertex[] CORNERS = new RenderUtil.Vertex[]{
|
PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, 1, 1, 1, 1);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
package com.minelittlepony.unicopia.client.render.spell;
|
package com.minelittlepony.unicopia.client.render.spell;
|
||||||
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.joml.Vector4f;
|
|
||||||
|
|
||||||
import com.minelittlepony.common.util.Color;
|
import com.minelittlepony.common.util.Color;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.PlaceableSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.PlaceableSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Spell;
|
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 com.minelittlepony.unicopia.entity.mob.CastSpellEntity;
|
||||||
|
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
@ -27,12 +24,6 @@ public class PlacedSpellRenderer implements SpellRenderer<PlaceableSpell> {
|
||||||
Unicopia.id("textures/particles/runes_4.png"),
|
Unicopia.id("textures/particles/runes_4.png"),
|
||||||
Unicopia.id("textures/particles/runes_5.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
|
@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) {
|
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<PlaceableSpell> {
|
||||||
float scale = (spell.getAge(tickDelta) / 25F) * 3;
|
float scale = (spell.getAge(tickDelta) / 25F) * 3;
|
||||||
matrices.scale(scale, scale, scale);
|
matrices.scale(scale, scale, scale);
|
||||||
|
|
||||||
float alpha = scale;
|
|
||||||
|
|
||||||
float angle = (animationProgress / 9F) % 360;
|
float angle = (animationProgress / 9F) % 360;
|
||||||
|
|
||||||
int color = delegate.getType().getColor();
|
int color = delegate.getType().getColor();
|
||||||
|
@ -70,7 +59,7 @@ public class PlacedSpellRenderer implements SpellRenderer<PlaceableSpell> {
|
||||||
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(angle * ringSpeed));
|
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(angle * ringSpeed));
|
||||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(angle * ringSpeed * dim));
|
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(angle * ringSpeed * dim));
|
||||||
matrices.multiply(RotationAxis.POSITIVE_X.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();
|
matrices.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,11 +69,4 @@ public class PlacedSpellRenderer implements SpellRenderer<PlaceableSpell> {
|
||||||
SpellEffectsRenderDispatcher.INSTANCE.render(matrices, vertices, delegate, caster, light, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.util.shape;
|
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.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.random.Random;
|
import net.minecraft.util.math.random.Random;
|
||||||
|
@ -102,6 +104,19 @@ public class Sphere implements Shape {
|
||||||
return stretch.multiply(rad);
|
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) {
|
public static double computeEllipsoidArea(double rad, Vec3d stretch) {
|
||||||
double p = 1.6075;
|
double p = 1.6075;
|
||||||
double result = Math.pow(rad * stretch.x, p) * Math.pow(rad * stretch.y, p);
|
double result = Math.pow(rad * stretch.x, p) * Math.pow(rad * stretch.y, p);
|
||||||
|
|
Loading…
Reference in a new issue