indoorgoose

Create an item called Infuser

A mace enchanted with: Wind Burst 1, Density 5, Fire Aspect 2, Unbreaking 3 and Mending 1. (Item name color purple)

Every time the mace is used when killing any entity such as mobs or players, infuser gains a level of fusion and plays minecraft:block.vault.open_shutter master @a ~ ~ ~ 1 1 and minecraft:copper_fire_flame ~ ~1.5 ~ 0.4 0.6 0.4 0.1 30, and also minecraft:block.trial_spawner.spawn_mob master @a ~ ~ ~ 1 1

Fusion level 0: Infuser acts like a normal mace with 0 modifications.

Fusion level 1: Nothing changes, infuser is still the same as fusion level 1, but when entity is killed by infuser and gaining fusion level to enter fusion level 1, item name turns to orange.

Fusion level 2: Item name change to light red and infuser gains a rise of attack speed increase its attack speed to 2.

Fusion level 3: Item name change to dark red and infuser becomes overloaded. Once in the overloading state smoke particles radiant off of it. It also plays an alarm of note blocks above spruce log every 5 ticks. Once entering overload, next attack caused by the infuser instantly deals 30 health to the entity hit by the attack and the player holding infuser, does not by pass totem. The attack player minecraft:smoke ~ ~1.5 ~ 0.4 0.6 0.4 0.1 100 and plays minecraft:block.beacon.deactivate master @a ~ ~ ~ 0.8 1 and minecraft:block.fire.extinguish master @a ~ ~ ~ 0.6 1 which resets infusers fusion level back to 0. And the cycle repeats. create an item called Codex, it is a blue bundle with enchant glint, every time the user right clicks with it, it will give the user a random effect with a power of 4, and the effect lasts for a minute, and its EVERY effect in the game, you can only use it one at a time, so when you use it, you gotta wait for it to wear off to use it again, also depending on if its a positive or negative effect, it will make a different sound, the default sounds for both are /playsound minecraft:item.bundle.drop_contents master @a ~ ~ ~ 5 1.2, and the particles are /particle minecraft:dust_plume ~ ~1 ~ 0.3 0.4 0.3 0.1 30 force, and now for the positive and negative sounds, first is positive: /playsound minecraft:entity.experience_orb.pickup master @a ~ ~ ~ 5 1.2, and next is negative: /playsound minecraft:entity.blaze.death master @a ~ ~1 ~ 5 1, also if i hit someone with Codex, it does the same random effect and particles and sounds, but also when i hit someone with codex, it has a 10 percent increase to give a negative effect, and for me a 10 percent increase for positive effects when i use it on myself codex has a blue item name. also make commands to get these items, these being /codex and /infuser

Kodari AI
KodariNov 8 at 6:13 am 2
FusionInfuserCodex
A Minecraft plugin introducing two custom items. The Infuser is a mace with Wind Burst, Density, Fire Aspect, Unbreaking, and Mending enchantments. It gains fusion levels upon kills, changing name colors (purple to orange to light red to dark red), increasing attack speed, and at level 3 becomes overloaded with smoke particles, note block alarms, and a powerful 30-health attack that resets fusion. The Codex is a blue bundle with enchant glint that grants random effects (power 4, one minute duration) on right-click or hit, with positive/negative sounds and particles, plus a 10% bias toward negative effects on enemies and positive on self. Commands /infuser and /codex grant these items.
  1. Add /infuser with persistent fusion levels and overload effects.

  2. Add /codex with weighted random effects, sounds, particles, and a one-minute cooldown.

Added /infuser and /codex. Both commands default to operators.

Codex has a one-minute cooldown per user. Instant effects take effect immediately rather than lasting a minute. Infuser’s overload deals 30 damage before normal damage reductions and does not bypass totems.

indoorgoose

Codex doesnt give the user a random effect when right clicked also Make it so that if the effect codex gave runs out or disappears early the cooldown vanishes also make the effect level codex gives lower by 1. also make it so that when hit someone with codex it has a different cooldown than when you right click to give yourself a random effect, so they have separate cooldowns. ALSO Remove infuser’s lore, and in addition once it reaches fusion level 2 attack damage boosts to 8 in that state. The attack in fusion level 3 should instant kill the player if they’re not holding, if they are holding a totem it instantly pops it. Add slightly more smoke particles in overloading state while holding the item.

Kodari AI
KodariNov 8 at 6:32 am 1
  1. Fix Codex right-click effects, effect levels, and separate cooldowns that end when the effect disappears.

  2. Update Infuser’s lore, damage, overload kill, and smoke.

  • Fixed Codex right-click use, lowered effects to level III, and separated self-use and attack cooldowns. Each cooldown ends when its effect disappears.

  • Removed Infuser’s lore, raised its fusion level 2 attack damage to 8, increased overload smoke, and made the overload attack lethal while allowing totems to activate.

indoorgoose

also make codex cooldowns appear on the action bar

Kodari AI
KodariNov 8 at 6:35 am 1

I’ll show the self-use and attack cooldowns separately while you’re holding Codex.

Codex now shows separate self-use and attack cooldowns on the action bar while held.

indoorgoose

Make it that the overloading hit from infuser not do any durability damage, also the instant kill only activating on a mace hit above 4 blocks.

Make the attack damage of fusion level 2 does the same damage as a sharpness 5 netherite sword

Kodari AI
KodariNov 8 at 6:49 am 1
  1. Restrict Infuser’s lethal overload hit to falls above four blocks and prevent its durability cost.

  2. Match fusion level 2’s attack damage to a Sharpness V netherite sword.

  • Infuser’s overload now triggers only after falling more than four blocks, without consuming durability on that hit.

  • Fusion level 2 now has 11 base attack damage, matching a Sharpness V netherite sword before damage reductions. Existing Infusers update when their fusion level next changes.

indoorgoose

make over load hit also doesnt do any durability damage to enemy's armor

Kodari AI
KodariNov 8 at 6:50 am 1

I’ll cancel armor durability loss for the player struck by an overload hit, without affecting their other equipment.

Infuser’s overload hit no longer damages the struck player’s armor durability.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 332
src/main/java/com/kodari/infusion/InfusionItems.java
package com.kodari.infusion;

import com.cryptomorin.xseries.XAttribute;
import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.particles.XParticle;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.SoundCategory;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemDamageEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public final class InfusionItems extends JavaPlugin implements Listener {
    private NamespacedKey itemKey;
    private NamespacedKey fusionKey;
    private NamespacedKey speedKey;
    private NamespacedKey damageKey;
    private record CodexCooldown(UUID target, PotionEffectType effect, long expiresAt) {}
    private final Map<UUID, CodexCooldown> selfCooldowns = new HashMap<>();
    private final Map<UUID, CodexCooldown> attackCooldowns = new HashMap<>();
    private final Set<UUID> overloadVictims = new HashSet<>();
    private final Set<UUID> overloadDurability = new HashSet<>();
    private final Set<UUID> overloadArmorProtection = new HashSet<>();
    private static final Set<String> POSITIVE = Set.of(
            "speed", "haste", "strength", "instant_health", "jump_boost", "regeneration",
            "resistance", "fire_resistance", "water_breathing", "invisibility", "night_vision",
            "health_boost", "absorption", "saturation", "luck", "slow_falling", "conduit_power",
            "dolphins_grace", "hero_of_the_village");

    @Override
    public void onEnable() {
        itemKey = new NamespacedKey(this, "item");
        fusionKey = new NamespacedKey(this, "fusion");
        speedKey = new NamespacedKey(this, "infuser_speed");
        damageKey = new NamespacedKey(this, "infuser_damage");
        Bukkit.getPluginManager().registerEvents(this, this);
        Bukkit.getScheduler().runTaskTimer(this, this::overloadEffects, 5L, 5L);
        Bukkit.getScheduler().runTaskTimer(this, (Runnable) this::showCodexCooldowns, 1L, 20L);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can receive this item.");
            return true;
        }
        Player player = (Player) sender;
        ItemStack item = command.getName().equalsIgnoreCase("infuser") ? createInfuser() : createCodex();
        if (item == null) {
            player.sendMessage(ChatColor.RED + "This item is not available on this server version.");
            return true;
        }
        player.getInventory().addItem(item).values().forEach(leftover -> player.getWorld().dropItemNaturally(player.getLocation(), leftover));
        return true;
    }

    private ItemStack createInfuser() {
        ItemStack item = XMaterial.matchXMaterial("MACE").map(XMaterial::parseItem).orElse(null);
        if (item == null) return null;
        ItemMeta meta = item.getItemMeta();
        meta.getPersistentDataContainer().set(itemKey, PersistentDataType.STRING, "infuser");
        meta.getPersistentDataContainer().set(fusionKey, PersistentDataType.INTEGER, 0);
        enchant(meta, "WIND_BURST", 1);
        enchant(meta, "DENSITY", 5);
        enchant(meta, "FIRE_ASPECT", 2);
        enchant(meta, "UNBREAKING", 3);
        enchant(meta, "MENDING", 1);
        item.setItemMeta(meta);
        setFusion(item, 0);
        return item;
    }

    private ItemStack createCodex() {
        ItemStack item = XMaterial.matchXMaterial("BLUE_BUNDLE").map(XMaterial::parseItem).orElse(null);
        if (item == null) return null;
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.BLUE + "Codex");
        meta.setEnchantmentGlintOverride(true);
        meta.getPersistentDataContainer().set(itemKey, PersistentDataType.STRING, "codex");
        item.setItemMeta(meta);
        return item;
    }

    private void enchant(ItemMeta meta, String name, int level) {
        XEnchantment.matchXEnchantment(name).ifPresent(enchantment -> meta.addEnchant(enchantment.getEnchant(), level, true));
    }

    private boolean isItem(ItemStack item, String type) {
        if (item == null || !item.hasItemMeta()) return false;
        return type.equals(item.getItemMeta().getPersistentDataContainer().get(itemKey, PersistentDataType.STRING));
    }

    private int fusion(ItemStack item) {
        return item.getItemMeta().getPersistentDataContainer().getOrDefault(fusionKey, PersistentDataType.INTEGER, 0);
    }

    private void setFusion(ItemStack item, int level) {
        ItemMeta meta = item.getItemMeta();
        meta.getPersistentDataContainer().set(fusionKey, PersistentDataType.INTEGER, level);
        ChatColor color = level == 0 ? ChatColor.DARK_PURPLE : level == 1 ? ChatColor.GOLD : level == 2 ? ChatColor.RED : ChatColor.DARK_RED;
        meta.setDisplayName(color + "Infuser");
        meta.setLore(null);
        Attribute speed = XAttribute.of("attack_speed").map(XAttribute::get).orElse(null);
        Attribute damage = XAttribute.of("attack_damage").map(XAttribute::get).orElse(null);
        if (speed != null) {
            meta.removeAttributeModifier(speed);
            if (level >= 2) meta.addAttributeModifier(speed, new AttributeModifier(speedKey, -2.0, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND));
        }
        if (damage != null) {
            meta.removeAttributeModifier(damage);
            if (level >= 2) meta.addAttributeModifier(damage, new AttributeModifier(damageKey, 10.0, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND));
        }
        item.setItemMeta(meta);
    }

    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    public void onAttack(EntityDamageByEntityEvent event) {
        if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof LivingEntity)) return;
        Player player = (Player) event.getDamager();
        LivingEntity target = (LivingEntity) event.getEntity();
        ItemStack item = player.getInventory().getItemInMainHand();
        if (isItem(item, "infuser") && fusion(item) == 3 && player.getFallDistance() > 4.0f) {
            setFusion(item, 0);
            overloadVictims.add(target.getUniqueId());
            Bukkit.getScheduler().runTask(this, () -> overloadVictims.remove(target.getUniqueId()));
            overloadDurability.add(player.getUniqueId());
            Bukkit.getScheduler().runTask(this, () -> overloadDurability.remove(player.getUniqueId()));
            overloadArmorProtection.add(target.getUniqueId());
            Bukkit.getScheduler().runTask(this, () -> overloadArmorProtection.remove(target.getUniqueId()));
            event.setDamage(1_000_000.0);
            player.damage(1_000_000.0);
            particles("SMOKE", player.getLocation().add(0, 1.5, 0), 100, 0.4, 0.6, 0.4, 0.1);
            sound(player.getLocation(), "minecraft:block.beacon.deactivate", 0.8f, 1f);
            sound(player.getLocation(), "minecraft:block.fire.extinguish", 0.6f, 1f);
        } else if (isItem(item, "codex")) {
            useCodex(player, target, false);
        }
    }

    @EventHandler(ignoreCancelled = true)
    public void onItemDamage(PlayerItemDamageEvent event) {
        if (isItem(event.getItem(), "infuser") && overloadDurability.remove(event.getPlayer().getUniqueId())) {
            event.setCancelled(true);
        } else if (overloadArmorProtection.contains(event.getPlayer().getUniqueId())) {
            for (ItemStack armor : event.getPlayer().getInventory().getArmorContents()) {
                if (armor != null && armor.equals(event.getItem())) {
                    event.setCancelled(true);
                    break;
                }
            }
        }
    }

    @EventHandler(priority = EventPriority.MONITOR)
    public void onDeath(EntityDeathEvent event) {
        LivingEntity victim = event.getEntity();
        if (overloadVictims.remove(victim.getUniqueId())) return;
        if (!(victim.getLastDamageCause() instanceof EntityDamageByEntityEvent)) return;
        Entity attacker = ((EntityDamageByEntityEvent) victim.getLastDamageCause()).getDamager();
        if (!(attacker instanceof Player)) return;
        Player player = (Player) attacker;
        ItemStack item = player.getInventory().getItemInMainHand();
        if (!isItem(item, "infuser")) return;
        setFusion(item, Math.min(3, fusion(item) + 1));
        Location location = victim.getLocation();
        sound(location, "minecraft:block.vault.open_shutter", 1f, 1f);