Skip to content

Instantly share code, notes, and snippets.

@Haven-King
Last active November 25, 2020 17:26
Show Gist options
  • Save Haven-King/571d1d55814bd1e55aa7bd5314a4278c to your computer and use it in GitHub Desktop.
Save Haven-King/571d1d55814bd1e55aa7bd5314a4278c to your computer and use it in GitHub Desktop.
package hephaestus.dev.automotion.mixin.item;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.util.Rarity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Slice;
@Mixin(Items.class)
public class EpicCookie {
@ModifyArg(method = "<clinit>",
slice = @Slice(
from = @At(
// We're going to be looking at everything after the constant with the value 'cookie'
value = "CONSTANT",
args = "stringValue=cookie"
)
),
at = @At(
// We want to modify the args when the constructor for Item is invoked
value = "INVOKE",
// The descriptor for the constructor
target = "Lnet/minecraft/item/Item;<init>(Lnet/minecraft/item/Item$Settings;)V",
// We only want to modify the args for the first constructor
ordinal = 0
)
)
private static Item.Settings adjustItemSettings(Item.Settings settings) {
return settings.rarity(Rarity.EPIC);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment