mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-20 03:44:23 +01:00
Minor cleanup
This commit is contained in:
parent
b1f64b9f9f
commit
8d2639b69b
7 changed files with 34 additions and 11 deletions
|
@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.entity.UEntities;
|
||||||
import com.minelittlepony.unicopia.particle.OrientedBillboardParticleEffect;
|
import com.minelittlepony.unicopia.particle.OrientedBillboardParticleEffect;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleHandle;
|
import com.minelittlepony.unicopia.particle.ParticleHandle;
|
||||||
import com.minelittlepony.unicopia.particle.UParticles;
|
import com.minelittlepony.unicopia.particle.UParticles;
|
||||||
|
import com.minelittlepony.unicopia.particle.ParticleHandle.Attachment;
|
||||||
|
|
||||||
import net.minecraft.nbt.*;
|
import net.minecraft.nbt.*;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -98,7 +99,7 @@ public class PlaceableSpell extends AbstractDelegatingSpell {
|
||||||
particlEffect.update(getUuid(), source, spawner -> {
|
particlEffect.update(getUuid(), source, spawner -> {
|
||||||
spawner.addParticle(new OrientedBillboardParticleEffect(UParticles.MAGIC_RUNES, 90, 0), source.getOriginVector(), Vec3d.ZERO);
|
spawner.addParticle(new OrientedBillboardParticleEffect(UParticles.MAGIC_RUNES, 90, 0), source.getOriginVector(), Vec3d.ZERO);
|
||||||
}).ifPresent(p -> {
|
}).ifPresent(p -> {
|
||||||
p.setAttribute(1, spell.getType().getColor());
|
p.setAttribute(Attachment.ATTR_COLOR, spell.getType().getColor());
|
||||||
});
|
});
|
||||||
|
|
||||||
return super.tick(source, Situation.GROUND);
|
return super.tick(source, Situation.GROUND);
|
||||||
|
@ -137,7 +138,7 @@ public class PlaceableSpell extends AbstractDelegatingSpell {
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(NbtCompound compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
if (compound.contains("dimension")) {
|
if (compound.contains("dimension", NbtElement.STRING_TYPE)) {
|
||||||
Identifier id = Identifier.tryParse(compound.getString("dimension"));
|
Identifier id = Identifier.tryParse(compound.getString("dimension"));
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
dimension = RegistryKey.of(Registry.WORLD_KEY, id);
|
dimension = RegistryKey.of(Registry.WORLD_KEY, id);
|
||||||
|
|
|
@ -1,8 +1,24 @@
|
||||||
package com.minelittlepony.unicopia.ability.magic.spell;
|
package com.minelittlepony.unicopia.ability.magic.spell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The situation of the spell being ticked.
|
||||||
|
*/
|
||||||
public enum Situation {
|
public enum Situation {
|
||||||
|
/**
|
||||||
|
* Ticks coming from living entities like the player and animals.
|
||||||
|
*/
|
||||||
BODY,
|
BODY,
|
||||||
|
/**
|
||||||
|
* Ticks coming from flying projectiles.
|
||||||
|
*/
|
||||||
PROJECTILE,
|
PROJECTILE,
|
||||||
|
/**
|
||||||
|
* Ticks coming from a PlaceableSpell that's being updated as a ground entity.
|
||||||
|
*/
|
||||||
GROUND,
|
GROUND,
|
||||||
|
/**
|
||||||
|
* Ticks coming directly from the ground SpellCastEntity.
|
||||||
|
* Handled only by PlaceableSpell. No other spell should receive this.
|
||||||
|
*/
|
||||||
GROUND_ENTITY
|
GROUND_ENTITY
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
|
import com.minelittlepony.unicopia.particle.ParticleHandle.Attachment;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
import com.minelittlepony.unicopia.particle.SphereParticleEffect;
|
import com.minelittlepony.unicopia.particle.SphereParticleEffect;
|
||||||
import com.minelittlepony.unicopia.particle.UParticles;
|
import com.minelittlepony.unicopia.particle.UParticles;
|
||||||
|
@ -116,13 +117,13 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileSpell
|
||||||
particlEffect.update(getUuid(), source, spawner -> {
|
particlEffect.update(getUuid(), source, spawner -> {
|
||||||
spawner.addParticle(new SphereParticleEffect(UParticles.SPHERE, getType().getColor(), 0.99F, radius, SPHERE_OFFSET), source.getOriginVector(), Vec3d.ZERO);
|
spawner.addParticle(new SphereParticleEffect(UParticles.SPHERE, getType().getColor(), 0.99F, radius, SPHERE_OFFSET), source.getOriginVector(), Vec3d.ZERO);
|
||||||
}).ifPresent(p -> {
|
}).ifPresent(p -> {
|
||||||
p.setAttribute(0, radius);
|
p.setAttribute(Attachment.ATTR_RADIUS, radius);
|
||||||
});
|
});
|
||||||
particlEffect.update(getUuid(), "_ring", source, spawner -> {
|
particlEffect.update(getUuid(), "_ring", source, spawner -> {
|
||||||
spawner.addParticle(new SphereParticleEffect(UParticles.DISK, 0xFFFFFFFF, 0.4F, radius + 1, SPHERE_OFFSET), getOrigin(source), Vec3d.ZERO);
|
spawner.addParticle(new SphereParticleEffect(UParticles.DISK, 0xFFFFFFFF, 0.4F, radius + 1, SPHERE_OFFSET), getOrigin(source), Vec3d.ZERO);
|
||||||
}).ifPresent(p -> {
|
}).ifPresent(p -> {
|
||||||
p.setAttribute(0, radius * 2F);
|
p.setAttribute(Attachment.ATTR_RADIUS, radius * 2F);
|
||||||
p.setAttribute(1, 0xAAAAAA);
|
p.setAttribute(Attachment.ATTR_COLOR, 0xAAAAAA);
|
||||||
});
|
});
|
||||||
|
|
||||||
double angle = age % 260;
|
double angle = age % 260;
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.particle.MagicParticleEffect;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleHandle;
|
import com.minelittlepony.unicopia.particle.ParticleHandle;
|
||||||
import com.minelittlepony.unicopia.particle.SphereParticleEffect;
|
import com.minelittlepony.unicopia.particle.SphereParticleEffect;
|
||||||
import com.minelittlepony.unicopia.particle.UParticles;
|
import com.minelittlepony.unicopia.particle.UParticles;
|
||||||
|
import com.minelittlepony.unicopia.particle.ParticleHandle.Attachment;
|
||||||
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
|
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
|
||||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||||
|
|
||||||
|
@ -75,8 +76,8 @@ public class ShieldSpell extends AbstractSpell {
|
||||||
particlEffect.update(getUuid(), source, spawner -> {
|
particlEffect.update(getUuid(), source, spawner -> {
|
||||||
spawner.addParticle(new SphereParticleEffect(UParticles.SPHERE, getType().getColor(), 0.3F, radius), origin, Vec3d.ZERO);
|
spawner.addParticle(new SphereParticleEffect(UParticles.SPHERE, getType().getColor(), 0.3F, radius), origin, Vec3d.ZERO);
|
||||||
}).ifPresent(p -> {
|
}).ifPresent(p -> {
|
||||||
p.setAttribute(0, radius);
|
p.setAttribute(Attachment.ATTR_RADIUS, radius);
|
||||||
p.setAttribute(1, getType().getColor());
|
p.setAttribute(Attachment.ATTR_COLOR, getType().getColor());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttribute(int key, Object value) {
|
public void setAttribute(int key, Object value) {
|
||||||
if (key == 1) {
|
if (key == ATTR_COLOR) {
|
||||||
int tint = (int)value;
|
int tint = (int)value;
|
||||||
red = Color.r(tint);
|
red = Color.r(tint);
|
||||||
green = Color.g(tint);
|
green = Color.g(tint);
|
||||||
|
|
|
@ -75,18 +75,18 @@ public class SphereParticle extends Particle implements Attachment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttribute(int key, Object value) {
|
public void setAttribute(int key, Object value) {
|
||||||
if (key == 0) {
|
if (key == ATTR_RADIUS) {
|
||||||
toRadius = (float)value;
|
toRadius = (float)value;
|
||||||
steps = 20;
|
steps = 20;
|
||||||
lerpIncrement = (toRadius - radius) / steps;
|
lerpIncrement = (toRadius - radius) / steps;
|
||||||
}
|
}
|
||||||
if (key == 1) {
|
if (key == ATTR_COLOR) {
|
||||||
int tint = (int)value;
|
int tint = (int)value;
|
||||||
red = Color.r(tint);
|
red = Color.r(tint);
|
||||||
green = Color.g(tint);
|
green = Color.g(tint);
|
||||||
blue = Color.b(tint);
|
blue = Color.b(tint);
|
||||||
}
|
}
|
||||||
if (key == 2) {
|
if (key == ATTR_OPACITY) {
|
||||||
alpha = (float)value;
|
alpha = (float)value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,10 @@ public class ParticleHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Attachment {
|
public interface Attachment {
|
||||||
|
int ATTR_RADIUS = 0;
|
||||||
|
int ATTR_COLOR = 1;
|
||||||
|
int ATTR_OPACITY = 2;
|
||||||
|
|
||||||
boolean isStillAlive();
|
boolean isStillAlive();
|
||||||
|
|
||||||
void attach(Link link);
|
void attach(Link link);
|
||||||
|
|
Loading…
Reference in a new issue