Dodge Cruel Death

Dodge Cruel Death

Extend live of items dropped on death

by
155 Downloads
fabric
Rent Server with this Mod

About this Mod

This code is written in Java and is a mixin for modifying the behavior of Minecraft, a popular sandbox game. The mixin is specifically designed to modify the dropItem method in a Minecraft class, changing how items are handled when an entity drops them. Let's break it down step by step:

Annotations

  • @Inject(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At("RETURN")): This annotation specifies that the mixin should inject code into the dropItem method. The method parameter specifies the signature of the method, including its name (dropItem), its parameters (Lnet/minecraft/item/ItemStack;ZZ), and its return type (Lnet/minecraft/entity/ItemEntity). The at parameter specifies where in the method to inject the code. In this case, it's injected at the RETURN point, meaning right before the method returns.

Method Signature

protected void onDropItem(final ItemStack stack, final boolean throwRandomly, final boolean retainOwnership, final CallbackInfoReturnable<ItemEntity> cir)
  • protected void onDropItem: This is the method being injected into the original dropItem method. It has the protected access modifier and returns void.
  • final ItemStack stack: The first parameter, stack, represents the item stack being dropped.
  • final boolean throwRandomly: The second parameter indicates whether the item should be thrown randomly.
  • final boolean retainOwnership: The third parameter indicates whether the entity should retain ownership of the item.
  • final CallbackInfoReturnable<ItemEntity> cir: This is a special parameter provided by mixin to get information about the method call, including its return value.

Method Body

  1. Check if the entity is alive:

    if (this.isAlive()) return;
    

    If the entity that dropped the item is still alive, the method returns immediately and does nothing. This ensures that the rest of the code only executes if the entity is not alive.

  2. Get the dropped item entity:

    final var entity = (ItemEntityAccessor) cir.getReturnValue();
    if (entity == null) return;
    

    The code retrieves the returned ItemEntity object from the original dropItem method using cir.getReturnValue(). If the returned entity is null, the method returns immediately and does nothing.

  3. Set the item age:

    entity.setItemAge(Short.MIN_VALUE + 1);
    

    If the entity is valid, its age is set to Short.MIN_VALUE + 1. In Minecraft, setting an item's age to Short.MIN_VALUE causes it to live indefinitely. By adding 1, it avoids the exact MIN_VALUE but still sets a very low age, effectively making the item last a very long time.

Summary

This mixin modifies the behavior of the dropItem method in Minecraft so that when an entity drops an item and the entity is not alive, the dropped item's age is set to a very low value, making the item live almost indefinitely. This is done by injecting code at the point where the original method returns, ensuring the modification happens only after the item has been successfully created and returned.

Available Versions

Dodge Cruel Death 1.1.0release
MC 1.21fabric
July 24, 2024

How to Install Dodge Cruel Death on Your Server

1

Order Server

Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).

2

Set fabric Loader

In the panel under "Egg", select the fabric loader and matching Minecraft version (1.21).

3

Install Mod

Open the mod browser in the dashboard and search for "Dodge Cruel Death". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.

Compatibility

Mod Loaders

fabric

Minecraft Versions

1.21

Server-side

~ Optional

Recommended RAM

4 GB(min. 3 GB)

Frequently Asked Questions

Dodge Cruel Death server crashes on startup – what to do?

Most common cause: wrong fabric version or insufficient RAM. Check the server log (latest.log) for "OutOfMemoryError" or "Mixin" errors. With Mado Hosting: ensure at least 3 GB RAM is allocated and the loader matches the mod version (1.21). You can switch loaders with one click in the panel.

Is Dodge Cruel Death compatible with fabric?

Dodge Cruel Death officially supports fabric for Minecraft 1.21. The Mado dashboard automatically detects incompatible loader combinations.

Server lagging with Dodge Cruel Death – how to optimize performance?

Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if Dodge Cruel Death consumes the most tick time. Common fixes: reduce server view-distance to 8-10, install "performant" or "starlight" as supplementary mods on Forge. With Mado Hosting, your server runs on NVMe SSDs with dedicated CPU cores for minimal latency.

Rent Modded Server

Install Dodge Cruel Death with just one click on your server.

Recommended RAM
4 GBab €8/mo
Min. 3 GB | +1 GB pro 8 Spieler
Create Server Now
1-Click Mod Install
NVMe SSD Storage
DDoS Protection included

Details

License
MIT License
Server-side
Optional

Supported Versions

1.21