This commit is contained in:
2024-10-21 19:53:50 +02:00
parent 9b310bdcc7
commit df60129653
6 changed files with 301 additions and 42 deletions
@@ -2,7 +2,6 @@ package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import net.kyori.adventure.key.Key;
@@ -17,6 +16,28 @@ public class ReplantingEnchant implements EnchantioEnchant {
public static final Key KEY = Key.key("enchantio:replanting");
private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
private final boolean canGetFromEnchantingTable;
private final Set<TagEntry<ItemType>> supportedItemTags;
public ReplantingEnchant(
int anvilCost,
int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable,
Set<TagEntry<ItemType>> supportedItemTags
) {
this.anvilCost = anvilCost;
this.weight = weight;
this.minimumCost = minimumCost;
this.maximumCost = maximumCost;
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
this.supportedItemTags = supportedItemTags;
}
@Override
public Key getKey() {
return KEY;
@@ -29,7 +50,7 @@ public class ReplantingEnchant implements EnchantioEnchant {
@Override
public int getAnvilCost() {
return 1;
return anvilCost;
}
@Override
@@ -39,17 +60,17 @@ public class ReplantingEnchant implements EnchantioEnchant {
@Override
public int getWeight() {
return 10;
return weight;
}
@Override
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
return EnchantmentRegistryEntry.EnchantmentCost.of(1, 1);
return minimumCost;
}
@Override
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
return EnchantmentRegistryEntry.EnchantmentCost.of(65, 1);
return maximumCost;
}
@Override
@@ -59,7 +80,7 @@ public class ReplantingEnchant implements EnchantioEnchant {
@Override
public boolean canGetFromEnchantingTable() {
return true;
return canGetFromEnchantingTable;
}
@Override
@@ -69,9 +90,7 @@ public class ReplantingEnchant implements EnchantioEnchant {
@Override
public Set<TagEntry<ItemType>> getSupportedItems() {
return Set.of(
TagEntry.tagEntry(ItemTypeTagKeys.HOES)
);
return supportedItemTags;
}
}
@@ -2,7 +2,6 @@ package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import net.kyori.adventure.key.Key;
@@ -17,6 +16,28 @@ public class SoulboundEnchant implements EnchantioEnchant {
public static final Key KEY = Key.key("enchantio:soulbound");
private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
private final boolean canGetFromEnchantingTable;
private final Set<TagEntry<ItemType>> supportedItemTags;
public SoulboundEnchant(
int anvilCost,
int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable,
Set<TagEntry<ItemType>> supportedItemTags
) {
this.anvilCost = anvilCost;
this.weight = weight;
this.minimumCost = minimumCost;
this.maximumCost = maximumCost;
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
this.supportedItemTags = supportedItemTags;
}
@Override
public Key getKey() {
return KEY;
@@ -29,7 +50,7 @@ public class SoulboundEnchant implements EnchantioEnchant {
@Override
public int getAnvilCost() {
return 1;
return anvilCost;
}
@Override
@@ -39,17 +60,17 @@ public class SoulboundEnchant implements EnchantioEnchant {
@Override
public int getWeight() {
return 10;
return weight;
}
@Override
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
return EnchantmentRegistryEntry.EnchantmentCost.of(10, 1);
return minimumCost;
}
@Override
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
return EnchantmentRegistryEntry.EnchantmentCost.of(65, 1);
return maximumCost;
}
@Override
@@ -59,7 +80,7 @@ public class SoulboundEnchant implements EnchantioEnchant {
@Override
public boolean canGetFromEnchantingTable() {
return true;
return canGetFromEnchantingTable;
}
@Override
@@ -69,11 +90,7 @@ public class SoulboundEnchant implements EnchantioEnchant {
@Override
public Set<TagEntry<ItemType>> getSupportedItems() {
return Set.of(
TagEntry.tagEntry(ItemTypeTagKeys.ENCHANTABLE_ARMOR),
TagEntry.tagEntry(ItemTypeTagKeys.ENCHANTABLE_WEAPON),
TagEntry.tagEntry(ItemTypeTagKeys.ENCHANTABLE_MINING)
);
return supportedItemTags;
}
}
@@ -2,7 +2,6 @@ package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import net.kyori.adventure.key.Key;
@@ -17,6 +16,28 @@ public class TelepathyEnchant implements EnchantioEnchant {
public static final Key KEY = Key.key("enchantio:telepathy");
private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
private final boolean canGetFromEnchantingTable;
private final Set<TagEntry<ItemType>> supportedItemTags;
public TelepathyEnchant(
int anvilCost,
int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable,
Set<TagEntry<ItemType>> supportedItemTags
) {
this.anvilCost = anvilCost;
this.weight = weight;
this.minimumCost = minimumCost;
this.maximumCost = maximumCost;
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
this.supportedItemTags = supportedItemTags;
}
@Override
public Key getKey() {
return KEY;
@@ -29,7 +50,7 @@ public class TelepathyEnchant implements EnchantioEnchant {
@Override
public int getAnvilCost() {
return 1;
return anvilCost;
}
@Override
@@ -39,17 +60,17 @@ public class TelepathyEnchant implements EnchantioEnchant {
@Override
public int getWeight() {
return 5;
return weight;
}
@Override
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
return EnchantmentRegistryEntry.EnchantmentCost.of(15, 1);
return minimumCost;
}
@Override
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
return EnchantmentRegistryEntry.EnchantmentCost.of(65, 1);
return maximumCost;
}
@Override
@@ -59,7 +80,7 @@ public class TelepathyEnchant implements EnchantioEnchant {
@Override
public boolean canGetFromEnchantingTable() {
return true;
return canGetFromEnchantingTable;
}
@Override
@@ -69,9 +90,7 @@ public class TelepathyEnchant implements EnchantioEnchant {
@Override
public Set<TagEntry<ItemType>> getSupportedItems() {
return Set.of(
TagEntry.tagEntry(ItemTypeTagKeys.ENCHANTABLE_MINING)
);
return supportedItemTags;
}
}