Add mirage spell

This commit is contained in:
Electroblob77
2020-10-18 22:12:14 +01:00
parent cf8de05d1b
commit 89345d4fbc
9 changed files with 88 additions and 0 deletions
@@ -210,6 +210,12 @@ public final class WizardryEventHandler {
}
}
// Mirage
if(event.getTarget().isPotionActive(WizardryPotions.mirage)){
// Can't find players under mirage at all! (Pretty sure this excludes revenge-targeting)
((EntityLiving)event.getEntityLiving()).setAttackTarget(null);
}
// Blindness tweak
// I'm not going as far as potion core's implementation, this is just so it does *something* to mobs
if(event.getEntityLiving().isPotionActive(MobEffects.BLINDNESS) && !Loader.isModLoaded("potioncore")
@@ -0,0 +1,45 @@
package electroblob.wizardry.client.renderer.effect;
import electroblob.wizardry.registry.WizardryPotions;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import java.util.Random;
@EventBusSubscriber(Side.CLIENT)
public class RenderMirage {
private static final int BLINK_PERIOD_1 = 47; // Use two prime numbers to make it look as chaotic as possible
private static final int BLINK_PERIOD_2 = 71;
private static final double MAX_OFFSET = 3;
private static final Random random = new Random(); // Seed will be set later
@SubscribeEvent
public static void onRenderLivingEvent(RenderLivingEvent.Pre<?> event){
if(event.getEntity().isPotionActive(WizardryPotions.mirage)){
random.setSeed(event.getEntity().ticksExisted / BLINK_PERIOD_1
+ event.getEntity().ticksExisted / BLINK_PERIOD_2);
GlStateManager.pushMatrix();
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE); // GhoOOoOostly OooOOOo00oOOo
GlStateManager.color(1, 1, 1, 0.5f);
GlStateManager.translate((random.nextDouble() * 2 - 1) * MAX_OFFSET,
(random.nextDouble() * 2 - 1) * MAX_OFFSET, (random.nextDouble() * 2 - 1) * MAX_OFFSET);
}
}
@SubscribeEvent
public static void onRenderLivingEvent(RenderLivingEvent.Post<?> event){
if(event.getEntity().isPotionActive(WizardryPotions.mirage)){
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.popMatrix();
}
}
}
@@ -468,6 +468,7 @@ public final class Spells {
registry.register(new WitheringTotem());
registry.register(new Fangs());
registry.register(new GuardianBeam());
registry.register(new SpellBuff("mirage", 0.64f, 0.47f, 0.9f, () -> WizardryPotions.mirage));
registry.register(new RadiantTotem());
registry.register(new Firestorm());
@@ -56,6 +56,7 @@ public final class WizardryPotions {
public static final Potion containment = placeholder();
public static final Potion frost_step = placeholder();
public static final Potion mark_of_sacrifice = placeholder();
public static final Potion mirage = placeholder();
/**
* Sets both the registry and unlocalised names of the given potion, then registers it with the given registry. Use
@@ -194,6 +195,12 @@ public final class WizardryPotions {
registerPotion(registry, "mark_of_sacrifice", new PotionMagicEffect(true, 0xe90e48,
new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icons/mark_of_sacrifice.png")));
registerPotion(registry, "mirage", new PotionMagicEffectParticles(false, 0, // No particles or we'll see the player's actual position!
new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icons/mirage.png")){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){} // We only want the syncing
}.setBeneficial());
}
}