From 6f776fbae6e0c6fcc9ccbd6f2ae355a0455adf15 Mon Sep 17 00:00:00 2001 From: Electroblob <35599699+Electroblob77@users.noreply.github.com> Date: Mon, 26 Feb 2018 18:37:52 +0000 Subject: [PATCH] Cleanup --- .../java/electroblob/wizardry/WizardryEventHandler.java | 2 +- src/main/java/electroblob/wizardry/registry/Spells.java | 3 ++- src/main/java/electroblob/wizardry/spell/MindTrick.java | 6 +++--- src/main/java/electroblob/wizardry/spell/Petrify.java | 3 +-- src/main/java/electroblob/wizardry/spell/PhaseStep.java | 7 ++----- .../java/electroblob/wizardry/util/IElementalDamage.java | 4 +++- src/main/java/electroblob/wizardry/util/MagicDamage.java | 4 ++-- .../java/electroblob/wizardry/util/WizardryUtilities.java | 3 +-- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/main/java/electroblob/wizardry/WizardryEventHandler.java b/src/main/java/electroblob/wizardry/WizardryEventHandler.java index 10e1a95f..3454f071 100644 --- a/src/main/java/electroblob/wizardry/WizardryEventHandler.java +++ b/src/main/java/electroblob/wizardry/WizardryEventHandler.java @@ -171,7 +171,7 @@ public final class WizardryEventHandler { @SubscribeEvent public static void onLivingAttackEvent(LivingAttackEvent event){ - // Prevents any damage to allies from magic if friendly fire is enabled + // Prevents any damage to allies from magic if friendly fire is disabled if(!Wizardry.settings.friendlyFire && event.getSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityPlayer && event.getSource() instanceof IElementalDamage){ diff --git a/src/main/java/electroblob/wizardry/registry/Spells.java b/src/main/java/electroblob/wizardry/registry/Spells.java index 4356d65a..2879dbd0 100644 --- a/src/main/java/electroblob/wizardry/registry/Spells.java +++ b/src/main/java/electroblob/wizardry/registry/Spells.java @@ -21,7 +21,8 @@ import net.minecraftforge.fml.common.registry.RegistryBuilder; // because it makes the text go bold, but also because it stops anyone fiddling with your fields). "Why would I want to // initialise things within the registry events?", I hear you ask - well, for one, custom registries don't like it if // you haven't created the registry before you start calling constructors of classes extending IForgeRegistryEntry.Impl, -// and secondly, +// and secondly, you might want to initialise objects based on certain conditions - perhaps a config option, or whether +// another mod is installed. This, presumably, is why everyone at forge is encouraging us to use @ObjectHolder. @ObjectHolder(Wizardry.MODID) @Mod.EventBusSubscriber public final class Spells { diff --git a/src/main/java/electroblob/wizardry/spell/MindTrick.java b/src/main/java/electroblob/wizardry/spell/MindTrick.java index 0fb465b4..d2f5dae2 100644 --- a/src/main/java/electroblob/wizardry/spell/MindTrick.java +++ b/src/main/java/electroblob/wizardry/spell/MindTrick.java @@ -116,9 +116,9 @@ public class MindTrick extends Spell { if(event.getSource() != null && event.getSource().getTrueSource() instanceof EntityLivingBase){ // Cancels the mind trick effect if the creature takes damage // This has been moved to within an (event.getSource().getEntity() instanceof EntityLivingBase) check so it - // doesn't - // crash the game with a ConcurrentModificationException. If you think about it, mind trick only ought to be - // cancelled if something attacks the entity since potions, drowning, cacti etc. don't affect the targeting. + // doesn't crash the game with a ConcurrentModificationException. If you think about it, mind trick only + // ought to be cancelled if something attacks the entity since potions, drowning, cacti etc. don't affect the + // targeting. if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick)){ event.getEntityLiving().removePotionEffect(WizardryPotions.mind_trick); } diff --git a/src/main/java/electroblob/wizardry/spell/Petrify.java b/src/main/java/electroblob/wizardry/spell/Petrify.java index 53161178..b207fd34 100644 --- a/src/main/java/electroblob/wizardry/spell/Petrify.java +++ b/src/main/java/electroblob/wizardry/spell/Petrify.java @@ -119,8 +119,7 @@ public class Petrify extends Spell { } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, - world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); return true; } diff --git a/src/main/java/electroblob/wizardry/spell/PhaseStep.java b/src/main/java/electroblob/wizardry/spell/PhaseStep.java index 8900551e..c7f21d7b 100644 --- a/src/main/java/electroblob/wizardry/spell/PhaseStep.java +++ b/src/main/java/electroblob/wizardry/spell/PhaseStep.java @@ -36,9 +36,7 @@ public class PhaseStep extends Spell { // The maximum wall thickness as determined by the range multiplier. The + 0.5f is so that // weird float processing doesn't incorrectly round it down. - int maxThickness = 1 - + (int)((modifiers.get(WizardryItems.range_upgrade) - 1) / Constants.RANGE_INCREASE_PER_LEVEL - + 0.5f); + int maxThickness = 1 + (int)((modifiers.get(WizardryItems.range_upgrade) - 1) / Constants.RANGE_INCREASE_PER_LEVEL + 0.5f); if(rayTrace.sideHit.getAxis().isHorizontal()){ @@ -49,8 +47,7 @@ public class PhaseStep extends Spell { // Prevents the player from teleporting through unbreakable blocks, so they cannot cheat in other // mods' mazes and dungeons. - if((WizardryUtilities.isBlockUnbreakable(world, pos1) - || WizardryUtilities.isBlockUnbreakable(world, pos1.up())) + if((WizardryUtilities.isBlockUnbreakable(world, pos1) || WizardryUtilities.isBlockUnbreakable(world, pos1.up())) && !Wizardry.settings.teleportThroughUnbreakableBlocks) return false; diff --git a/src/main/java/electroblob/wizardry/util/IElementalDamage.java b/src/main/java/electroblob/wizardry/util/IElementalDamage.java index 9a22cf58..cf2a6c15 100644 --- a/src/main/java/electroblob/wizardry/util/IElementalDamage.java +++ b/src/main/java/electroblob/wizardry/util/IElementalDamage.java @@ -20,8 +20,10 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public interface IElementalDamage { + /** Returns the type of this damage, which determines how it interacts with different entities. */ DamageType getType(); - + /** Returns true is this damage is from a retaliatory effect (i.e. in response to other damage). Used to avoid + * infinite loops with retaliatory effects. */ boolean isRetaliatory(); @SubscribeEvent diff --git a/src/main/java/electroblob/wizardry/util/MagicDamage.java b/src/main/java/electroblob/wizardry/util/MagicDamage.java index bad5b85e..4df3bccb 100644 --- a/src/main/java/electroblob/wizardry/util/MagicDamage.java +++ b/src/main/java/electroblob/wizardry/util/MagicDamage.java @@ -33,8 +33,8 @@ import net.minecraft.util.EntityDamageSource; // A note on the use of the vanilla damagesources: // When using indirect damage sources, the SECOND argument is the original entity (i.e. the caster), and the -// FIRST argument is the actual projectile or whatever that does the damage. getEntity() will return -// the original entity, and getSourceOfDamage() will return the projectile. +// FIRST argument is the actual projectile or whatever that does the damage. getTrueSource() will return +// the original entity, and getImmediateSource() will return the projectile. // The vanilla approach to damage types is inconsistent, to say the least. Poison is simply 'magic', and relies on // EntityLivingBase.isPotionApplicable to determine whether an entity is affected or not. Wither, on the other hand, is diff --git a/src/main/java/electroblob/wizardry/util/WizardryUtilities.java b/src/main/java/electroblob/wizardry/util/WizardryUtilities.java index fd129af5..3ab2bf72 100644 --- a/src/main/java/electroblob/wizardry/util/WizardryUtilities.java +++ b/src/main/java/electroblob/wizardry/util/WizardryUtilities.java @@ -344,8 +344,7 @@ public final class WizardryUtilities { * defaults to {@link SoundCategory#PLAYERS}. */ public static void playSoundAtPlayer(EntityPlayer player, SoundEvent sound, float volume, float pitch){ - player.world.playSound(null, player.posX, player.posY, player.posZ, sound, SoundCategory.PLAYERS, volume, - pitch); + player.world.playSound(null, player.posX, player.posY, player.posZ, sound, SoundCategory.PLAYERS, volume, pitch); } /**