diff --git a/src/main/java/electroblob/wizardry/Settings.java b/src/main/java/electroblob/wizardry/Settings.java index c7b8a34e..df0b5b9e 100644 --- a/src/main/java/electroblob/wizardry/Settings.java +++ b/src/main/java/electroblob/wizardry/Settings.java @@ -179,6 +179,8 @@ public final class Settings { * velocity-based one. */ public boolean replaceVanillaFallDamage = true; // TODO: This should be synced + /** [Server-only] Whether to tweak the blindness effect to reduce follow distance when used on non-players. */ + public boolean blindnessTweak = true; /** [Server-only] Whether using bonemeal on grass blocks has a chance to grow crystal flowers. */ public boolean bonemealGrowsCrystalFlowers = true; /** @@ -704,6 +706,13 @@ public final class Settings { replaceVanillaFallDamage = property.getBoolean(); propOrder.add(property.getName()); + property = config.get(TWEAKS_CATEGORY, "blindnessTweak", true, + "Whether to tweak the blindness effect to reduce follow distance when used on non-players. This automatically disables itself in favour of Potion Core's implementation if installed."); + property.setLanguageKey("config." + Wizardry.MODID + ".blindness_tweak"); + Wizardry.proxy.setToNamedBooleanEntry(property); + blindnessTweak = property.getBoolean(); + propOrder.add(property.getName()); + property = config.get(TWEAKS_CATEGORY, "mobLootTableWhitelist", new String[0], "Whitelist for loot tables to inject additional mob drops (as specified in loot_tables/entities/mob_additions.json) into. Wizardry makes a best guess as to which loot tables belong to hostile mobs, but this may not always be correct or appropriate; add loot table locations (not entity IDs) to this list to manually include them."); property.setLanguageKey("config." + Wizardry.MODID + ".mob_loot_table_whitelist"); property.setRequiresMcRestart(true); diff --git a/src/main/java/electroblob/wizardry/WizardryEventHandler.java b/src/main/java/electroblob/wizardry/WizardryEventHandler.java index 16d2b394..29f9dcf0 100644 --- a/src/main/java/electroblob/wizardry/WizardryEventHandler.java +++ b/src/main/java/electroblob/wizardry/WizardryEventHandler.java @@ -26,6 +26,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumHand; @@ -192,16 +193,27 @@ public final class WizardryEventHandler { @SubscribeEvent public static void onLivingSetAttackTargetEvent(LivingSetAttackTargetEvent event){ - if(event.getTarget() != null && event.getEntityLiving() instanceof EntityLiving - && event.getTarget().isPotionActive(WizardryPotions.muffle)){ + if(event.getEntityLiving() instanceof EntityLiving && event.getTarget() != null){ - Vec3d vec = event.getTarget().getPositionEyes(1).subtract(event.getEntity().getPositionEyes(1)); - // Find the angle between the direction the mob is looking and the direction the player is in - // Angle between a and b = acos((a.b) / (|a|*|b|)) - double angle = Math.acos(vec.dotProduct(event.getEntity().getLookVec()) / vec.length()); - System.out.println(angle); - // If the player is not within the 144-degree arc in front of the mob, it won't detect them - if(angle > 0.4 * Math.PI){ + // Muffle + if(event.getTarget().isPotionActive(WizardryPotions.muffle)){ + + Vec3d vec = event.getTarget().getPositionEyes(1).subtract(event.getEntity().getPositionEyes(1)); + // Find the angle between the direction the mob is looking and the direction the player is in + // Angle between a and b = acos((a.b) / (|a|*|b|)) + double angle = Math.acos(vec.dotProduct(event.getEntity().getLookVec()) / vec.length()); + System.out.println(angle); + // If the player is not within the 144-degree arc in front of the mob, it won't detect them + if(angle > 0.4 * Math.PI){ + ((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") + && Wizardry.settings.blindnessTweak && event.getTarget().getDistanceSq(event.getEntity()) > 2.5 * 2.5){ + // Can't detect anything more than 2.5 blocks away (roughly the player's view distance when blinded) ((EntityLiving)event.getEntityLiving()).setAttackTarget(null); } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntitySmokeBomb.java b/src/main/java/electroblob/wizardry/entity/projectile/EntitySmokeBomb.java index 9033963e..f19e6453 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntitySmokeBomb.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntitySmokeBomb.java @@ -1,13 +1,11 @@ package electroblob.wizardry.entity.projectile; import electroblob.wizardry.registry.Spells; -import electroblob.wizardry.registry.WizardryPotions; import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.spell.Spell; import electroblob.wizardry.util.EntityUtils; import electroblob.wizardry.util.ParticleBuilder; import electroblob.wizardry.util.ParticleBuilder.Type; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.MobEffects; import net.minecraft.potion.PotionEffect; @@ -64,14 +62,7 @@ public class EntitySmokeBomb extends EntityBomb { for(EntityLivingBase target : targets){ if(target != this.getThrower()){ - // Gives the target blindness, and mind trick if it's not a player (since this has the desired - // effect of preventing targeting) target.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, duration, 0)); - - if(target instanceof EntityLiving){ - ((EntityLiving)target).setAttackTarget(null); - target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, duration, 0)); - } } } diff --git a/src/main/resources/assets/ebwizardry/lang/en_gb.lang b/src/main/resources/assets/ebwizardry/lang/en_gb.lang index 6e8d87d6..9c06ce6a 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_gb.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_gb.lang @@ -1359,6 +1359,8 @@ config.ebwizardry.replace_vanilla_fall_damage=Replace Vanilla Fall Damage config.ebwizardry.replace_vanilla_fall_damage.tooltip=Whether to replace Minecraft's distance-based fall damage calculation with an equivalent, velocity-based one. This is done such that mobs in freefall will take exactly the same damage as normal, so it will not break falling-based mob farms. Disable this if you experience falling-related weirdness! If this is disabled, some spells revert to a more simplistic method of resetting the player's fall damage in certain cases. config.ebwizardry.replace_vanilla_fall_damage.true=Yes - it's parkour time config.ebwizardry.replace_vanilla_fall_damage.false=No - break my legs normally +config.ebwizardry.blindness_tweak=Blindness Tweak +config.ebwizardry.blindness_tweak.tooltip=Whether to tweak the blindness effect to reduce follow distance when used on non-players. This automatically disables itself in favour of Potion Core's implementation if installed. config.ebwizardry.mob_loot_table_whitelist=Mob Loot Table Whitelist config.ebwizardry.mob_loot_table_whitelist.tooltip=Whitelist for loot tables to inject additional mob drops (as specified in loot_tables/entities/mob_additions.json) into. Wizardry makes a best guess as to which loot tables belong to hostile mobs, but this may not always be correct or appropriate; add loot table locations (not entity IDs) to this list to manually include them. config.ebwizardry.mob_loot_table_blacklist=Mob Loot Table Blacklist diff --git a/src/main/resources/assets/ebwizardry/lang/en_us.lang b/src/main/resources/assets/ebwizardry/lang/en_us.lang index f34add33..b633dd56 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_us.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_us.lang @@ -1359,6 +1359,8 @@ config.ebwizardry.replace_vanilla_fall_damage=Replace Vanilla Fall Damage config.ebwizardry.replace_vanilla_fall_damage.tooltip=Whether to replace Minecraft's distance-based fall damage calculation with an equivalent, velocity-based one. This is done such that mobs in freefall will take exactly the same damage as normal, so it will not break falling-based mob farms. Disable this if you experience falling-related weirdness! If this is disabled, some spells revert to a more simplistic method of resetting the player's fall damage in certain cases. config.ebwizardry.replace_vanilla_fall_damage.true=Yes - it's parkour time config.ebwizardry.replace_vanilla_fall_damage.false=No - break my legs normally +config.ebwizardry.blindness_tweak=Blindness Tweak +config.ebwizardry.blindness_tweak.tooltip=Whether to tweak the blindness effect to reduce follow distance when used on non-players. This automatically disables itself in favour of Potion Core's implementation if installed. config.ebwizardry.mob_loot_table_whitelist=Mob Loot Table Whitelist config.ebwizardry.mob_loot_table_whitelist.tooltip=Whitelist for loot tables to inject additional mob drops (as specified in loot_tables/entities/mob_additions.json) into. Wizardry makes a best guess as to which loot tables belong to hostile mobs, but this may not always be correct or appropriate; add loot table locations (not entity IDs) to this list to manually include them. config.ebwizardry.mob_loot_table_blacklist=Mob Loot Table Blacklist