diff --git a/src/main/java/electroblob/wizardry/WizardryEventHandler.java b/src/main/java/electroblob/wizardry/WizardryEventHandler.java index de9f9521..5e0d21b6 100644 --- a/src/main/java/electroblob/wizardry/WizardryEventHandler.java +++ b/src/main/java/electroblob/wizardry/WizardryEventHandler.java @@ -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") diff --git a/src/main/java/electroblob/wizardry/client/renderer/effect/RenderMirage.java b/src/main/java/electroblob/wizardry/client/renderer/effect/RenderMirage.java new file mode 100644 index 00000000..3e8337d4 --- /dev/null +++ b/src/main/java/electroblob/wizardry/client/renderer/effect/RenderMirage.java @@ -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(); + } + } + +} diff --git a/src/main/java/electroblob/wizardry/registry/Spells.java b/src/main/java/electroblob/wizardry/registry/Spells.java index 632a0852..bbc15c90 100644 --- a/src/main/java/electroblob/wizardry/registry/Spells.java +++ b/src/main/java/electroblob/wizardry/registry/Spells.java @@ -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()); diff --git a/src/main/java/electroblob/wizardry/registry/WizardryPotions.java b/src/main/java/electroblob/wizardry/registry/WizardryPotions.java index 9f5f7338..75535e1a 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryPotions.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryPotions.java @@ -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()); + } } \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/lang/en_gb.lang b/src/main/resources/assets/ebwizardry/lang/en_gb.lang index 2d28f970..c973a627 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_gb.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_gb.lang @@ -891,6 +891,7 @@ spell.ebwizardry\:meteor=Meteor spell.ebwizardry\:mind_control=Mind Control spell.ebwizardry\:mind_trick=Mind Trick spell.ebwizardry\:mine=Mine +spell.ebwizardry\:mirage=Mirage spell.ebwizardry\:muffle=Muffle spell.ebwizardry\:none=[Empty Slot] spell.ebwizardry\:oakflesh=Oakflesh @@ -1078,6 +1079,7 @@ spell.ebwizardry\:meteor.desc=Some wizards just want to see the world burn... spell.ebwizardry\:mind_control.desc=Takes control of the target's mind for 30 seconds, causing it switch sides and fight for the caster instead. Will not work on creatures that are too strong-willed. spell.ebwizardry\:mind_trick.desc=Confuses and disorients the target for 15 seconds, rendering it unable to attack effectively. The effect will be dispelled if the target takes damage. spell.ebwizardry\:mine.desc=Breaks the block the caster is looking at. Potency will allow harder blocks to be broken. +spell.ebwizardry\:mirage.desc=Creates an illusion where the caster appears to be a few blocks away from their actual position, blinking around every few seconds. The illusion lasts for 20 seconds. spell.ebwizardry\:muffle.desc=Silences any sounds made by the caster for 30 seconds. When muffled, mobs can only detect you when looking towards you. spell.ebwizardry\:none.desc=To get a spell book with the /give command, use id\: /give [player] ebwizardry\:spell_book 1 [spell id] (if you found this book in a chest, some other mod has messed things up). spell.ebwizardry\:oakflesh.desc=Improves the caster's damage resistance for 30 seconds. @@ -1251,6 +1253,7 @@ potion.ebwizardry\:curse_of_enfeeblement=Curse of Enfeeblement potion.ebwizardry\:curse_of_undeath=Curse of Undeath potion.ebwizardry\:containment=Containment potion.ebwizardry\:frost_step=Frost Step +potion.ebwizardry\:mirage=Mirage enchantment.ebwizardry\:magic_sword=Imbuement enchantment.ebwizardry\:magic_bow=Imbuement diff --git a/src/main/resources/assets/ebwizardry/lang/en_us.lang b/src/main/resources/assets/ebwizardry/lang/en_us.lang index 244eeb15..aefcd0ba 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_us.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_us.lang @@ -891,6 +891,7 @@ spell.ebwizardry\:meteor=Meteor spell.ebwizardry\:mind_control=Mind Control spell.ebwizardry\:mind_trick=Mind Trick spell.ebwizardry\:mine=Mine +spell.ebwizardry\:mirage=Mirage spell.ebwizardry\:muffle=Muffle spell.ebwizardry\:none=[Empty Slot] spell.ebwizardry\:oakflesh=Oakflesh @@ -1078,6 +1079,7 @@ spell.ebwizardry\:meteor.desc=Some wizards just want to see the world burn... spell.ebwizardry\:mind_control.desc=Takes control of the target's mind for 30 seconds, causing it switch sides and fight for the caster instead. Will not work on creatures that are too strong-willed. spell.ebwizardry\:mind_trick.desc=Confuses and disorients the target for 15 seconds, rendering it unable to attack effectively. The effect will be dispelled if the target takes damage. spell.ebwizardry\:mine.desc=Breaks the block the caster is looking at. Potency will allow harder blocks to be broken. +spell.ebwizardry\:mirage.desc=Creates an illusion where the caster appears to be a few blocks away from their actual position, blinking around every few seconds. The illusion lasts for 20 seconds. spell.ebwizardry\:muffle.desc=Silences any sounds made by the caster for 30 seconds. When muffled, mobs can only detect you when looking towards you. spell.ebwizardry\:none.desc=To get a spell book with the /give command, use id\: /give [player] ebwizardry\:spell_book 1 [spell id] (if you found this book in a chest, some other mod has messed things up). spell.ebwizardry\:oakflesh.desc=Improves the caster's damage resistance for 30 seconds. @@ -1251,6 +1253,7 @@ potion.ebwizardry\:curse_of_enfeeblement=Curse of Enfeeblement potion.ebwizardry\:curse_of_undeath=Curse of Undeath potion.ebwizardry\:containment=Containment potion.ebwizardry\:frost_step=Frost Step +potion.ebwizardry\:mirage=Mirage enchantment.ebwizardry\:magic_sword=Imbuement enchantment.ebwizardry\:magic_bow=Imbuement diff --git a/src/main/resources/assets/ebwizardry/spells/mirage.json b/src/main/resources/assets/ebwizardry/spells/mirage.json new file mode 100644 index 00000000..50aedefa --- /dev/null +++ b/src/main/resources/assets/ebwizardry/spells/mirage.json @@ -0,0 +1,23 @@ +{ + "enabled": { + "book": true, + "scroll": true, + "wands": true, + "npcs": true, + "dispensers": true, + "commands": true, + "treasure": true, + "trades": true, + "looting": true + }, + "tier": "advanced", + "element": "sorcery", + "type": "alteration", + "cost": 40, + "chargeup": 10, + "cooldown": 200, + "base_properties": { + "mirage_duration": 400, + "mirage_strength": 0 + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/textures/gui/potion_icons/mirage.png b/src/main/resources/assets/ebwizardry/textures/gui/potion_icons/mirage.png new file mode 100644 index 00000000..edebc087 Binary files /dev/null and b/src/main/resources/assets/ebwizardry/textures/gui/potion_icons/mirage.png differ diff --git a/src/main/resources/assets/ebwizardry/textures/spells/mirage.png b/src/main/resources/assets/ebwizardry/textures/spells/mirage.png new file mode 100644 index 00000000..e4743e91 Binary files /dev/null and b/src/main/resources/assets/ebwizardry/textures/spells/mirage.png differ