Prometheus ODonnell

make a spear that when i charge spear a player it saves that i did and then when i offhand shift it teleports them to me and when i offhand it swaps our places its called VoidSwap

Kodari AI
KodariOct 14 at 3:26 am 6
VoidSwap
VoidSwap introduces a unique spear weapon with three distinct abilities. Charging a player with the spear marks them as your target, storing their identity. While holding the spear in your offhand and sneaking, you instantly teleport the marked player to your current position. Simply holding the spear in your offhand without sneaking swaps your positions with the marked target. The spear provides a tactical advantage for combat and mobility, allowing strategic repositioning and forced engagement. Includes visual feedback when targeting and cooldown management to prevent spam. Fully configurable via config file for cooldowns, range limits, and permission requirements.
  1. Register the VoidSwap spear and add its survival recipe, item assets, and name.

  2. Save a player target when you right-click them with the spear; using it from your offhand pulls them while sneaking or swaps positions otherwise.

  3. Add the Fabric 1.21.11 entrypoint and project metadata.

Created VoidSwap as a Fabric 1.21.11 mod.

Right-click a player with the spear to mark them. Then put it in your offhand and use it: sneaking pulls them to you; otherwise, you swap places. The mark is consumed when you use the ability and is kept only for the current server session.

Craft the spear with an Ender Pearl, Diamond, and Stick in a vertical line, from top to bottom.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
12 249
src/main/java/com/kodari/voidswap/VoidSwap.java
package com.kodari.voidswap;

import net.fabricmc.api.ModInitializer;

public final class VoidSwap implements ModInitializer {
    public static final String MOD_ID = "voidswap";

    @Override
    public void onInitialize() {
        ModItems.initialize();
    }
}