From 4ef54cf8cbd72d28f9109abd6ea71203ab404d56 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Sun, 31 May 2020 18:47:24 +0100 Subject: [PATCH] Add sounds to zombie apocalypse spell, plus misc tweaks --- .../client/renderer/RenderZombieSpawner.java | 15 ++++---- .../entity/construct/EntityZombieSpawner.java | 35 +++++++++++-------- .../wizardry/registry/WizardrySounds.java | 2 ++ .../wizardry/spell/ZombieApocalypse.java | 16 ++++++++- .../resources/assets/ebwizardry/sounds.json | 4 +++ 5 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderZombieSpawner.java b/src/main/java/electroblob/wizardry/client/renderer/RenderZombieSpawner.java index e5c2f8ce..abb37a46 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderZombieSpawner.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderZombieSpawner.java @@ -20,7 +20,7 @@ public class RenderZombieSpawner extends Render { private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/entity/zombie_spawner.png"); - private static final Vec3d[] HIDDEN_BOX = WizardryUtilities.getVertices(new AxisAlignedBB(-1, 0, -1, 1, 2.1, 1)); + private static final Vec3d[] HIDDEN_BOX = WizardryUtilities.getVertices(new AxisAlignedBB(-1, 0, -1, 1, 2.5, 1)); public RenderZombieSpawner(RenderManager renderManager){ super(renderManager); @@ -49,19 +49,22 @@ public class RenderZombieSpawner extends Render { s = (float)Math.pow(s, 0.4); // Smooths the animation GlStateManager.scale(s, s, s); - GlStateManager.rotate(age, 0, 1, 0); + GlStateManager.rotate(age * 2, 0, 1, 0); this.bindTexture(TEXTURE); Vec3d[] vertices = WizardryUtilities.getVertices(entity.getEntityBoundingBox().offset(entity.getPositionVector().scale(-1))); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - - drawFace(buffer, vertices[0], vertices[1], vertices[3], vertices[2], 0, 0, 1, 1); // Top - drawFace(buffer, vertices[1], vertices[0], vertices[2], vertices[3], 0, 0, 1, 1); // Bottom - + drawFace(buffer, vertices[0], vertices[1], vertices[3], vertices[2], 0, 0, 1, 1); // Bottom tessellator.draw(); + GlStateManager.disableDepth(); // Disable depth for the top face + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + drawFace(buffer, vertices[1], vertices[0], vertices[2], vertices[3], 0, 0, 1, 1); // Top + tessellator.draw(); + GlStateManager.enableDepth(); + GlStateManager.popMatrix(); // Hidden box diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityZombieSpawner.java b/src/main/java/electroblob/wizardry/entity/construct/EntityZombieSpawner.java index 7a9cbb3d..a79b36ea 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityZombieSpawner.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityZombieSpawner.java @@ -2,6 +2,7 @@ package electroblob.wizardry.entity.construct; import electroblob.wizardry.entity.living.EntityZombieMinion; import electroblob.wizardry.registry.Spells; +import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.spell.SpellMinion; import electroblob.wizardry.spell.ZombieApocalypse; import electroblob.wizardry.util.ParticleBuilder; @@ -24,23 +25,29 @@ public class EntityZombieSpawner extends EntityMagicConstruct { super.onUpdate(); - if(!world.isRemote && rand.nextInt(Spells.zombie_apocalypse.getProperty(ZombieApocalypse.MINION_SPAWN_INTERVAL).intValue()) == 0){ + if(lifetime - ticksExisted > 10 && rand.nextInt(Spells.zombie_apocalypse.getProperty(ZombieApocalypse.MINION_SPAWN_INTERVAL).intValue()) == 0){ - EntityZombieMinion zombie = new EntityZombieMinion(world); + if(world.isRemote){ + this.playSound(WizardrySounds.ENTITY_ZOMBIE_SPAWNER_SPAWN, 1, 1); - zombie.setPosition(this.posX, this.posY, this.posZ); - zombie.setCaster(this.getCaster()); - // Modifier implementation - // Attribute modifiers are pretty opaque, see https://minecraft.gamepedia.com/Attribute#Modifiers - zombie.setLifetime(Spells.zombie_apocalypse.getProperty(SpellMinion.MINION_LIFETIME).intValue()); - IAttributeInstance attribute = zombie.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE); - attribute.applyModifier(new AttributeModifier(SpellMinion.POTENCY_ATTRIBUTE_MODIFIER, - damageMultiplier - 1, Operations.MULTIPLY_CUMULATIVE)); - zombie.setHealth(zombie.getMaxHealth()); // Need to set this because we may have just modified the value - zombie.hurtResistantTime = 30; // Prevent fall damage - zombie.hideParticles(); // Hide spawn particles or they pop out the top of the hidden box + }else{ - world.spawnEntity(zombie); + EntityZombieMinion zombie = new EntityZombieMinion(world); + + zombie.setPosition(this.posX, this.posY, this.posZ); + zombie.setCaster(this.getCaster()); + // Modifier implementation + // Attribute modifiers are pretty opaque, see https://minecraft.gamepedia.com/Attribute#Modifiers + zombie.setLifetime(Spells.zombie_apocalypse.getProperty(SpellMinion.MINION_LIFETIME).intValue()); + IAttributeInstance attribute = zombie.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE); + attribute.applyModifier(new AttributeModifier(SpellMinion.POTENCY_ATTRIBUTE_MODIFIER, + damageMultiplier - 1, Operations.MULTIPLY_CUMULATIVE)); + zombie.setHealth(zombie.getMaxHealth()); // Need to set this because we may have just modified the value + zombie.hurtResistantTime = 30; // Prevent fall damage + zombie.hideParticles(); // Hide spawn particles or they pop out the top of the hidden box + + world.spawnEntity(zombie); + } } if(world.isRemote){ diff --git a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java index 240343dd..8c8bf00e 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java +++ b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java @@ -61,6 +61,7 @@ public final class WizardrySounds { public static final SoundEvent ENTITY_METEOR_FALLING = createSound("entity.meteor.falling"); public static final SoundEvent ENTITY_SHIELD_DEFLECT = createSound("entity.shield.deflect"); public static final SoundEvent ENTITY_TORNADO_AMBIENT = createSound("entity.tornado.ambient"); + public static final SoundEvent ENTITY_ZOMBIE_SPAWNER_SPAWN = createSound("entity.zombie_spawner.spawn"); public static final SoundEvent ENTITY_EVIL_WIZARD_AMBIENT = createSound("entity.evil_wizard.ambient"); public static final SoundEvent ENTITY_EVIL_WIZARD_HURT = createSound("entity.evil_wizard.hurt"); @@ -197,6 +198,7 @@ public final class WizardrySounds { event.getRegistry().register(ENTITY_METEOR_FALLING); event.getRegistry().register(ENTITY_SHIELD_DEFLECT); event.getRegistry().register(ENTITY_TORNADO_AMBIENT); + event.getRegistry().register(ENTITY_ZOMBIE_SPAWNER_SPAWN); event.getRegistry().register(ENTITY_EVIL_WIZARD_AMBIENT); event.getRegistry().register(ENTITY_EVIL_WIZARD_HURT); diff --git a/src/main/java/electroblob/wizardry/spell/ZombieApocalypse.java b/src/main/java/electroblob/wizardry/spell/ZombieApocalypse.java index 553041e7..a3d6acd4 100644 --- a/src/main/java/electroblob/wizardry/spell/ZombieApocalypse.java +++ b/src/main/java/electroblob/wizardry/spell/ZombieApocalypse.java @@ -2,9 +2,11 @@ package electroblob.wizardry.spell; import electroblob.wizardry.entity.construct.EntityZombieSpawner; import electroblob.wizardry.item.SpellActions; +import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.util.SpellModifiers; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumFacing; +import net.minecraft.util.SoundEvent; import net.minecraft.world.World; import javax.annotation.Nullable; @@ -13,15 +15,27 @@ public class ZombieApocalypse extends SpellConstruct { public static final String MINION_SPAWN_INTERVAL = "minion_spawn_interval"; + private static final int SPAWNER_HEIGHT = 8; + public ZombieApocalypse(){ super("zombie_apocalypse", SpellActions.POINT_UP, EntityZombieSpawner::new, false); addProperties(SpellMinion.MINION_LIFETIME, MINION_SPAWN_INTERVAL); + this.soundValues(1.3f, 1, 0); + } + + @Override + protected SoundEvent[] createSounds(){ + return createContinuousSpellSounds(); } @Override protected boolean spawnConstruct(World world, double x, double y, double z, EnumFacing side, @Nullable EntityLivingBase caster, SpellModifiers modifiers){ - y += 8; + y += SPAWNER_HEIGHT; return super.spawnConstruct(world, x, y, z, side, caster, modifiers); } + @Override + protected void playSound(World world, double x, double y, double z, int ticksInUse, int duration, SpellModifiers modifiers, String... sounds){ + this.playSoundLoop(world, x, y + SPAWNER_HEIGHT, z, 0, (int)(getProperty(DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade))); + } } diff --git a/src/main/resources/assets/ebwizardry/sounds.json b/src/main/resources/assets/ebwizardry/sounds.json index e03d769d..51ab8cd8 100644 --- a/src/main/resources/assets/ebwizardry/sounds.json +++ b/src/main/resources/assets/ebwizardry/sounds.json @@ -37,6 +37,7 @@ "entity.stormcloud.thunder": {"category": "spells", "sounds": ["ambient/weather/thunder1", "ambient/weather/thunder2", "ambient/weather/thunder3"]}, "entity.stormcloud.attack": {"category": "spells", "sounds": ["ebwizardry:arc1", "ebwizardry:arc2", "ebwizardry:arc3"]}, "entity.tornado.ambient": {"category": "spells", "sounds": ["ebwizardry:wind"]}, + "entity.zombie_spawner.spawn": {"category": "spells", "sounds": ["mob/guardian/elder_death"]}, "entity.evil_wizard.ambient": {"category": "hostile", "sounds": ["mob/evocation_illager/idle1", "mob/evocation_illager/idle2", "mob/evocation_illager/idle3", "mob/evocation_illager/idle4"]}, "entity.evil_wizard.hurt": {"category": "hostile", "sounds": ["mob/evocation_illager/hurt1", "mob/evocation_illager/hurt2"]}, @@ -324,6 +325,9 @@ "spell.whirlwind": {"category": "spells", "sounds": ["ebwizardry:ice"]}, "spell.wither": {"category": "spells", "sounds": ["mob/wither/hurt1", "mob/wither/hurt2", "mob/wither/hurt3", "mob/wither/hurt4"]}, "spell.wither_skull": {"category": "spells", "sounds": ["mob/wither/shoot"]}, + "spell.zombie_apocalypse.start": {"category": "spells", "sounds": ["ebwizardry:dark_aura_start"]}, + "spell.zombie_apocalypse.loop": {"category": "spells", "sounds": ["ebwizardry:dark_aura_loop"]}, + "spell.zombie_apocalypse.end": {"category": "spells", "sounds": ["ebwizardry:dark_aura_end"]}, "forfeit.burn_self": {"category": "spells", "sounds": ["fire/ignite"]}, "forfeit.fireball": {"category": "spells", "sounds": ["mob/ghast/fireball4"]},