This commit is contained in:
Electroblob
2018-02-26 18:37:52 +00:00
parent 13444f1de3
commit 6f776fbae6
8 changed files with 15 additions and 17 deletions
@@ -171,7 +171,7 @@ public final class WizardryEventHandler {
@SubscribeEvent @SubscribeEvent
public static void onLivingAttackEvent(LivingAttackEvent event){ 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 if(!Wizardry.settings.friendlyFire && event.getSource() != null
&& event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityPlayer && event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityPlayer
&& event.getSource() instanceof IElementalDamage){ && event.getSource() instanceof IElementalDamage){
@@ -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 // 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 // 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, // 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) @ObjectHolder(Wizardry.MODID)
@Mod.EventBusSubscriber @Mod.EventBusSubscriber
public final class Spells { public final class Spells {
@@ -116,9 +116,9 @@ public class MindTrick extends Spell {
if(event.getSource() != null && event.getSource().getTrueSource() instanceof EntityLivingBase){ if(event.getSource() != null && event.getSource().getTrueSource() instanceof EntityLivingBase){
// Cancels the mind trick effect if the creature takes damage // 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 // This has been moved to within an (event.getSource().getEntity() instanceof EntityLivingBase) check so it
// doesn't // doesn't crash the game with a ConcurrentModificationException. If you think about it, mind trick only
// crash the game with a ConcurrentModificationException. If you think about it, mind trick only ought to be // ought to be cancelled if something attacks the entity since potions, drowning, cacti etc. don't affect the
// cancelled if something attacks the entity since potions, drowning, cacti etc. don't affect the targeting. // targeting.
if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick)){ if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick)){
event.getEntityLiving().removePotionEffect(WizardryPotions.mind_trick); event.getEntityLiving().removePotionEffect(WizardryPotions.mind_trick);
} }
@@ -119,8 +119,7 @@ public class Petrify extends Spell {
} }
} }
caster.swingArm(hand); caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
world.rand.nextFloat() * 0.2F + 1.0F);
return true; return true;
} }
@@ -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 // 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. // weird float processing doesn't incorrectly round it down.
int maxThickness = 1 int maxThickness = 1 + (int)((modifiers.get(WizardryItems.range_upgrade) - 1) / Constants.RANGE_INCREASE_PER_LEVEL + 0.5f);
+ (int)((modifiers.get(WizardryItems.range_upgrade) - 1) / Constants.RANGE_INCREASE_PER_LEVEL
+ 0.5f);
if(rayTrace.sideHit.getAxis().isHorizontal()){ 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 // Prevents the player from teleporting through unbreakable blocks, so they cannot cheat in other
// mods' mazes and dungeons. // mods' mazes and dungeons.
if((WizardryUtilities.isBlockUnbreakable(world, pos1) if((WizardryUtilities.isBlockUnbreakable(world, pos1) || WizardryUtilities.isBlockUnbreakable(world, pos1.up()))
|| WizardryUtilities.isBlockUnbreakable(world, pos1.up()))
&& !Wizardry.settings.teleportThroughUnbreakableBlocks) && !Wizardry.settings.teleportThroughUnbreakableBlocks)
return false; return false;
@@ -20,8 +20,10 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber @Mod.EventBusSubscriber
public interface IElementalDamage { public interface IElementalDamage {
/** Returns the type of this damage, which determines how it interacts with different entities. */
DamageType getType(); 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(); boolean isRetaliatory();
@SubscribeEvent @SubscribeEvent
@@ -33,8 +33,8 @@ import net.minecraft.util.EntityDamageSource;
// A note on the use of the vanilla damagesources: // 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 // 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 // FIRST argument is the actual projectile or whatever that does the damage. getTrueSource() will return
// the original entity, and getSourceOfDamage() will return the projectile. // 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 // 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 // EntityLivingBase.isPotionApplicable to determine whether an entity is affected or not. Wither, on the other hand, is
@@ -344,8 +344,7 @@ public final class WizardryUtilities {
* defaults to {@link SoundCategory#PLAYERS}. * defaults to {@link SoundCategory#PLAYERS}.
*/ */
public static void playSoundAtPlayer(EntityPlayer player, SoundEvent sound, float volume, float pitch){ 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, player.world.playSound(null, player.posX, player.posY, player.posZ, sound, SoundCategory.PLAYERS, volume, pitch);
pitch);
} }
/** /**