Add stormcloud spell

This commit is contained in:
Electroblob77
2020-05-18 20:41:41 +01:00
parent ebde514c98
commit 650344a0c8
11 changed files with 191 additions and 1 deletions
@@ -795,6 +795,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityStormElemental.class, RenderBlank::new);
RenderingRegistry.registerEntityRenderingHandler(EntityEarthquake.class, RenderBlank::new);
RenderingRegistry.registerEntityRenderingHandler(EntityHailstorm.class, RenderBlank::new);
RenderingRegistry.registerEntityRenderingHandler(EntityStormcloud.class, RenderBlank::new);
// Runes on ground
RenderingRegistry.registerEntityRenderingHandler(EntityHealAura.class,
@@ -0,0 +1,122 @@
package electroblob.wizardry.entity.construct;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.MagicDamage;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.WizardryUtilities;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;
import java.util.List;
public class EntityStormcloud extends EntityMagicConstruct {
// private static final DataParameter<Float> RADIUS = new DataParameter<>(21, DataSerializers.FLOAT);
public EntityStormcloud(World world){
super(world);
this.height = 2.0f;
this.width = Spells.stormcloud.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2;
}
// @Override
// protected void entityInit(){
// super.entityInit();
// this.getDataManager().register(RADIUS, width); // TODO: This doesn't work, implement blast modifiers properly into SpellConstruct
// }
// public void multiplyWidth(float multiplier){
// this.setSize(width * multiplier, height);
// this.getDataManager().set(RADIUS, width);
// }
public void onUpdate(){
super.onUpdate();
// if(world.isRemote){
// float radius = this.getDataManager().get(RADIUS);
// if(radius != width) this.setSize(radius, height);
// }else{
// if(this.getDataManager().get(RADIUS) != width) this.getDataManager().set(RADIUS, width);
// }
// if(this.ticksExisted % 35 == 0) this.playSound(WizardrySounds.ENTITY_STORMCLOUD_AMBIENT, 1, 1);
if(this.world.isRemote){
float areaFactor = (width * width) / 36; // Ensures cloud/raindrop density stays the same for different sizes
for(int i = 0; i < 2 * areaFactor; i++) ParticleBuilder.create(Type.CLOUD, this)
.clr(0.3f, 0.3f, 0.3f).shaded(true).spawn(world);
}
List<EntityLivingBase> targets = world.getEntitiesWithinAABB(EntityLivingBase.class,
this.getEntityBoundingBox().expand(0, -10, 0));
float damage = Spells.stormcloud.getProperty(Spell.DAMAGE).floatValue() * this.damageMultiplier;
for(EntityLivingBase target : targets){
if(this.isValidTarget(target)){
if(target.ticksExisted % 150 == 0){ // Use target's lifetime so they don't all get hit at once, looks better
if(!this.world.isRemote){
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeIndirectMagicDamage(
this, this.getCaster(), MagicDamage.DamageType.SHOCK), damage);
}else{
ParticleBuilder.create(Type.LIGHTNING).pos(target.posX, posY + height/2, target.posZ)
.target(target).scale(2).spawn(world);
ParticleBuilder.spawnShockParticles(world, target.posX, target.getEntityBoundingBox().minY + target.height, target.posZ);
}
target.playSound(WizardrySounds.ENTITY_STORMCLOUD_THUNDER, 1, 1.6f);
target.playSound(WizardrySounds.ENTITY_STORMCLOUD_ATTACK, 1, 1);
}
}
}
// BlockPos pos = new BlockPos(this);
//
// for(int x = -(int)(this.width/2); x <= this.width/2 + 0.5; x++){
// for(int z = -(int)(this.width/2); z <= this.width/2 + 0.5; z++){
//
// int y = WizardryUtilities.getNearestFloor()
//
// }
// }
}
// Need to sync the caster so they don't have particles spawned at them
@Override
public void writeSpawnData(ByteBuf data){
super.writeSpawnData(data);
if(getCaster() != null) data.writeInt(getCaster().getEntityId());
}
@Override
public void readSpawnData(ByteBuf data){
super.readSpawnData(data);
if(!data.isReadable()) return;
Entity entity = world.getEntityByID(data.readInt());
if(entity instanceof EntityLivingBase){
setCaster((EntityLivingBase)entity);
}else{
Wizardry.logger.warn("Stormcloud caster with ID in spawn data not found");
}
}
}
@@ -8,7 +8,6 @@ import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.spell.*;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.init.MobEffects;
import net.minecraft.item.EnumAction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
@@ -239,6 +238,10 @@ public final class Spells {
public static final Spell slow_time = placeholder();
public static final Spell resurrection = placeholder();
// Wizardry 4.3 spells
public static final Spell stormcloud = placeholder();
@SubscribeEvent
public static void register(RegistryEvent.Register<Spell> event){
@@ -437,6 +440,11 @@ public final class Spells {
registry.register(new SpeedTime());
registry.register(new SlowTime());
registry.register(new Resurrection());
// Wizardry 4.3 spells
registry.register(new Stormcloud());
}
}
@@ -150,6 +150,7 @@ public class WizardryEntities {
registry.register(createEntry(EntityArrowRain.class, "arrow_rain", TrackingType.CONSTRUCT).build());
registry.register(createEntry(EntityEarthquake.class, "earthquake", TrackingType.CONSTRUCT).build());
registry.register(createEntry(EntityHailstorm.class, "hailstorm", TrackingType.CONSTRUCT).build());
registry.register(createEntry(EntityStormcloud.class, "stormcloud", TrackingType.CONSTRUCT).build());
// These ones move, velocity updates are sent if that's not at constant velocity
registry.register(createEntry(EntityShield.class, "shield") .tracker(160, 10, true).build());
@@ -86,6 +86,8 @@ public final class WizardrySounds {
public static final SoundEvent ENTITY_STORM_ELEMENTAL_WIND = createSound("entity.storm_elemental.wind");
public static final SoundEvent ENTITY_STORM_ELEMENTAL_HURT = createSound("entity.storm_elemental.hurt");
public static final SoundEvent ENTITY_STORM_ELEMENTAL_DEATH = createSound("entity.storm_elemental.death");
public static final SoundEvent ENTITY_STORMCLOUD_THUNDER = createSound("entity.stormcloud.thunder");
public static final SoundEvent ENTITY_STORMCLOUD_ATTACK = createSound("entity.stormcloud.attack");
public static final SoundEvent ENTITY_WIZARD_YES = createSound("entity.wizard.yes");
public static final SoundEvent ENTITY_WIZARD_NO = createSound("entity.wizard.no");
public static final SoundEvent ENTITY_WIZARD_AMBIENT = createSound("entity.wizard.ambient");
@@ -0,0 +1,22 @@
package electroblob.wizardry.spell;
import electroblob.wizardry.entity.construct.EntityStormcloud;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumFacing;
import javax.annotation.Nullable;
public class Stormcloud extends SpellConstructRanged<EntityStormcloud> {
public Stormcloud(){
super("stormcloud", EntityStormcloud::new, false);
this.addProperties(DAMAGE, EFFECT_RADIUS);
this.floor(true);
}
@Override
protected void addConstructExtras(EntityStormcloud construct, EnumFacing side, @Nullable EntityLivingBase caster, SpellModifiers modifiers){
construct.posY += 5;
}
}