Dodge Cruel Death

Quick rating

Dodge Cruel Death

No reviews yet

Extend live of items dropped on death

Mod Loaders
Fabric
Minecraft
1.21

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

Compatibility

Supported Environments

Dev Environment
Client Optional
Server Optional

About

Project Details

Type
Mod
License
MIT License
Latest Version
Dodge Cruel Death 1.1.0
Authors
CurseForge
Modrinth

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID
Modrinth ID

Resources

External Links

Source Issues Wiki Discord

About

Description

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.

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.

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

<1,000
Total Downloads
CurseForge
<1,000
Modrinth
<1,000
Last Updated
CurseForge
Created
CurseForge
Modrinth
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works