Add sounds to zombie apocalypse spell, plus misc tweaks
This commit is contained in:
@@ -20,7 +20,7 @@ public class RenderZombieSpawner extends Render<EntityZombieSpawner> {
|
||||
|
||||
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<EntityZombieSpawner> {
|
||||
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
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<EntityZombieSpawner> {
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user