KingHassan23
πŸ“Ž 1 file 11,919 chars
πŸ“„
pasted-code-1794534581789.txt
txt 377 lines
β–Ά
# PROJECT: Leveled Drops β€” Enhanced NeoForge 1.21.1 Remake

You are an expert Minecraft Java mod developer specializing in NeoForge, Minecraft internals, loot systems, data components, networking, GUI rendering, enchantments, and Mixins.

Your task is to **recreate and modernize the Minecraft mod "Leveled Drops" version 1.0.1 for Minecraft Java Edition 1.21.1 using NeoForge and Java 21**.

The original mod targets Minecraft 1.20.1 Forge. If the original JAR is provided, inspect its implementation, metadata, assets, configuration, and behavior before recreating the systems.

The goal is to preserve the original gameplay mechanics while improving compatibility, stability, performance, usability, and multiplayer synchronization.

## 1. Mandatory Technical Requirements

- Minecraft Java Edition: **1.21.1**
- Mod loader: **NeoForge 21.1.x**
- Java: **21**
- Mod ID: `leveleddrops`
- Use the official NeoForge development environment and Gradle.
- Use Minecraft 1.21.1-compatible APIs, mappings, registries, networking, and data components.
- Produce a complete, compilable Java mod project.
- Prefer NeoForge events and supported APIs.
- Use Mixins only where necessary.
- Avoid unnecessary third-party dependencies.
- Ensure compatibility with dedicated servers and singleplayer.
- Never execute client-only code on a dedicated server.

Do not merely modify the Minecraft version number in the original JAR. Properly port or reconstruct the implementation.

## 2. Core Drop Multiplication System

Every item drop produced by a player breaking a block or killing a mob must be multiplied according to that player's selected XP-based multiplier.

Examples:

- XP level 1 β†’ Γ—1 drops
- XP level 5 β†’ Γ—5 drops
- XP level 10 β†’ Γ—10 drops
- XP level 30 β†’ Γ—30 drops
- XP level 64 β†’ Γ—64 drops

The player may manually select a lower multiplier between 1 and their current XP level.

Preserve the original drop results before multiplication, including loot table outcomes, enchantment effects, and modded loot.

**Do not multiply experience orbs.**

Avoid multiplying the same drop more than once.

Do not multiply unrelated item entities or drops that were not caused by an eligible player action.

## 3. New Level 0 Protection

This is an essential improvement.

The original XP-based behavior must be modified to prevent new players from becoming unable to collect resources.

Implement the following rule:

`maximumMultiplier = max(1, player.experienceLevel)`

At XP level 0, the player must automatically have a multiplier of Γ—1.

Examples:

- Level 0 β†’ Γ—1
- Level 1 β†’ Γ—1
- Level 2 β†’ Γ—2
- Level 10 β†’ Γ—10

This protection must work immediately when creating a new world.

Players must still be able to deliberately disable drops by selecting Γ—0 through the configuration screen.

Automatic level changes must never set the multiplier to Γ—0.

If a player loses XP levels, clamp their selected multiplier to the new allowed maximum.

## 4. Containers and NBT Preservation

Breaking a chest, barrel, or other supported container must multiply:

1. The block's own item drops.
2. Every item stored inside the container.

Example:

A chest contains:

- 5 diamonds
- 1 enchanted sword
- 10 iron ingots

The player breaks it at multiplier Γ—10.

Expected results:

- 50 diamonds
- 10 identical enchanted swords
- 100 iron ingots
- 10 chest items, assuming the original block drop is one chest

Every copy of the enchanted sword must preserve its enchantments, durability, custom name, lore, and all other data components.

For Minecraft 1.21.1, correctly preserve the modern item data component system rather than relying on outdated item NBT assumptions.

Avoid accidental duplication caused by processing container contents more than once.

Support modded containers where technically possible, without destroying their custom inventories or data.

## 5. Disable Drops Mode

Keep the original Disable Drops functionality.

The configuration screen must contain a button labeled:

**Disable Drops**

When activated:

- Set the effective multiplier to Γ—0.
- Suppress eligible item drops completely.
- Do not suppress XP orbs.
- Preserve the player's selection across sessions.
- Display Γ—0 on the HUD.
- Allow the player to re-enable drops.

When drops are re-enabled, restore a valid multiplier between 1 and the player's current allowed maximum.

This behavior must also work at XP level 0.

## 6. Configuration Screen and Keybind

Preserve the original default keybind:

**M**

The key must be rebindable through Minecraft's Controls menu.

Pressing M opens the Leveled Drops configuration screen.

The main screen must include:

- Current XP level.
- Current selected multiplier.
- Slider from Γ—1 to the maximum allowed multiplier.
- Disable Drops button.
- Enable Drops button when drops are disabled.
- HUD settings.
- Advanced settings.

The screen must work correctly at level 0, where the slider has a valid Γ—1 setting.

The interface should be intuitive and consistent with Minecraft's visual style.

## 7. Improved HUD

Display the current multiplier continuously as:

**Γ—N**

Examples: Γ—0, Γ—1, Γ—10, Γ—64.

Add configurable options for:

- Top-left position.
- Top-right position.
- Bottom-left position.
- Bottom-right position.
- HUD scale.
- Background transparency.
- HUD visibility.

Default settings should resemble the original mod.

The HUD must update correctly when the player's multiplier or XP level changes.

Avoid unnecessary per-frame calculations.

## 8. Enchantment Level Cap: 64

Preserve the original enchantment overhaul.

All multi-level enchantments must support levels up to 64.

Examples include:

- Sharpness
- Protection
- Efficiency
- Unbreaking
- Fortune
- Looting
- Other applicable multi-level enchantments

Single-level enchantments must remain single-level.

Preserve normal enchantment compatibility rules unless the original mod explicitly changes them.

Players must be able to combine enchantments normally through anvils.

Examples:

- Sharpness V + Sharpness V β†’ Sharpness VI
- Sharpness VI + Sharpness VI β†’ Sharpness VII

Continue this progression up to level 64.

The `/enchant` command must respect the expanded maximum level.

Ensure that Minecraft 1.21.1's data-driven enchantment system is handled correctly.

Do not simply modify tooltips while leaving the actual enchantment functionality capped at vanilla levels.

## 9. Anvil Overhaul

Remove the vanilla "Too Expensive!" restriction.

Anvil operations must not be rejected because of accumulated prior-work penalties or the vanilla cost ceiling.

Preserve the original concept that anvil costs depend on enchantment rarity rather than accumulated repair penalties.

Maintain valid survival-mode XP costs and normal enchantment compatibility behavior.

Do not introduce free enchanting unless it is explicitly required by the original implementation.

Test enchanted books, enchanted equipment, repairs, and renaming.

## 10. Roman Numeral Display

Enchantment levels above 10 must use Roman numerals followed by their Arabic value.

Examples:

- Level 11 β†’ XI (11)
- Level 20 β†’ XX (20)
- Level 30 β†’ XXX (30)
- Level 40 β†’ XL (40)
- Level 50 β†’ L (50)
- Level 64 β†’ LXIV (64)

Levels 1 through 10 should retain their normal Roman numeral display.

The display must be consistent across enchanted books, equipment, and relevant tooltips.

## 11. Performance Improvements

Optimize drop multiplication for high XP levels and large farms.

Requirements:

- Avoid unnecessary allocations.
- Avoid redundant calculations.
- Avoid repeated loot processing.
- Respect each item's maximum stack size.
- Preserve data components on every copy.
- Prevent integer overflow.
- Prevent accidental loss of items.
- Avoid excessive network traffic.
- Never silently cap the multiplier or delete valid drops.

The optimized implementation must produce the same gameplay results as the intended original behavior.

## 12. Multiplayer Support

The server must be authoritative.

Each player must have an independent selected multiplier and disabled-drops state.

Requirements:

- Save player settings persistently.
- Synchronize multiplier changes to the client.
- Validate client requests on the server.
- Clamp invalid multiplier values.
- Handle login, logout, death, respawn, and dimension changes.
- Avoid duplicating drops when multiple players interact with the same entity.
- Prevent client-side manipulation of drop quantities.

The server must determine actual drop quantities.

## 13. Advanced Configuration

Add optional configuration settings for:

- Block drop multiplication.
- Mob drop multiplication.
- Container content multiplication.
- Block exclusions.
- Entity exclusions.
- Item exclusions.
- HUD appearance.
- Compatibility options.

**All gameplay options must default to the original behavior.**

NBT and data component preservation must always remain enabled and must never be optional.

Do not introduce new progression systems, currencies, artificial XP rewards, special equipment, or unrelated gameplay mechanics.

## 14. Compatibility

Use NeoForge-compatible event hooks where possible.

Respect:

- Vanilla loot tables.
- Modded loot tables.
- Fortune and Looting.
- Silk Touch.
- Enchanted equipment.
- Custom item data components.
- Modded blocks and entities.
- Container inventories.
- Dedicated server execution.

If an interaction cannot be handled safely, explain the limitation rather than implementing an unsafe duplication mechanism.

## 15. Testing and Acceptance Criteria

Create tests or clearly documented manual verification steps covering:

1. A new player at level 0 can obtain normal drops.
2. Level 10 produces exactly ten times eligible item drops.
3. Manually selecting Γ—3 at level 10 produces Γ—3 drops.
4. Disable Drops suppresses eligible items but not XP.
5. Breaking a chest multiplies its contents and block drop exactly once.
6. Enchanted items retain identical data components.
7. Multiplier selection persists after restarting the game.
8. Losing XP levels clamps the multiplier correctly.
9. Two multiplayer players maintain independent multipliers.
10. Multi-level enchantments can reach level 64.
11. Single-level enchantments retain their original maximum.
12. The `/enchant` command accepts valid expanded levels.
13. Anvil combinations are not blocked by "Too Expensive!".
14. Roman numeral tooltips display correctly.
15. The mod loads on a dedicated NeoForge 1.21.1 server.

## 16. Required Deliverables

Provide:

- Complete Java source code.
- Complete Gradle project.
- NeoForge mod metadata.
- Required resources and Mixins.
- Default configuration files.
- Localization files.
- Build instructions.
- A compiled Minecraft 1.21.1 NeoForge JAR, if the environment supports compilation.
- A list of implemented features.
- A list of unresolved limitations.
- Testing results, clearly distinguishing actual tests from unverified assumptions.

Do not claim that a feature works unless it has been implemented and tested.

## 17. Implementation Order

Build the mod incrementally in this order:

**Phase 1:** NeoForge project setup and successful compilation.

**Phase 2:** XP-based drop multiplication and level 0 protection.

**Phase 3:** Container multiplication and data component preservation.

**Phase 4:** Persistent settings, keybind, GUI, and HUD.

**Phase 5:** Multiplayer synchronization.

**Phase 6:** Enchantment level cap, anvil overhaul, and Roman numeral display.

**Phase 7:** Performance, compatibility, advanced settings, and testing.

At the end of each phase, verify that the project still compiles.

If the environment supports project files, modify the actual project rather than providing disconnected code snippets.

**Final instruction:** Prioritize correctness and preservation of the original Leveled Drops gameplay over adding new features. The finished mod must feel like a polished, faithful Minecraft 1.21.1 version of Leveled Drops 1.0.1.
Kodari AI
KodariNov 13 at 1:57 am 7
LeveledDrops
A NeoForge 1.21.1 mod that multiplies item drops based on player XP level. Players select a multiplier between 1 and their current level via a configurable GUI (default key M), with automatic Γ—1 protection at level 0. Features include container content multiplication with full data component preservation, disable drops mode, persistent per-player settings with server-authoritative multiplayer sync, expanded enchantment levels up to 64, anvil "Too Expensive" removal, and Roman numeral tooltip display. Includes configurable HUD, block/entity/item exclusions, and performance optimizations for large farms.
  • Build the NeoForge project and server-authoritative drop multiplier first.

  • Preserve item components and XP drops; document interactions that cannot yet be handled safely.

  • Include manual verification steps and clearly identify unfinished features.

Created an incomplete, unverified foundation for NeoForge 1.21.1: player-attributed block and mob drops scale with XP level, with level 0 protected at Γ—1. Item stack components are copied; XP drops are unchanged.

Container contents, multiplier selection, GUI/HUD, multiplayer synchronization, enchantment changes and anvil changes remain unimplemented. Other limitations and manual checks are listed in VERIFICATION.md. No original JAR was supplied, and no compilation or gameplay tests were run.

To build in Kodari, click Compile in the top bar, then Compile in the window. On success, click Download.

KingHassan23
πŸ“Ž 1 file 2,030 chars
πŸ“„
pasted-code-1794535448804.txt
txt 32 lines
β–Ά
The generated Leveled Drops JAR is incomplete.

I inspected the compiled JAR. It contains only one Java class, `com.kodari.leveleddrops.LeveledDrops`, which registers BlockDropsEvent and LivingDropsEvent handlers and multiplies item drops using `Math.max(1, player.experienceLevel)`.

This is only a partial implementation of the requested mod.

Please continue developing the existing NeoForge 1.21.1 project rather than starting over.

Fix and implement the following missing requirements:

1. Add a rebindable M keybind and functional multiplier configuration GUI.
2. Allow selecting a multiplier from Γ—1 to the player's current XP level, with Γ—1 as the minimum at level 0.
3. Add a Disable Drops button that deliberately sets the multiplier to Γ—0 without suppressing XP orbs.
4. Persist each player's multiplier and disabled state across sessions.
5. Implement a configurable Γ—N HUD indicator.
6. Ensure chest, barrel, and supported container contents are multiplied exactly once, preserving all item data components.
7. Implement enchantment levels up to 64, including anvil book combinations and `/enchant` support.
8. Remove the anvil's Too Expensive restriction while preserving rarity-based XP costs.
9. Display enchantment levels above X as Roman numerals followed by Arabic numbers, such as LXIV (64).
10. Add proper server-authoritative multiplayer synchronization.
11. Preserve correct attribution for eligible player-caused drops, including supported indirect kills.
12. Validate the NeoForge 1.21.1 event registrations and dedicated-server compatibility.

Preserve the current level 0 protection.

Use actual Java source files, resources, configuration classes, networking, and Mixins where necessary.

Compile the project after each major implementation phase. Report actual compilation errors and fix them.

Do not claim completion unless every requirement has been implemented and tested.

Provide the complete project and the newly compiled JAR, together with a feature checklist and any unresolved limitations.
Kodari AI
KodariNov 13 at 2:19 am 6
  1. Add persistent, server-authoritative multiplier selection and synchronization.

  2. Add the keybind, configuration screen and HUD.

  3. Address container drops, enchantments and anvils where the 1.21.1 hooks permit safe implementation.

  4. Document verification and any remaining limitations.

Extended the existing project with unverified implementations of multiplier selection, per-player persistence and server validation, an M-key screen, a HUD, and enchantment levels up to 64 with Roman-numeral formatting.

The mod is not complete. Container contents are not multiplied, the anvil’s β€œToo Expensive” restriction remains, HUD settings are limited and do not persist, and some indirect kills are not attributed. Dedicated-server compatibility and the new mixins have not been tested. See VERIFICATION.md for the checklist and limitations.

No compilation or gameplay tests were run, so I cannot provide a newly compiled JAR or report that the changes work. To build this version in Kodari, click Compile in the top bar, then Compile in the window; if successful, click Download.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
leveleddrops-1.0.1.jar
settings.gradle
VERIFICATION.md
Code
12 396
src/main/java/com/kodari/leveleddrops/LeveledDrops.java
package com.kodari.leveleddrops;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.Supplier;

import com.mojang.serialization.Codec;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
import net.neoforged.neoforge.event.level.BlockDropsEvent;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.attachment.AttachmentType;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
import net.neoforged.neoforge.network.PacketDistributor;

@Mod(LeveledDrops.MOD_ID)
public final class LeveledDrops {
    public static final String MOD_ID = "leveleddrops";
    private static final DeferredRegister<AttachmentType<?>> ATTACHMENTS =
            DeferredRegister.create(NeoForgeRegistries.Keys.ATTACHMENT_TYPES, MOD_ID);
    public static final Supplier<AttachmentType<Integer>> SELECTION = ATTACHMENTS.register("selection",
            () -> AttachmentType.builder(() -> -1).serialize(Codec.INT).copyOnDeath().build());
    private static final Map<UUID, Integer> LAST_SENT = new HashMap<>();

    public LeveledDrops(IEventBus modBus) {
        ATTACHMENTS.register(modBus);
        modBus.addListener(DropSelection::register);
        NeoForge.EVENT_BUS.addListener(BlockDropsEvent.class, LeveledDrops::onBlockDrops);
        NeoForge.EVENT_BUS.addListener(LivingDropsEvent.class, LeveledDrops::onLivingDrops);
        NeoForge.EVENT_BUS.addListener(PlayerTickEvent.Post.class, LeveledDrops::onPlayerTick);
        NeoForge.EVENT_BUS.addListener(PlayerEvent.PlayerLoggedOutEvent.class, LeveledDrops::onLogout);
        NeoForge.EVENT_BUS.addListener(PlayerEvent.PlayerRespawnEvent.class, LeveledDrops::onRespawn);
        NeoForge.EVENT_BUS.addListener(PlayerEvent.PlayerChangedDimensionEvent.class, LeveledDrops::onDimensionChange);
    }

    public static int effective(Player player) {
        int selection = player.getData(SELECTION.get());
        int max = Math.max(1, player.experienceLevel);
        return selection < 0 ? max : Math.min(selection, max);
    }

    private static void onPlayerTick(PlayerTickEvent.Post event) {
        if (!(event.getEntity() instanceof ServerPlayer player)) return;
        int selection = player.getData(SELECTION.get());
        int max = Math.max(1, player.experienceLevel);
        if (selection > max) {
            selection = max;
            player.setData(SELECTION.get(), selection);
        }
        int effective = effective(player);
        if (!Integer.valueOf(effective).equals(LAST_SENT.put(player.getUUID(), effective))) {
            PacketDistributor.sendToPlayer(player, new DropSelection(effective));
        }
    }

    private static void onLogout(PlayerEvent.PlayerLoggedOutEvent event) {
        LAST_SENT.remove(event.getEntity().getUUID());
    }

    private static void onRespawn(PlayerEvent.PlayerRespawnEvent event) {
        LAST_SENT.remove(event.getEntity().getUUID());
    }

    private static void onDimensionChange(PlayerEvent.PlayerChangedDimensionEvent event) {
        LAST_SENT.remove(event.getEntity().getUUID());
    }

    private static void onBlockDrops(BlockDropsEvent event) {
        if (event.getBreaker() instanceof ServerPlayer player) {
            multiply(event.getDrops(), effective(player));
        }
    }

    private static void onLivingDrops(LivingDropsEvent event) {
        if (!(event.getEntity() instanceof Player)
                && event.getSource().getEntity() instanceof ServerPlayer player) {
            multiply(event.getDrops(), effective(player));
        }
    }

    private static void multiply(Collection<ItemEntity> drops, int multiplier) {
        if (multiplier == 0) {
            drops.clear();
            return;
        }
        if (multiplier <= 1 || drops.isEmpty()) {
            return;
        }

        List<ItemEntity> additions = new ArrayList<>();
        for (ItemEntity drop : drops) {
            ItemStack stack = drop.getItem();
            if (stack.isEmpty()) {
                continue;
            }
            long remaining = (long) stack.getCount() * (multiplier - 1L);
            int maxStackSize = stack.getMaxStackSize();
            while (remaining > 0) {
                int count = (int) Math.min(remaining, maxStackSize);
                additions.add(new ItemEntity(drop.level(), drop.getX(), drop.getY(), drop.getZ(),
                        stack.copyWithCount(count)));
                remaining -= count;
            }
        }
        drops.addAll(additions);
    }
}