Skip to content

Commit

Permalink
Enchantment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazzuk committed Nov 11, 2021
1 parent 5f5a2d2 commit 528390c
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.cloudburstmc.api.enchantment;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum EnchantmentRarity {
COMMON(10),
UNCOMMON(5),
RARE(2),
VERY_RARE(1);

private final int weight;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package org.cloudburstmc.api.enchantment;

public enum EnchantmentTarget {
ALL,
ARMOR,
ARMOR_CHEST,
ARMOR_FEET,
ARMOR_HEAD,
ARMOR_TORSO,
ARMOR_LEGS,
ARMOR_FEET,
SWORD,
DIGGER,
FISHING_ROD,
BREAKABLE,
BOW,
WEARABLE,
BREAKABLE,
CROSSBOW,
FISHING_ROD,
TOOL,
TRIDENT,
CROSSBOW

VANISHABLE,
WEAPON,
WEARABLE
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class EnchantmentType {
private final short id;
private final Identifier type;
private final int maxLevel;
private final int weight;
private final EnchantmentRarity rarity;
private final boolean treasure;
private final boolean cursed;
private final EnchantmentTarget target;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,46 @@
import lombok.experimental.UtilityClass;
import org.cloudburstmc.api.util.Identifiers;

import static org.cloudburstmc.api.enchantment.EnchantmentRarity.*;
import static org.cloudburstmc.api.enchantment.EnchantmentTarget.*;

@UtilityClass
public class EnchantmentTypes {

public static final EnchantmentType PROTECTION = EnchantmentType.builder().id((short) 0).type(Identifiers.PROTECTION).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType FIRE_PROTECTION = EnchantmentType.builder().id((short) 1).type(Identifiers.FIRE_PROTECTION).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType FALL_PROTECTION = EnchantmentType.builder().id((short) 2).type(Identifiers.FALL_PROTECTION).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType EXPLOSION_PROTECTION = EnchantmentType.builder().id((short) 3).type(Identifiers.EXPLOSION_PROTECTION).maxLevel(5).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType PROJECTILE_PROTECTION = EnchantmentType.builder().id((short) 4).type(Identifiers.PROJECTILE_PROTECTION).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType THORNS = EnchantmentType.builder().id((short) 5).type(Identifiers.THORNS).maxLevel(3).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType WATER_BREATHING = EnchantmentType.builder().id((short) 6).type(Identifiers.RESPIRATION).maxLevel(3).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType WATER_WALKER = EnchantmentType.builder().id((short) 7).type(Identifiers.WATER_WALKER).maxLevel(3).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType WATER_WORKER = EnchantmentType.builder().id((short) 8).type(Identifiers.WATER_WORKER).maxLevel(1).weight(2).target(EnchantmentTarget.ARMOR_HEAD).build();
public static final EnchantmentType DAMAGE_SHARPNESS = EnchantmentType.builder().id((short) 9).type(Identifiers.DAMAGE_SHARPNESS).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType DAMAGE_SMITE = EnchantmentType.builder().id((short) 10).type(Identifiers.DAMAGE_SMITE).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType DAMAGE_ARTHOPODS = EnchantmentType.builder().id((short) 11).type(Identifiers.DAMAGE_ARTHOPODS).maxLevel(5).weight(5).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType KNOCKBACK = EnchantmentType.builder().id((short) 12).type(Identifiers.KNOCKBACK).maxLevel(2).weight(5).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType FIRE_ASPECT = EnchantmentType.builder().id((short) 13).type(Identifiers.FIRE_ASPECT).maxLevel(2).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType LOOTING = EnchantmentType.builder().id((short) 14).type(Identifiers.LOOTING).maxLevel(3).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType EFFICIENCY = EnchantmentType.builder().id((short) 15).type(Identifiers.EFFICIENCY).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType SILK_TOUCH = EnchantmentType.builder().id((short) 16).type(Identifiers.SILK_TOUCH).maxLevel(1).weight(1).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType DURABILITY = EnchantmentType.builder().id((short) 17).type(Identifiers.DURABILITY).maxLevel(3).weight(5).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType FORTUNE = EnchantmentType.builder().id((short) 18).type(Identifiers.FORTUNE).maxLevel(5).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType BOW_POWER = EnchantmentType.builder().id((short) 19).type(Identifiers.BOW_POWER).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType BOW_PUNCH = EnchantmentType.builder().id((short) 20).type(Identifiers.BOW_PUNCH).maxLevel(2).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType BOW_FLAME = EnchantmentType.builder().id((short) 21).type(Identifiers.BOW_FLAME).maxLevel(1).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType BOW_INFINITY = EnchantmentType.builder().id((short) 22).type(Identifiers.BOW_INFINITY).maxLevel(1).weight(1).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType LUCK = EnchantmentType.builder().id((short) 23).type(Identifiers.LUCK).maxLevel(3).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType LURE = EnchantmentType.builder().id((short) 24).type(Identifiers.LURE).maxLevel(3).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType FROST_WALKER = EnchantmentType.builder().id((short) 25).type(Identifiers.FROST_WALKER).maxLevel(2).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType MENDING = EnchantmentType.builder().id((short) 26).type(Identifiers.MENDING).maxLevel(1).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType BINDING_CURSE = EnchantmentType.builder().id((short) 27).type(Identifiers.BINDING_CURSE).maxLevel(1).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType VANISHING_CURSE = EnchantmentType.builder().id((short) 28).type(Identifiers.VANISHING_CURSE).maxLevel(5).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType TRIDENT_IMPALING = EnchantmentType.builder().id((short) 29).type(Identifiers.TRIDENT_IMPALING).maxLevel(5).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType TRIDENT_RIPTIDE = EnchantmentType.builder().id((short) 30).type(Identifiers.TRIDENT_RIPTIDE).maxLevel(5).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType TRIDENT_LOYALTY = EnchantmentType.builder().id((short) 31).type(Identifiers.TRIDENT_LOYALTY).maxLevel(5).weight(5).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType TRIDENT_CHANNELING = EnchantmentType.builder().id((short) 32).type(Identifiers.TRIDENT_CHANNELING).maxLevel(5).weight(1).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType CROSSBOW_MULTISHOT = EnchantmentType.builder().id((short) 33).type(Identifiers.CROSSBOW_MULTISHOT).maxLevel(5).weight(2).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType CROSSBOW_PIERCING = EnchantmentType.builder().id((short) 34).type(Identifiers.CROSSBOW_PIERCING).maxLevel(5).weight(10).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType CROSSBOW_QUICK_CHARGE = EnchantmentType.builder().id((short) 35).type(Identifiers.CROSSBOW_QUICK_CHARGE).maxLevel(5).weight(5).target(EnchantmentTarget.ARMOR).build();
public static final EnchantmentType PROTECTION = EnchantmentType.builder().id((short) 0).type(Identifiers.PROTECTION).maxLevel(4).rarity(COMMON).target(ARMOR).build();
public static final EnchantmentType FIRE_PROTECTION = EnchantmentType.builder().id((short) 1).type(Identifiers.FIRE_PROTECTION).maxLevel(4).rarity(UNCOMMON).target(ARMOR).build();
public static final EnchantmentType FEATHER_FALLING = EnchantmentType.builder().id((short) 2).type(Identifiers.FEATHER_FALLING).maxLevel(4).rarity(UNCOMMON).target(ARMOR_FEET).build();
public static final EnchantmentType BLAST_PROTECTION = EnchantmentType.builder().id((short) 3).type(Identifiers.BLAST_PROTECTION).maxLevel(4).rarity(RARE).target(ARMOR).build();
public static final EnchantmentType PROJECTILE_PROTECTION = EnchantmentType.builder().id((short) 4).type(Identifiers.PROJECTILE_PROTECTION).maxLevel(4).rarity(UNCOMMON).target(ARMOR).build();
public static final EnchantmentType THORNS = EnchantmentType.builder().id((short) 5).type(Identifiers.THORNS).maxLevel(3).rarity(VERY_RARE).target(ARMOR).build();
public static final EnchantmentType RESPIRATION = EnchantmentType.builder().id((short) 6).type(Identifiers.RESPIRATION).maxLevel(3).rarity(RARE).target(ARMOR_HEAD).build();
public static final EnchantmentType DEPTH_STRIDER = EnchantmentType.builder().id((short) 7).type(Identifiers.DEPTH_STRIDER).maxLevel(3).rarity(RARE).target(ARMOR_FEET).build();
public static final EnchantmentType AQUA_AFFINITY = EnchantmentType.builder().id((short) 8).type(Identifiers.AQUA_AFFINITY).maxLevel(1).rarity(RARE).target(ARMOR_HEAD).build();
public static final EnchantmentType SHARPNESS = EnchantmentType.builder().id((short) 9).type(Identifiers.SHARPNESS).maxLevel(5).rarity(COMMON).target(WEAPON).build();
public static final EnchantmentType SMITE = EnchantmentType.builder().id((short) 10).type(Identifiers.SMITE).maxLevel(5).rarity(UNCOMMON).target(WEAPON).build();
public static final EnchantmentType BANE_OF_ARTHROPODS = EnchantmentType.builder().id((short) 11).type(Identifiers.BANE_OF_ARTHROPODS).maxLevel(5).rarity(UNCOMMON).target(WEAPON).build();
public static final EnchantmentType KNOCKBACK = EnchantmentType.builder().id((short) 12).type(Identifiers.KNOCKBACK).maxLevel(2).rarity(UNCOMMON).target(WEAPON).build();
public static final EnchantmentType FIRE_ASPECT = EnchantmentType.builder().id((short) 13).type(Identifiers.FIRE_ASPECT).maxLevel(2).rarity(RARE).target(WEAPON).build();
public static final EnchantmentType LOOTING = EnchantmentType.builder().id((short) 14).type(Identifiers.LOOTING).maxLevel(3).rarity(RARE).target(WEAPON).build();
public static final EnchantmentType EFFICIENCY = EnchantmentType.builder().id((short) 15).type(Identifiers.EFFICIENCY).maxLevel(5).rarity(COMMON).target(TOOL).build();
public static final EnchantmentType SILK_TOUCH = EnchantmentType.builder().id((short) 16).type(Identifiers.SILK_TOUCH).maxLevel(1).rarity(VERY_RARE).target(TOOL).build();
public static final EnchantmentType UNBREAKING = EnchantmentType.builder().id((short) 17).type(Identifiers.UNBREAKING).maxLevel(3).rarity(UNCOMMON).target(BREAKABLE).build();
public static final EnchantmentType FORTUNE = EnchantmentType.builder().id((short) 18).type(Identifiers.FORTUNE).maxLevel(3).rarity(RARE).target(TOOL).build();
public static final EnchantmentType POWER = EnchantmentType.builder().id((short) 19).type(Identifiers.POWER).maxLevel(5).rarity(COMMON).target(BOW).build();
public static final EnchantmentType PUNCH = EnchantmentType.builder().id((short) 20).type(Identifiers.PUNCH).maxLevel(2).rarity(RARE).target(BOW).build();
public static final EnchantmentType FLAME = EnchantmentType.builder().id((short) 21).type(Identifiers.FLAME).maxLevel(1).rarity(RARE).target(BOW).build();
public static final EnchantmentType INFINITY = EnchantmentType.builder().id((short) 22).type(Identifiers.INFINITY).maxLevel(1).rarity(VERY_RARE).target(BOW).build();
public static final EnchantmentType LUCK_OF_THE_SEA = EnchantmentType.builder().id((short) 23).type(Identifiers.LUCK_OF_THE_SEA).maxLevel(3).rarity(RARE).target(FISHING_ROD).build();
public static final EnchantmentType LURE = EnchantmentType.builder().id((short) 24).type(Identifiers.LURE).maxLevel(3).rarity(RARE).target(FISHING_ROD).build();
public static final EnchantmentType FROST_WALKER = EnchantmentType.builder().id((short) 25).type(Identifiers.FROST_WALKER).maxLevel(2).rarity(RARE).treasure(true).target(ARMOR_FEET).build();
public static final EnchantmentType MENDING = EnchantmentType.builder().id((short) 26).type(Identifiers.MENDING).maxLevel(1).rarity(RARE).treasure(true).target(BREAKABLE).build();
public static final EnchantmentType BINDING = EnchantmentType.builder().id((short) 27).type(Identifiers.BINDING).maxLevel(1).rarity(VERY_RARE).treasure(true).cursed(true).target(WEARABLE).build();
public static final EnchantmentType VANISHING = EnchantmentType.builder().id((short) 28).type(Identifiers.VANISHING).maxLevel(1).rarity(VERY_RARE).treasure(true).cursed(true).target(VANISHABLE).build();
public static final EnchantmentType IMPALING = EnchantmentType.builder().id((short) 29).type(Identifiers.IMPALING).maxLevel(5).rarity(RARE).target(TRIDENT).build();
public static final EnchantmentType RIPTIDE = EnchantmentType.builder().id((short) 30).type(Identifiers.RIPTIDE).maxLevel(3).rarity(RARE).target(TRIDENT).build();
public static final EnchantmentType LOYALTY = EnchantmentType.builder().id((short) 31).type(Identifiers.LOYALTY).maxLevel(3).rarity(UNCOMMON).target(TRIDENT).build();
public static final EnchantmentType CHANNELING = EnchantmentType.builder().id((short) 32).type(Identifiers.CHANNELING).maxLevel(1).rarity(VERY_RARE).target(TRIDENT).build();
public static final EnchantmentType MULTISHOT = EnchantmentType.builder().id((short) 33).type(Identifiers.MULTISHOT).maxLevel(1).rarity(RARE).target(CROSSBOW).build();
public static final EnchantmentType PIERCING = EnchantmentType.builder().id((short) 34).type(Identifiers.PIERCING).maxLevel(4).rarity(COMMON).target(CROSSBOW).build();
public static final EnchantmentType QUICK_CHARGE = EnchantmentType.builder().id((short) 35).type(Identifiers.QUICK_CHARGE).maxLevel(3).rarity(UNCOMMON).target(CROSSBOW).build();
public static final EnchantmentType SOUL_SPEED = EnchantmentType.builder().id((short) 36).type(Identifiers.SOUL_SPEED).maxLevel(3).rarity(VERY_RARE).treasure(true).target(ARMOR_FEET).build();
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package org.cloudburstmc.api.enchantment.behavior;

import org.cloudburstmc.api.enchantment.EnchantmentInstance;
import org.cloudburstmc.api.enchantment.EnchantmentRarity;
import org.cloudburstmc.api.entity.Entity;
import org.cloudburstmc.api.event.entity.EntityDamageEvent;
import org.cloudburstmc.api.item.ItemStack;

public abstract class EnchantmentBehavior {

public EnchantmentRarity getRarity(EnchantmentInstance enchantment) {
return enchantment.getType().getRarity();
}

public int getWeight(EnchantmentInstance enchantment) {
return enchantment.getType().getWeight();
return this.getRarity(enchantment).getWeight();
}

public int getMaxLevel(EnchantmentInstance enchantment) {
Expand Down
Loading

0 comments on commit 528390c

Please sign in to comment.