mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-12 06:06:55 +00:00
allow modification of the arrow spread for volley enchant
This commit is contained in:
@@ -31,6 +31,7 @@ public class VolleyEnchant implements EnchantioEnchant {
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
private final double spread;
|
||||
|
||||
public VolleyEnchant(
|
||||
int anvilCost,
|
||||
@@ -41,7 +42,8 @@ public class VolleyEnchant implements EnchantioEnchant {
|
||||
Set<TagEntry<ItemType>> supportedItemTags,
|
||||
Set<EquipmentSlotGroup> activeSlots,
|
||||
int maxLevel,
|
||||
int additionalArrowsPerLevel
|
||||
int additionalArrowsPerLevel,
|
||||
double spread
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
@@ -51,6 +53,7 @@ public class VolleyEnchant implements EnchantioEnchant {
|
||||
this.maxLevel = maxLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
this.additionalArrowsPerLevel = additionalArrowsPerLevel;
|
||||
this.spread = spread;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
@@ -80,6 +83,10 @@ public class VolleyEnchant implements EnchantioEnchant {
|
||||
return additionalArrowsPerLevel;
|
||||
}
|
||||
|
||||
public double getSpread() {
|
||||
return spread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
@@ -138,7 +145,8 @@ public class VolleyEnchant implements EnchantioEnchant {
|
||||
)
|
||||
)),
|
||||
EnchantioConfig.getInt(configurationSection, "maxLevel", 3),
|
||||
EnchantioConfig.getInt(configurationSection, "additionalArrowsPerLevel", 1)
|
||||
EnchantioConfig.getInt(configurationSection, "additionalArrowsPerLevel", 1),
|
||||
EnchantioConfig.getDouble(configurationSection, "spread", 0.5)
|
||||
);
|
||||
|
||||
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package me.youhavetrouble.enchantio.listeners;
|
||||
import io.papermc.paper.registry.RegistryAccess;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import me.youhavetrouble.enchantio.EnchantioConfig;
|
||||
import me.youhavetrouble.enchantio.enchants.EnchantioEnchant;
|
||||
import me.youhavetrouble.enchantio.enchants.ExecutionerEnchant;
|
||||
import me.youhavetrouble.enchantio.enchants.VolleyEnchant;
|
||||
import org.bukkit.Registry;
|
||||
@@ -43,10 +42,10 @@ public class VolleyListener implements Listener {
|
||||
int level = bow.getEnchantmentLevel(volley);
|
||||
if (level <= 0) return;
|
||||
if (!(EnchantioConfig.ENCHANTS.get(ExecutionerEnchant.KEY) instanceof VolleyEnchant volleyEnchant)) return;
|
||||
double spread = volleyEnchant.getSpread();
|
||||
if (projectileEntity instanceof Arrow arrow) {
|
||||
for (int i = 0; i < level * volleyEnchant.getAdditionalArrowsPerLevel(); i++) {
|
||||
Vector velocity = arrow.getVelocity();
|
||||
double spread = 0.5;
|
||||
double spreadX = (random.nextDouble() - 0.5) * spread;
|
||||
double spreadY = (random.nextDouble() - 0.5) * spread;
|
||||
double spreadZ = (random.nextDouble() - 0.5) * spread;
|
||||
@@ -68,7 +67,6 @@ public class VolleyListener implements Listener {
|
||||
arrow.setPickupStatus(AbstractArrow.PickupStatus.CREATIVE_ONLY);
|
||||
for (int i = 0; i < level; i++) {
|
||||
Vector velocity = arrow.getVelocity();
|
||||
double spread = 0.5; // Adjust the spread value as needed
|
||||
double spreadX = (random.nextDouble() - 0.5) * spread;
|
||||
double spreadY = (random.nextDouble() - 0.5) * spread;
|
||||
double spreadZ = (random.nextDouble() - 0.5) * spread;
|
||||
|
||||
Reference in New Issue
Block a user