diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java index b51b286d..4092bdfc 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java @@ -225,6 +225,7 @@ public class EcoEnchants { public static final EcoEnchant BLOCK_BREATHER = new BlockBreather(); public static final EcoEnchant VOLTAGE = new Voltage(); public static final EcoEnchant TRANSFUSE = new Transfuse(); + public static final EcoEnchant INACCURACY_CURSE = new InaccuracyCurse(); /** * Get all registered {@link EcoEnchant}s diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java new file mode 100644 index 00000000..4523726b --- /dev/null +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java @@ -0,0 +1,48 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; +import com.willfp.ecoenchants.nms.Target; +import com.willfp.ecoenchants.util.Rand; +import org.bukkit.Sound; +import org.bukkit.SoundCategory; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.util.Vector; + +public class InaccuracyCurse extends EcoEnchant { + public InaccuracyCurse() { + super( + new EcoEnchantBuilder("inaccuracy_curse", EnchantmentType.CURSE, Target.Applicable.BOW, 4.0) + ); + } + + // START OF LISTENERS + + @EventHandler + public void onShoot(EntityShootBowEvent event) { + if (event.getProjectile().getType() != EntityType.ARROW) + return; + + if (!(event.getEntity() instanceof Player)) + return; + + Player player = (Player) event.getEntity(); + + if (!EnchantChecks.mainhand(player, this)) return; + + double spread = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "spread"); + + Vector velocity = event.getProjectile().getVelocity().clone(); + + velocity.add(new Vector(Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread))); + event.getProjectile().setVelocity(velocity); + } +} diff --git a/Plugin/src/main/resources/enchants/curse/breaklessnesscurse.yml b/Plugin/src/main/resources/enchants/curse/breaklessnesscurse.yml index d3cc69af..c3ae2099 100644 --- a/Plugin/src/main/resources/enchants/curse/breaklessnesscurse.yml +++ b/Plugin/src/main/resources/enchants/curse/breaklessnesscurse.yml @@ -9,7 +9,7 @@ name: "Curse of Breaklessness" description: Chance to prevent block breaking. obtaining: - table: true + table: false villager: true loot: true rarity: legendary diff --git a/Plugin/src/main/resources/enchants/curse/inaccuracycurse.yml b/Plugin/src/main/resources/enchants/curse/inaccuracycurse.yml new file mode 100644 index 00000000..d518cd44 --- /dev/null +++ b/Plugin/src/main/resources/enchants/curse/inaccuracycurse.yml @@ -0,0 +1,22 @@ +# +# Curse of Inaccuracy EcoEnchant +# + +config-version: 4.0 # Don't edit this. + +name: "Curse of Inaccuracy" + +description: Arrows fire incorrectly. + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + grindstoneable: true + conflicts: [] + +config: + spread: 0.2 \ No newline at end of file diff --git a/Plugin/src/main/resources/enchants/curse/misfortunecurse.yml b/Plugin/src/main/resources/enchants/curse/misfortunecurse.yml index c5b6b6a1..08098d95 100644 --- a/Plugin/src/main/resources/enchants/curse/misfortunecurse.yml +++ b/Plugin/src/main/resources/enchants/curse/misfortunecurse.yml @@ -9,7 +9,7 @@ name: "Curse of Misfortune" description: Chance for blocks to not drop items. obtaining: - table: true + table: false villager: true loot: true rarity: legendary diff --git a/Plugin/src/main/resources/plugin.yml b/Plugin/src/main/resources/plugin.yml index 65d986bd..820018dc 100644 --- a/Plugin/src/main/resources/plugin.yml +++ b/Plugin/src/main/resources/plugin.yml @@ -244,6 +244,7 @@ permissions: ecoenchants.fromtable.blockbreather: true ecoenchants.fromtable.voltage: true ecoenchants.fromtable.transfuse: true + ecoenchants.fromtable.inaccuracycurse: true ecoenchants.updateannounce: description: Informs admins of a new update @@ -848,4 +849,7 @@ permissions: default: true ecoenchants.fromtable.transfuse: description: Allows getting transfuse from an enchanting table + default: true + ecoenchants.fromtable.inaccuracycurse: + description: Allows getting curse of inaccuracy from an enchanting table default: true \ No newline at end of file