tutorial:mixin_redirectors_methods
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tutorial:mixin_redirectors_methods [2020/08/17 00:58] – created user11681 | tutorial:mixin_redirectors_methods [2021/01/15 04:20] (current) – Fix instance method example - removed "static" modifier & rename class obw | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| Method redirectors can use the following [[https:// | Method redirectors can use the following [[https:// | ||
| + | |||
| * '' | * '' | ||
| * '' | * '' | ||
| Line 9: | Line 10: | ||
| The '' | The '' | ||
| - | ==== redirecting | + | ==== Redirecting |
| Static method redirectors should have the same parameters as the '' | Static method redirectors should have the same parameters as the '' | ||
| redirecting the '' | redirecting the '' | ||
| + | |||
| <code java [enable_line_numbers=true]> | <code java [enable_line_numbers=true]> | ||
| - | @Mixin(ItemStack.class) | + | @Mixin(SimpleInventory.class) |
| - | class ItemStackMixin | + | abstract |
| @Redirect(method = " | @Redirect(method = " | ||
| at = @At(value = " | at = @At(value = " | ||
| Line 25: | Line 27: | ||
| </ | </ | ||
| - | ==== redirecting | + | ==== Redirecting |
| Instance method redirectors are similar to static methood redirectors, | Instance method redirectors are similar to static methood redirectors, | ||
| redirecting the '' | redirecting the '' | ||
| + | |||
| <code java [enable_line_numbers=true]> | <code java [enable_line_numbers=true]> | ||
| @Mixin(Entity.class) | @Mixin(Entity.class) | ||
| - | class ItemStackMixin | + | abstract |
| @Redirect(method = " | @Redirect(method = " | ||
| at = @At(value = " | at = @At(value = " | ||
| - | private | + | private ItemEntity replaceDroppedItem(Entity droppingEntity, |
| return droppingEntity.dropItem(item == Items.DIAMOND ? Items.AIR : item, yOffset); | return droppingEntity.dropItem(item == Items.DIAMOND ? Items.AIR : item, yOffset); | ||
| } | } | ||
| Line 46: | Line 49: | ||
| redirecting the '' | redirecting the '' | ||
| + | |||
| <code java [enable_line_numbers=true]> | <code java [enable_line_numbers=true]> | ||
| @Mixin(MinecraftClient.class) | @Mixin(MinecraftClient.class) | ||
| - | class MinecraftClientMixin { | + | abstract |
| @Redirect(method = " | @Redirect(method = " | ||
| at = @At(value = " | at = @At(value = " | ||
| Line 59: | Line 63: | ||
| } | } | ||
| </ | </ | ||
| + | |||
tutorial/mixin_redirectors_methods.1597625902.txt.gz · Last modified: 2020/08/17 00:58 by user11681