Skip to content

Instantly share code, notes, and snippets.

@wagyourtail
Last active January 16, 2023 20:16
Show Gist options
  • Save wagyourtail/059e32d741d2515daf4889c00f8931ca to your computer and use it in GitHub Desktop.
Save wagyourtail/059e32d741d2515daf4889c00f8931ca to your computer and use it in GitHub Desktop.
@Inject(method = "getEquipmentChanges", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), locals = LocalCapture.CAPTURE_FAILHARD
/************************************************************************************************************************************************************************/
/* Target Class : net.minecraft.world.entity.LivingEntity */
/* Target Method : private Map collectEquipmentChanges() */
/* Target Max LOCALS : 10 */
/* Initial Frame Size : 1 */
/* Callback Name : getEquipmentChanges */
/* Instruction : InjectionNode INVOKEINTERFACE */
/************************************************************************************************************************************************************************/
/* LOCAL TYPE NAME */
/* [ 0] LivingEntity this */
/* > [ 1] Map map <capture> */
/* [ 2] EquipmentSlot[] aenumitemslot <capture> */
/* [ 3] int i <capture> */
/* [ 4] - */
/* [ 5] EquipmentSlot enumitemslot <capture> */
/* [ 6] - */
/* [ 7] ItemStack itemstack1 <capture> */
/* [ 8] - */
/* [ 9] - */
/************************************************************************************************************************************************************************/
/* */
/* /** */
/* * Expected callback signature */
/* * / */
/* private void getEquipmentChanges(CallbackInfoReturnable<Map> cir, Map map, EquipmentSlot aenumitemslot[], int i, EquipmentSlot enumitemslot, ItemStack itemstack1) { */
/* // Method body */
/* } */
/* */
/************************************************************************************************************************************************************************/
// access flags 0x2
// signature ()Ljava/util/Map<Lnet/minecraft/world/entity/EquipmentSlot;Lnet/minecraft/world/item/ItemStack;>;
// declaration: java.util.Map<net.minecraft.world.entity.EquipmentSlot, net.minecraft.world.item.ItemStack> collectEquipmentChanges()
private collectEquipmentChanges()Ljava/util/Map;
@Ljavax/annotation/Nullable;()
L0
LINENUMBER 3085 L0
ACONST_NULL
ASTORE 1
L1
LINENUMBER 3086 L1
INVOKESTATIC net/minecraft/world/entity/EquipmentSlot.values ()[Lnet/minecraft/world/entity/EquipmentSlot;
ASTORE 2
L2
LINENUMBER 3087 L2
ALOAD 2
ARRAYLENGTH
ISTORE 3
L3
LINENUMBER 3089 L3
ICONST_0
ISTORE 4
L4
FRAME FULL [net/minecraft/world/entity/LivingEntity java/util/Map [Lnet/minecraft/world/entity/EquipmentSlot; I I] []
ILOAD 4
ILOAD 3
IF_ICMPGE L5
L6
LINENUMBER 3090 L6
ALOAD 2
ILOAD 4
AALOAD
ASTORE 5
L7
LINENUMBER 3093 L7
GETSTATIC net/minecraft/world/entity/EntityLiving$7.$SwitchMap$net$minecraft$world$entity$EquipmentSlot$Type : [I
ALOAD 5
INVOKEVIRTUAL net/minecraft/world/entity/EquipmentSlot.getType ()Lnet/minecraft/world/entity/EquipmentSlot$Type;
INVOKEVIRTUAL net/minecraft/world/entity/EquipmentSlot$Type.ordinal ()I
IALOAD
LOOKUPSWITCH
1: L8
2: L9
default: L10
L8
LINENUMBER 3095 L8
FRAME APPEND [net/minecraft/world/entity/EquipmentSlot]
ALOAD 0
ALOAD 5
INVOKEVIRTUAL net/minecraft/world/entity/LivingEntity.getLastHandItem (Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;
ASTORE 6
L11
LINENUMBER 3096 L11
GOTO L12
L9
LINENUMBER 3098 L9
FRAME SAME
ALOAD 0
ALOAD 5
INVOKEVIRTUAL net/minecraft/world/entity/LivingEntity.getLastArmorItem (Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;
ASTORE 6
L13
LINENUMBER 3099 L13
GOTO L12
L10
LINENUMBER 3101 L10
FRAME SAME
GOTO L14
L12
LINENUMBER 3104 L12
FRAME APPEND [net/minecraft/world/item/ItemStack]
ALOAD 0
ALOAD 5
INVOKEVIRTUAL net/minecraft/world/entity/LivingEntity.getItemBySlot (Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;
ASTORE 7
L15
LINENUMBER 3106 L15
ALOAD 0
ALOAD 6
ALOAD 7
INVOKEVIRTUAL net/minecraft/world/entity/LivingEntity.equipmentHasChanged (Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)Z
IFEQ L14
L16
LINENUMBER 3108 L16
ALOAD 0
INSTANCEOF net/minecraft/server/level/ServerPlayer
IFEQ L17
ALOAD 5
INVOKEVIRTUAL net/minecraft/world/entity/EquipmentSlot.getType ()Lnet/minecraft/world/entity/EquipmentSlot$Type;
GETSTATIC net/minecraft/world/entity/EquipmentSlot$Type.ARMOR : Lnet/minecraft/world/entity/EquipmentSlot$Type;
IF_ACMPNE L17
L18
LINENUMBER 3109 L18
ALOAD 6
INVOKESTATIC org/bukkit/craftbukkit/v1_19_R2/inventory/CraftItemStack.asBukkitCopy (Lnet/minecraft/world/item/ItemStack;)Lorg/bukkit/inventory/ItemStack;
ASTORE 8
L19
LINENUMBER 3110 L19
ALOAD 7
INVOKESTATIC org/bukkit/craftbukkit/v1_19_R2/inventory/CraftItemStack.asBukkitCopy (Lnet/minecraft/world/item/ItemStack;)Lorg/bukkit/inventory/ItemStack;
ASTORE 9
L20
LINENUMBER 3111 L20
NEW com/destroystokyo/paper/event/player/PlayerArmorChangeEvent
DUP
ALOAD 0
INVOKEVIRTUAL net/minecraft/world/entity/LivingEntity.getBukkitEntity ()Lorg/bukkit/craftbukkit/v1_19_R2/entity/CraftEntity;
CHECKCAST org/bukkit/entity/Player
ALOAD 5
INVOKEVIRTUAL net/minecraft/world/entity/EquipmentSlot.name ()Ljava/lang/String;
INVOKESTATIC com/destroystokyo/paper/event/player/PlayerArmorChangeEvent$SlotType.valueOf (Ljava/lang/String;)Lcom/destroystokyo/paper/event/player/PlayerArmorChangeEvent$SlotType;
ALOAD 8
ALOAD 9
INVOKESPECIAL com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.<init> (Lorg/bukkit/entity/Player;Lcom/destroystokyo/paper/event/player/PlayerArmorChangeEvent$SlotType;Lorg/bukkit/inventory/ItemStack;Lorg/bukkit/inventory/ItemStack;)V
INVOKEVIRTUAL com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.callEvent ()Z
POP
L17
LINENUMBER 3114 L17
FRAME APPEND [net/minecraft/world/item/ItemStack]
ALOAD 1
IFNONNULL L21
L22
LINENUMBER 3115 L22
LDC Lnet/minecraft/world/entity/EquipmentSlot;.class
INVOKESTATIC com/google/common/collect/Maps.newEnumMap (Ljava/lang/Class;)Ljava/util/EnumMap;
ASTORE 1
L21
LINENUMBER 3118 L21
FRAME SAME
ALOAD 1
ALOAD 5
ALOAD 7
INVOKEINTERFACE java/util/Map.put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; (itf)
POP
L23
LINENUMBER 3119 L23
ALOAD 6
INVOKEVIRTUAL net/minecraft/world/item/ItemStack.isEmpty ()Z
IFNE L24
L25
LINENUMBER 3120 L25
ALOAD 0
INVOKEVIRTUAL net/minecraft/world/entity/LivingEntity.getAttributes ()Lnet/minecraft/world/entity/ai/attributes/AttributeMap;
ALOAD 6
ALOAD 5
INVOKEVIRTUAL net/minecraft/world/item/ItemStack.getAttributeModifiers (Lnet/minecraft/world/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;
INVOKEVIRTUAL net/minecraft/world/entity/ai/attributes/AttributeMap.removeAttributeModifiers (Lcom/google/common/collect/Multimap;)V
L24
LINENUMBER 3123 L24
FRAME SAME
ALOAD 7
INVOKEVIRTUAL net/minecraft/world/item/ItemStack.isEmpty ()Z
IFNE L14
L26
LINENUMBER 3124 L26
ALOAD 0
INVOKEVIRTUAL net/minecraft/world/entity/LivingEntity.getAttributes ()Lnet/minecraft/world/entity/ai/attributes/AttributeMap;
ALOAD 7
ALOAD 5
INVOKEVIRTUAL net/minecraft/world/item/ItemStack.getAttributeModifiers (Lnet/minecraft/world/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;
INVOKEVIRTUAL net/minecraft/world/entity/ai/attributes/AttributeMap.addTransientAttributeModifiers (Lcom/google/common/collect/Multimap;)V
L14
LINENUMBER 3089 L14
FRAME CHOP 3
IINC 4 1
GOTO L4
L5
LINENUMBER 3129 L5
FRAME CHOP 1
ALOAD 1
ARETURN
L27
LOCALVARIABLE itemstack Lnet/minecraft/world/item/ItemStack; L11 L9 6
LOCALVARIABLE itemstack Lnet/minecraft/world/item/ItemStack; L13 L10 6
LOCALVARIABLE oldItem Lorg/bukkit/inventory/ItemStack; L19 L17 8
LOCALVARIABLE newItem Lorg/bukkit/inventory/ItemStack; L20 L17 9
LOCALVARIABLE enumitemslot Lnet/minecraft/world/entity/EquipmentSlot; L7 L14 5
LOCALVARIABLE itemstack Lnet/minecraft/world/item/ItemStack; L12 L14 6
LOCALVARIABLE itemstack1 Lnet/minecraft/world/item/ItemStack; L15 L14 7
LOCALVARIABLE j I L4 L5 4
LOCALVARIABLE this Lnet/minecraft/world/entity/LivingEntity; L0 L27 0
LOCALVARIABLE map Ljava/util/Map; L1 L27 1
// signature Ljava/util/Map<Lnet/minecraft/world/entity/EquipmentSlot;Lnet/minecraft/world/item/ItemStack;>;
// declaration: map extends java.util.Map<net.minecraft.world.entity.EquipmentSlot, net.minecraft.world.item.ItemStack>
LOCALVARIABLE aenumitemslot [Lnet/minecraft/world/entity/EquipmentSlot; L2 L27 2
LOCALVARIABLE i I L3 L27 3
MAXSTACK = 6
MAXLOCALS = 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment