Vincent Nielsen

i want this mace to be able to get trown like a tridentjust with this texture when you shift hold right click iyou can trow it where it charges like a trident, and when it hits a player it strikes the player with a lightning bolt where the player is, and it works like a normal mace wheree you fall and it doese dmg just with it sriking with a lightning bolt when you hit the player, and the lightning bolt doese an aditional 3 hearts when trowing and 2 when striking,

📎 1 file 8,650 chars
📄
Gods-Mace.json
json 271 lines
▶
{
	"format_version": "1.21.11",
	"credit": "Made with Blockbench",
	"textures": {
		"0": "block/texture",
		"1": "block/texture",
		"2": "block/texture",
		"3": "block/texture",
		"4": "block/texture",
		"5": "block/texture",
		"6": "block/texture",
		"7": "block/texture",
		"8": "block/texture",
		"9": "block/texture",
		"10": "block/texture",
		"11": "block/texture",
		"12": "block/texture",
		"13": "block/texture",
		"14": "block/texture",
		"particle": "block/texture"
	},
	"elements": [
		{
			"from": [7, -1, 7],
			"to": [9, 14, 9],
			"rotation": {"angle": 0, "axis": "y", "origin": [7, -1, 7]},
			"faces": {
				"north": {"uv": [0, 0, 2, 15], "texture": "#10"},
				"east": {"uv": [2, 0, 4, 15], "texture": "#10"},
				"south": {"uv": [4, 0, 6, 15], "texture": "#10"},
				"west": {"uv": [6, 0, 8, 15], "texture": "#10"},
				"up": {"uv": [10, 2, 8, 0], "texture": "#10"},
				"down": {"uv": [10, 2, 8, 4], "texture": "#10"}
			}
		},
		{
			"from": [7, 0, 6],
			"to": [9, 2, 9],
			"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 7]},
			"faces": {
				"north": {"uv": [0, 4, 2, 6], "texture": "#11"},
				"east": {"uv": [0, 0, 3, 2], "texture": "#11"},
				"south": {"uv": [5, 0, 7, 2], "texture": "#11"},
				"west": {"uv": [0, 2, 3, 4], "texture": "#11"},
				"up": {"uv": [5, 3, 3, 0], "texture": "#11"},
				"down": {"uv": [5, 3, 3, 6], "texture": "#11"}
			}
		},
		{
			"from": [7, 0, 7],
			"to": [10, 2, 9],
			"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 7]},
			"faces": {
				"north": {"uv": [0, 0, 3, 2], "texture": "#12"},
				"east": {"uv": [0, 4, 2, 6], "texture": "#12"},
				"south": {"uv": [0, 2, 3, 4], "texture": "#12"},
				"west": {"uv": [2, 4, 4, 6], "texture": "#12"},
				"up": {"uv": [6, 2, 3, 0], "texture": "#12"},
				"down": {"uv": [6, 2, 3, 4], "texture": "#12"}
			}
		},
		{
			"from": [6, 0, 7],
			"to": [9, 2, 9],
			"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 7]},
			"faces": {
				"north": {"uv": [0, 0, 3, 2], "texture": "#9"},
				"east": {"uv": [0, 4, 2, 6], "texture": "#9"},
				"south": {"uv": [0, 2, 3, 4], "texture": "#9"},
				"west": {"uv": [2, 4, 4, 6], "texture": "#9"},
				"up": {"uv": [6, 2, 3, 0], "texture": "#9"},
				"down": {"uv": [6, 2, 3, 4], "texture": "#9"}
			}
		},
		{
			"from": [7, 0, 6],
			"to": [9, 2, 10],
			"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 7]},
			"faces": {
				"north": {"uv": [2, 4, 4, 6], "texture": "#13"},
				"east": {"uv": [0, 0, 4, 2], "texture": "#13"},
				"south": {"uv": [4, 4, 6, 6], "texture": "#13"},
				"west": {"uv": [0, 2, 4, 4], "texture": "#13"},
				"up": {"uv": [2, 8, 0, 4], "texture": "#13"},
				"down": {"uv": [6, 0, 4, 4], "texture": "#13"}
			}
		},
		{
			"from": [6, 14, 4],
			"to": [10, 18, 12],
			"rotation": {"angle": 0, "axis": "y", "origin": [7, 3, 10]},
			"faces": {
				"north": {"uv": [4, 8, 8, 12], "texture": "#2"},
				"east": {"uv": [0, 0, 8, 4], "texture": "#2"},
				"south": {"uv": [8, 8, 12, 12], "texture": "#2"},
				"west": {"uv": [0, 4, 8, 8], "texture": "#2"},
				"up": {"uv": [4, 16, 0, 8], "texture": "#2"},
				"down": {"uv": [12, 0, 8, 8], "texture": "#2"}
			}
		},
		{
			"from": [9, 15, 6],
			"to": [11, 16, 9],
			"rotation": {"angle": 0, "axis": "y", "origin": [12, 2, 6]},
			"faces": {
				"north": {"uv": [0, 4, 2, 5], "texture": "#4"},
				"east": {"uv": [0, 3, 3, 4], "texture": "#4"},
				"south": {"uv": [4, 0, 6, 1], "texture": "#4"},
				"west": {"uv": [3, 3, 6, 4], "texture": "#4"},
				"up": {"uv": [2, 3, 0, 0], "texture": "#4"},
				"down": {"uv": [4, 0, 2, 3], "texture": "#4"}
			}
		},
		{
			"from": [5, 15, 6],
			"to": [7, 16, 9],
			"rotation": {"angle": 0, "axis": "y", "origin": [8, 2, 6]},
			"faces": {
				"north": {"uv": [0, 4, 2, 5], "texture": "#3"},
				"east": {"uv": [0, 3, 3, 4], "texture": "#3"},
				"south": {"uv": [4, 0, 6, 1], "texture": "#3"},
				"west": {"uv": [3, 3, 6, 4], "texture": "#3"},
				"up": {"uv": [2, 3, 0, 0], "texture": "#3"},
				"down": {"uv": [4, 0, 2, 3], "texture": "#3"}
			}
		},
		{
			"from": [6, 13, 3],
			"to": [10, 17, 4],
			"rotation": {"angle": 0, "axis": "y", "origin": [9, 3, 3]},
			"faces": {
				"north": {"uv": [0, 0, 4, 4], "texture": "#7"},
				"east": {"uv": [4, 0, 5, 4], "texture": "#7"},
				"south": {"uv": [0, 4, 4, 8], "texture": "#7"},
				"west": {"uv": [4, 4, 5, 8], "texture": "#7"},
				"up": {"uv": [9, 1, 5, 0], "texture": "#7"},
				"down": {"uv": [9, 1, 5, 2], "texture": "#7"}
			}
		},
		{
			"from": [9, 16, 5],
			"to": [11, 18, 14],
			"rotation": {"angle": 0, "axis": "y", "origin": [10, 3, 11]},
			"faces": {
				"north": {"uv": [4, 4, 6, 6], "texture": "#0"},
				"east": {"uv": [0, 0, 9, 2], "texture": "#0"},
				"south": {"uv": [4, 6, 6, 8], "texture": "#0"},
				"west": {"uv": [0, 2, 9, 4], "texture": "#0"},
				"up": {"uv": [2, 13, 0, 4], "texture": "#0"},
				"down": {"uv": [4, 4, 2, 13], "texture": "#0"}
			}
		},
		{
			"from": [5, 16, 5],
			"to": [7, 18, 14],
			"rotation": {"angle": 0, "axis": "y", "origin": [6, 3, 11]},
			"faces": {
				"north": {"uv": [4, 4, 6, 6], "texture": "#5"},
				"east": {"uv": [0, 0, 9, 2], "texture": "#5"},
				"south": {"uv": [4, 6, 6, 8], "texture": "#5"},
				"west": {"uv": [0, 2, 9, 4], "texture": "#5"},
				"up": {"uv": [2, 13, 0, 4], "texture": "#5"},
				"down": {"uv": [4, 4, 2, 13], "texture": "#5"}
			}
		},
		{
			"from": [9, 17, 7],
			"to": [11, 19, 16],
			"rotation": {"angle": 0, "axis": "y", "origin": [10, 4, 13]},
			"faces": {
				"north": {"uv": [4, 4, 6, 6], "texture": "#1"},
				"east": {"uv": [0, 0, 9, 2], "texture": "#1"},
				"south": {"uv": [4, 6, 6, 8], "texture": "#1"},
				"west": {"uv": [0, 2, 9, 4], "texture": "#1"},
				"up": {"uv": [2, 13, 0, 4], "texture": "#1"},
				"down": {"uv": [4, 4, 2, 13], "texture": "#1"}
			}
		},
		{
			"from": [5, 17, 7],
			"to": [7, 19, 16],
			"rotation": {"angle": 0, "axis": "y", "origin": [6, 4, 13]},
			"faces": {
				"north": {"uv": [4, 4, 6, 6], "texture": "#6"},
				"east": {"uv": [0, 0, 9, 2], "texture": "#6"},
				"south": {"uv": [4, 6, 6, 8], "texture": "#6"},
				"west": {"uv": [0, 2, 9, 4], "texture": "#6"},
				"up": {"uv": [2, 13, 0, 4], "texture": "#6"},
				"down": {"uv": [4, 4, 2, 13], "texture": "#6"}
			}
		},
		{
			"from": [7, 0, 6],
			"to": [9, 2, 9],
			"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 7]},
			"color": 4,
			"faces": {
				"north": {"uv": [0, 0, 2, 2], "texture": "#missing"},
				"east": {"uv": [0, 0, 2, 2], "texture": "#missing"},
				"south": {"uv": [0, 0, 2, 2], "texture": "#missing"},
				"west": {"uv": [0, 0, 2, 2], "texture": "#missing"},
				"up": {"uv": [0, 0, 2, 2], "texture": "#missing"},
				"down": {"uv": [0, 0, 1, 2], "texture": "#missing"}
			}
		},
		{
			"from": [6, 13, 4],
			"to": [10, 14, 11],
			"rotation": {"angle": 0, "axis": "y", "origin": [8, 12, 4]},
			"faces": {
				"north": {"uv": [0, 8, 4, 9], "texture": "#8"},
				"east": {"uv": [0, 7, 7, 8], "texture": "#8"},
				"south": {"uv": [8, 0, 12, 1], "texture": "#8"},
				"west": {"uv": [7, 7, 14, 8], "texture": "#8"},
				"up": {"uv": [4, 7, 0, 0], "texture": "#8"},
				"down": {"uv": [8, 0, 4, 7], "texture": "#8"}
			}
		},
		{
			"from": [7, 12, 6],
			"to": [9, 14, 8],
			"rotation": {"angle": 0, "axis": "y", "origin": [7, 10, 5]},
			"faces": {
				"north": {"uv": [0, 0, 2, 2], "texture": "#14"},
				"east": {"uv": [0, 2, 2, 4], "texture": "#14"},
				"south": {"uv": [2, 0, 4, 2], "texture": "#14"},
				"west": {"uv": [2, 2, 4, 4], "texture": "#14"},
				"up": {"uv": [2, 6, 0, 4], "texture": "#14"},
				"down": {"uv": [6, 0, 4, 2], "texture": "#14"}
			}
		},
		{
			"from": [9, 16, 7],
			"to": [11, 16, 9],
			"rotation": {"angle": 0, "axis": "y", "origin": [9, 16, 7]},
			"color": 7,
			"faces": {
				"north": {"uv": [0, 2, 2, 2], "texture": "#missing"},
				"east": {"uv": [0, 2, 2, 2], "texture": "#missing"},
				"south": {"uv": [0, 2, 2, 2], "texture": "#missing"},
				"west": {"uv": [0, 2, 2, 2], "texture": "#missing"},
				"up": {"uv": [0, 0, 2, 2], "texture": "#missing"},
				"down": {"uv": [0, 0, 2, 2], "texture": "#missing"}
			}
		}
	],
	"display": {
		"thirdperson_righthand": {
			"rotation": [12, 3, 0],
			"translation": [-0.25, 2.5, 2.5],
			"scale": [0.99, 1, 1]
		},
		"firstperson_righthand": {
			"rotation": [15, 36, 3],
			"translation": [1.5, 0.5, -6.5],
			"scale": [1.25, 1, 1]
		},
		"gui": {
			"rotation": [0, 94, 0],
			"translation": [-0.25, -1.75, 0],
			"scale": [1.11, 0.88, 0.91]
		},
		"fixed": {
			"rotation": [1, -98, 1],
			"translation": [0.75, -1, 0.5]
		},
		"on_shelf": {
			"rotation": [0, 94, 0]
		}
	}
}
Kodari AI
KodariToday at 8:42 pm 2
ThunderMace
A Minecraft plugin that adds a custom mace weapon with trident-like throwing mechanics. When shift-right-clicking, the mace charges and launches like a trident, striking enemies with lightning bolts dealing 3 hearts of bonus damage. The mace also functions as a normal melee weapon with fall damage mechanics, and when striking enemies in melee combat, it triggers lightning dealing 2 hearts of additional damage. The plugin uses a custom item model with the provided Gods-Mace texture and implements projectile physics, lightning effects, and damage calculations.

I’ll add the mace’s throw and lightning mechanics. A plugin can’t detect release of right-click with a normal mace, so the throw will launch automatically after a one-second charge.

Created /godsmace to give operators God’s Mace. Sneak-right-click to charge; it throws automatically after one second and drops where it lands. Player hits add 3 hearts of thrown damage or 2 hearts to melee damage, before armor reduction, with a visual lightning strike.

The supplied model isn’t applied: it needs a client resource pack and references missing textures. To create or edit the visuals, enable Kodari Studio under Project Settings → Generation, or for all projects at https://kodari.ai/settings?tab=features.

Vincent Nielsen

make it fly back like a loyalty trident too,

Kodari AI
KodariToday at 8:45 pm 2
  • Make thrown maces fly back to their owner after impact or timeout.

  • Leave the mace recoverable if its owner disconnects or the plugin stops.

God’s Mace now flies back to its owner after hitting something or timing out. If the owner disconnects or changes worlds, it drops where it is.

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

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
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.ProjectileHitEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
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.scheduler.BukkitTask;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public final class GodsMace extends JavaPlugin implements Listener {
    private final Map<UUID, BukkitTask> charging = new HashMap<>();
    private final Map<UUID, ItemStack> thrown = new HashMap<>();
    private final Map<UUID, Item> returning = new HashMap<>();
    private NamespacedKey maceKey;

    @Override
    public void onEnable() {
        maceKey = new NamespacedKey(this, "gods_mace");
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("godsmace").setExecutor((sender, command, label, args) -> {
            if (!(sender instanceof Player)) {
                sender.sendMessage("Only players can use this command.");
                return true;
            }
            Player player = (Player) sender;
            ItemStack mace = XMaterial.matchXMaterial("MACE").map(XMaterial::parseItem).orElse(null);
            if (mace == null) {
                player.sendMessage(ChatColor.RED + "This server does not support maces.");
                return true;
            }
            ItemMeta meta = mace.getItemMeta();
            meta.setDisplayName(ChatColor.GOLD + "God's Mace");
            meta.getPersistentDataContainer().set(maceKey, PersistentDataType.BYTE, (byte) 1);
            mace.setItemMeta(meta);
            player.getInventory().addItem(mace).values().forEach(item -> player.getWorld().dropItemNaturally(player.getLocation(), item));
            return true;
        });
    }

    private boolean isMace(ItemStack item) {
        return item != null && item.hasItemMeta()
                && item.getItemMeta().getPersistentDataContainer().has(maceKey, PersistentDataType.BYTE);
    }

    @EventHandler(ignoreCancelled = true)
    public void onUse(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        if (event.getHand() != EquipmentSlot.HAND || !player.isSneaking() || !isMace(event.getItem())
                || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)) return;
        event.setCancelled(true);
        if (charging.containsKey(player.getUniqueId())) return;
        int slot = player.getInventory().getHeldItemSlot();
        ItemStack original = event.getItem().clone();
        player.sendMessage(ChatColor.YELLOW + "Charging God's Mace...");
        UUID id = player.getUniqueId();
        BukkitTask task = getServer().getScheduler().runTaskTimer(this, new Runnable() {
            private int ticks;

            @Override
            public void run() {
                if (!player.isOnline() || player.isDead() || !player.isSneaking()
                        || player.getInventory().getHeldItemSlot() != slot
                        || !original.equals(player.getInventory().getItem(slot))) {
                    cancelCharge(id);
                    return;
                }
                if (++ticks < 20) return;
                cancelCharge(id);
                ItemStack projectileItem = original.clone();
                projectileItem.setAmount(1);
                Snowball projectile = player.launchProjectile(Snowball.class);
                projectile.setItem(projectileItem);
                projectile.setVelocity(player.getEyeLocation().getDirection().multiply(2.5));
                thrown.put(projectile.getUniqueId(), projectileItem);
                if (original.getAmount() == 1) player.getInventory().setItem(slot, null);
                else {
                    original.setAmount(original.getAmount() - 1);
                    player.getInventory().setItem(slot, original);
                }
                getServer().getScheduler().runTaskLater(GodsMace.this, () -> returnProjectile(projectile, projectile.getLocation()), 200L);
            }
        }, 1L, 1L);
        charging.put(id, task);
    }

    private void cancelCharge(UUID id) {
        BukkitTask task = charging.remove(id);
        if (task != null) task.cancel();
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onDamage(EntityDamageByEntityEvent event) {
        if (!(event.getEntity() instanceof Player)) return;
        if (event.getDamager() instanceof Player) {
            Player attacker = (Player) event.getDamager();
            if (isMace(attacker.getInventory().getItemInMainHand())) {
                event.setDamage(event.getDamage() + 4.0);
            }
        } else if (event.getDamager() instanceof Snowball && thrown.containsKey(event.getDamager().getUniqueId())) {
            event.setDamage(6.0);
        }
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onDamageEffect(EntityDamageByEntityEvent event) {
        if (!(event.getEntity() instanceof Player) || event.getFinalDamage() <= 0) return;
        boolean melee = event.getDamager() instanceof Player
                && isMace(((Player) event.getDamager()).getInventory().getItemInMainHand());
        boolean projectile = event.getDamager() instanceof Snowball && thrown.containsKey(event.getDamager().getUniqueId());
        if (melee || projectile) event.getEntity().getWorld().strikeLightningEffect(event.getEntity().getLocation());
    }

    @EventHandler
    public void onProjectileHit(ProjectileHitEvent event) {
        if (event.getEntity() instanceof Snowball && thrown.containsKey(event.getEntity().getUniqueId())) {
            Snowball projectile = (Snowball) event.getEntity();
            Location impact = projectile.getLocation().clone();
            getServer().getScheduler().runTask(this, () -> returnProjectile(projectile, impact));
        }
    }

    private void returnProjectile(Snowball projectile, Location location) {
        ItemStack item = thrown.remove(projectile.getUniqueId());
        if (item == null) return;
        Player owner = projectile.getShooter() instanceof Player ? (Player) projectile.getShooter() : null;
        projectile.remove();
        Item flying = location.getWorld().dropItem(location, item);
        flying.setPickupDelay(Integer.MAX_VALUE);
        flying.setGravity(false);
        returning.put(flying.getUniqueId(), flying);
        new org.bukkit.scheduler.BukkitRunnable() {
            @Override
            public void run() {
                if (!flying.isValid()) {
                    returning.remove(flying.getUniqueId());
                    cancel();
                    return;
                }
                if (owner == null || !owner.isOnline() || owner.isDead() || !owner.getWorld().equals(flying.getWorld())) {
                    flying.setGravity(true);
                    flying.setPickupDelay(0);
                    returning.remove(flying.getUniqueId());
                    cancel();
                    return;
                }
                Location target = owner.getEyeLocation();
                org.bukkit.util.Vector direction = target.toVector().subtract(flying.getLocation().toVector());
                if (direction.lengthSquared() <= 1.0) {
                    owner.getInventory().addItem(flying.getItemStack()).values()
                            .forEach(leftover -> owner.getWorld().dropItemNaturally(owner.getLocation(), leftover));
                    flying.remove();
                    returning.remove(flying.getUniqueId());
                    cancel();
                    return;
                }
                flying.teleport(flying.getLocation().add(direction.normalize().multiply(0.8)));
            }
        }.runTaskTimer(this, 1L, 1L);
    }

    private void dropProjectile(Snowball projectile) {
        ItemStack item = thrown.remove(projectile.getUniqueId());
        if (item == null) return;
        projectile.getWorld().dropItemNaturally(projectile.getLocation(), item);
        projectile.remove();
    }

    @Override
    public void onDisable() {
        charging.values().forEach(BukkitTask::cancel);
        charging.clear();
        for (UUID id : new java.util.ArrayList<>(thrown.keySet())) {
            org.bukkit.entity.Entity entity = getServer().getEntity(id);
            if (entity instanceof Snowball) dropProjectile((Snowball) entity);
            else getLogger().warning("Could not recover thrown mace " + id + " because its projectile is unloaded.");
        }
        thrown.clear();
        for (Item item : returning.values()) {
            if (item.isValid()) {
                item.setGravity(true);
                item.setPickupDelay(0);
            }