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