Skip to content

Commit bc4008c

Browse files
committed
Fix indexing of private methods in call hierarchy walker
1 parent 949146c commit bc4008c

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

regressionTests/playerRandomHierarchy.regressiontest

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.apply (Ln
3030
net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.apply (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/LivingEntity;)Z <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
3131
net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.apply (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/LivingEntity;)Z <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
3232
net/minecraft/world/item/enchantment/Enchantment.modifyDamageFilteredValue (Lnet/minecraft/core/component/DataComponentType;Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/item/enchantment/Enchantment.lambda$modifyDamageFilteredValue$7 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
33-
net/minecraft/world/item/enchantment/Enchantment.modifyEntityFilteredValue (Lnet/minecraft/core/component/DataComponentType;Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/item/enchantment/Enchantment.lambda$modifyEntityFilteredValue$6 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
33+
net/minecraft/world/item/enchantment/Enchantment.modifyFishingLuckBonus (Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/item/enchantment/Enchantment.modifyEntityFilteredValue <- net/minecraft/world/item/enchantment/Enchantment.lambda$modifyEntityFilteredValue$6 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
34+
net/minecraft/world/item/enchantment/Enchantment.modifyFishingTimeReduction (Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/item/enchantment/Enchantment.modifyEntityFilteredValue <- net/minecraft/world/item/enchantment/Enchantment.lambda$modifyEntityFilteredValue$6 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
35+
net/minecraft/world/item/enchantment/Enchantment.modifyMobExperience (Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/item/enchantment/Enchantment.modifyEntityFilteredValue <- net/minecraft/world/item/enchantment/Enchantment.lambda$modifyEntityFilteredValue$6 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
36+
net/minecraft/world/item/enchantment/Enchantment.modifyProjectileCount (Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/item/enchantment/Enchantment.modifyEntityFilteredValue <- net/minecraft/world/item/enchantment/Enchantment.lambda$modifyEntityFilteredValue$6 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
37+
net/minecraft/world/item/enchantment/Enchantment.modifyProjectileSpread (Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/item/enchantment/Enchantment.modifyEntityFilteredValue <- net/minecraft/world/item/enchantment/Enchantment.lambda$modifyEntityFilteredValue$6 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
38+
net/minecraft/world/item/enchantment/Enchantment.modifyTridentReturnToOwnerAcceleration (Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/item/enchantment/Enchantment.modifyEntityFilteredValue <- net/minecraft/world/item/enchantment/Enchantment.lambda$modifyEntityFilteredValue$6 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
3439
net/minecraft/world/item/enchantment/Enchantment.modifyDamageProtection (Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lorg/apache/commons/lang3/mutable/MutableFloat;)V <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
3540
net/minecraft/world/entity/ExperienceOrb.repairPlayerItems (Lnet/minecraft/server/level/ServerPlayer;I)I <- net/minecraft/world/item/enchantment/EnchantmentHelper.getRandomItemWith <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
3641
net/minecraft/world/item/enchantment/EnchantmentHelper.getTridentSpinAttackStrength (Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/LivingEntity;)F <- net/minecraft/world/item/enchantment/EnchantmentHelper.lambda$getTridentSpinAttackStrength$36 <- net/minecraft/world/entity/Entity.getRandom <- net/minecraft/world/entity/Entity.random
@@ -78,9 +83,7 @@ net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/
7883
net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/world/entity/Entity.random
7984
net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/world/entity/Entity.random
8085
net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/world/entity/Entity.random
81-
net/minecraft/world/entity/LivingEntity.makeDrownParticles ()V <- net/minecraft/world/entity/Entity.random
82-
net/minecraft/world/entity/LivingEntity.makeDrownParticles ()V <- net/minecraft/world/entity/Entity.random
83-
net/minecraft/world/entity/LivingEntity.makeDrownParticles ()V <- net/minecraft/world/entity/Entity.random
86+
net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/world/entity/LivingEntity.makeDrownParticles <- net/minecraft/world/entity/Entity.random
8487
net/minecraft/world/entity/LivingEntity.makePoofParticles ()V <- net/minecraft/world/entity/Entity.random
8588
net/minecraft/world/entity/LivingEntity.makePoofParticles ()V <- net/minecraft/world/entity/Entity.random
8689
net/minecraft/world/entity/LivingEntity.makePoofParticles ()V <- net/minecraft/world/entity/Entity.random

src/test/java/net/earthcomputer/clientcommands/test/ReferencesFinder.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,10 @@ private static ReferencesSet resolveNonVirtualMethod(@Nullable ClassInfo owner,
210210
return null;
211211
}
212212

213-
// finds the most abstract versions of the method as if referenced by a virtual method instruction, of which there could
214-
// be multiple in the case of multiple interface inheritance
213+
// Finds the most abstract versions of the method as if referenced by a virtual method instruction, of which there could
214+
// be multiple in the case of multiple interface inheritance.
215+
// Does not resolve private methods, for that, call resolveNonVirtualMethod after calling this method if this method
216+
// returns nothing while indexing.
215217
private static List<ReferencesSet> resolveVirtualMethod(String accessorClass, ClassInfo owner, NameAndDesc nameAndDesc, ClassResolver resolver) {
216218
ReferencesSet resolvedInClass = null;
217219
List<ReferencesSet> resolvedInInterfaces = new ArrayList<>();
@@ -511,9 +513,16 @@ public void visitMethodInsn(int opcode, String owner, String name, String descri
511513
} else {
512514
ClassInfo ownerInfo = getOrCreateClassInfo(interner, owner);
513515
if (ownerInfo != null) {
514-
for (ReferencesSet references : resolveVirtualMethod(methodOwnerNameAndDesc.owner, ownerInfo, new NameAndDesc(name, descriptor), className -> getOrCreateClassInfo(interner, className))) {
516+
List<ReferencesSet> resolved = resolveVirtualMethod(methodOwnerNameAndDesc.owner, ownerInfo, new NameAndDesc(name, descriptor), className -> getOrCreateClassInfo(interner, className));
517+
for (ReferencesSet references : resolved) {
515518
references.add(methodOwnerNameAndDesc);
516519
}
520+
if (resolved.isEmpty()) {
521+
ReferencesSet resolvedNonVirtual = resolveNonVirtualMethod(ownerInfo, new NameAndDesc(name, descriptor), className -> getOrCreateClassInfo(interner, className));
522+
if (resolvedNonVirtual != null) {
523+
resolvedNonVirtual.add(methodOwnerNameAndDesc);
524+
}
525+
}
517526
}
518527
}
519528
}

0 commit comments

Comments
 (0)