Troy williamson

make me a one piece mod and add all the devil fruits

Kodari AI
KodariNov 6 at 9:40 pm 13
OnePieceDevilFruits
A comprehensive One Piece mod for Minecraft Fabric that introduces Devil Fruits as obtainable items. Players can find and consume Devil Fruits scattered throughout the world, each granting unique supernatural powers based on the anime. The mod implements the Gomu Gomu no Mi granting rubber-like abilities, the Mera Mera no Mi with fire manipulation, the Goro Goro no Mi with lightning powers, and more. Each fruit provides distinct combat abilities, movement enhancements, and visual effects. Fruits respawn in random locations after consumption, encouraging exploration and collection. The mod includes a fruit encyclopedia GUI for tracking discovered powers, custom models for each fruit, and balanced cooldown systems to prevent overpowered gameplay. Compatible with Fabric 26.3 and designed for both single-player and multiplayer servers.
  1. Set up a Fabric 26.3 mod with a reusable fruit-power item system.

  2. Add a starter roster of original pirate-adventure fruits with survival recipes, custom textures, and distinct effects.

  3. Register their items, assets, and creative-tab entries.

Created a Fabric 26.3 pirate fruit-power mod with five original fruits—not the complete One Piece catalog.

In survival, use an apple to trade it for a random fruit; make sure you have inventory space. Right-click a fruit to activate its power for 30 seconds, with a 40-second cooldown:

  • Elastic: Speed II and Jump Boost II

  • Flame: Fire Resistance and Strength

  • Frost: Resistance and Slow Falling

  • Storm: Speed III and Night Vision

  • Quake: Strength III and Resistance II

They’re registered in a custom creative tab and have their own textures and item models.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
21 207
src/main/java/com/kodari/grandfruits/GrandFruits.java
package com.kodari.grandfruits;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.network.chat.Component;

public class GrandFruits implements ModInitializer {
    public static final String MOD_ID = "grandfruits";

    private static final Item ELASTIC_FRUIT = registerFruit("elastic_fruit", 1.1F,
            new Power(MobEffects.SPEED, 1), new Power(MobEffects.JUMP_BOOST, 1));
    private static final Item FLAME_FRUIT = registerFruit("flame_fruit", 1.4F,
            new Power(MobEffects.FIRE_RESISTANCE, 0), new Power(MobEffects.STRENGTH, 0));
    private static final Item FROST_FRUIT = registerFruit("frost_fruit", 0.9F,
            new Power(MobEffects.RESISTANCE, 0), new Power(MobEffects.SLOW_FALLING, 0));
    private static final Item STORM_FRUIT = registerFruit("storm_fruit", 1.7F,
            new Power(MobEffects.SPEED, 2), new Power(MobEffects.NIGHT_VISION, 0));
    private static final Item QUAKE_FRUIT = registerFruit("quake_fruit", 0.7F,
            new Power(MobEffects.STRENGTH, 2), new Power(MobEffects.RESISTANCE, 1));

    private static final List<Item> FRUITS = List.of(
            ELASTIC_FRUIT, FLAME_FRUIT, FROST_FRUIT, STORM_FRUIT, QUAKE_FRUIT);

    @SuppressWarnings("unused")
    private static final CreativeModeTab FRUIT_TAB = registerFruitTab();

    @Override
    public void onInitialize() {
        UseItemCallback.EVENT.register(GrandFruits::convertAppleToFruit);
    }

    private static InteractionResult convertAppleToFruit(Player player, Level level, InteractionHand hand) {
        if (level.isClientSide() || player.isSpectator()) {
            return InteractionResult.PASS;
        }

        ItemStack heldStack = player.getItemInHand(hand);
        if (heldStack.getItem() != Items.APPLE) {
            return InteractionResult.PASS;
        }

        ItemStack fruitStack = new ItemStack(FRUITS.get(ThreadLocalRandom.current().nextInt(FRUITS.size())));
        if (!player.getInventory().add(fruitStack)) {
            return InteractionResult.FAIL;
        }

        heldStack.shrink(1);
        player.playSound(SoundEvents.AMETHYST_BLOCK_CHIME, 0.8F, 1.5F);
        return InteractionResult.SUCCESS;
    }

    private static Item registerFruit(String name, float soundPitch, Power... powers) {
        Identifier identifier = Identifier.fromNamespaceAndPath(MOD_ID, name);
        ResourceKey<Item> itemKey = ResourceKey.create(Registries.ITEM, identifier);
        Item item = new FruitItem(new Item.Properties().setId(itemKey).stacksTo(1), soundPitch, powers);
        return Registry.register(BuiltInRegistries.ITEM, identifier, item);
    }

    private static CreativeModeTab registerFruitTab() {
        Identifier identifier = Identifier.fromNamespaceAndPath(MOD_ID, "fruits");
        ResourceKey<CreativeModeTab> tabKey = ResourceKey.create(Registries.CREATIVE_MODE_TAB, identifier);
        CreativeModeTab tab = CreativeModeTab.builder(CreativeModeTab.Row.TOP, 0)
                .title(Component.translatable("itemGroup.grandfruits.fruits"))
                .icon(() -> new ItemStack(ELASTIC_FRUIT))
                .displayItems((parameters, output) -> {
                    for (Item fruit : FRUITS) {
                        output.accept(fruit);
                    }
                })
                .build();
        return Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, tabKey, tab);
    }

    private record Power(Holder<MobEffect> effect, int amplifier) {
    }

    private static final class FruitItem extends Item {
        private final float soundPitch;
        private final Power[] powers;

        private FruitItem(Properties properties, float soundPitch, Power... powers) {
            super(properties);
            this.soundPitch = soundPitch;
            this.powers = powers;
        }

        @Override
        public InteractionResult use(Level level, Player player, InteractionHand hand) {
            if (!level.isClientSide()) {
                for (Power power : powers) {
                    player.addEffect(new MobEffectInstance(power.effect(), 20 * 30, power.amplifier()));
                }

                player.playSound(SoundEvents.AMETHYST_BLOCK_CHIME, 1.0F, soundPitch);
                player.getCooldowns().addCooldown(player.getItemInHand(hand), 20 * 40);
            }

            return InteractionResult.SUCCESS;
        }
    }
}