Skip to content

Commit

Permalink
Renamed Methods
Browse files Browse the repository at this point in the history
 - Renamed methods for the purposed of appropriate blame in debugging
  • Loading branch information
chronosacaria committed Jun 27, 2023
1 parent 82f7ba0 commit 4dead3e
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 64 deletions.
38 changes: 19 additions & 19 deletions src/main/java/chronosacaria/mcdw/api/util/PlayerAttackHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@
public class PlayerAttackHelper {

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public static boolean isLikelyNotMeleeDamage(DamageSource damageSource){
public static boolean mcdw$isLikelyNotMeleeDamage(DamageSource damageSource){
return damageSource.isOf(DamageTypes.ON_FIRE)
|| damageSource.isOf(DamageTypes.EXPLOSION)
|| damageSource.isOf(DamageTypes.MAGIC)
|| damageSource.isOf(DamageTypes.ARROW)
|| !isDirectDamage(damageSource);
|| !mcdw$isDirectDamage(damageSource);
}

private static boolean isDirectDamage(DamageSource damageSource){
private static boolean mcdw$isDirectDamage(DamageSource damageSource){
return damageSource.isOf(DamageTypes.MOB_ATTACK)
|| damageSource.isOf(DamageTypes.PLAYER_ATTACK);
}

public static void switchModifiers(PlayerEntity player, ItemStack switchFrom, ItemStack switchTo) {
public static void mcdw$switchModifiers(PlayerEntity player, ItemStack switchFrom, ItemStack switchTo) {
player.getAttributes().removeModifiers(switchFrom.getAttributeModifiers(EquipmentSlot.MAINHAND));
player.getAttributes().addTemporaryModifiers(switchTo.getAttributeModifiers(EquipmentSlot.MAINHAND));
}

public static void offhandAttack(PlayerEntity playerEntity, Entity target) {
public static void mcdw$offhandAttack(PlayerEntity playerEntity, Entity target) {
if (CompatibilityFlags.noOffhandConflicts) {
if (!target.isAttackable())
if (target.handleAttack(playerEntity))
Expand All @@ -65,14 +65,14 @@ public static void offhandAttack(PlayerEntity playerEntity, Entity target) {
ItemStack offhandStack = playerEntity.getOffHandStack();

// use offhand modifiers
switchModifiers(playerEntity, playerEntity.getMainHandStack(), offhandStack);
mcdw$switchModifiers(playerEntity, playerEntity.getMainHandStack(), offhandStack);

float cooldownProgress = ((IDualWielding) playerEntity).getOffhandAttackCooldownProgress(0.5F);
float attackDamage = (float) playerEntity.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE);
attackDamage *= 0.2f + Math.pow(cooldownProgress, 2) * 0.8f;

// use mainhand modifiers
switchModifiers(playerEntity, offhandStack, playerEntity.getMainHandStack());
mcdw$switchModifiers(playerEntity, offhandStack, playerEntity.getMainHandStack());

float enchantBonusDamage = EnchantmentHelper.getAttackDamage(offhandStack, target instanceof LivingEntity livingTarget ?
livingTarget.getGroup() : EntityGroup.DEFAULT) * cooldownProgress;
Expand Down Expand Up @@ -229,7 +229,7 @@ public static void offhandAttack(PlayerEntity playerEntity, Entity target) {
* <a href = "https://github.com/JamiesWhiteShirt/reach-entity-attributes/blob/1.19/src/main/java/com/jamieswhiteshirt/reachentityattributes/ReachEntityAttributes.java#L27">ReachEntityAttributes Lines 27-30</a>
*/

public static double getReachDistance(LivingEntity livingEntity, double defaultReachDistance) {
public static double mcdw$getReachDistance(LivingEntity livingEntity, double defaultReachDistance) {
@Nullable
EntityAttributeInstance reachDistance = livingEntity.getAttributeInstance(EntityAttributesRegistry.REACH);
return (reachDistance != null) ? (defaultReachDistance + reachDistance.getValue()) : defaultReachDistance;
Expand All @@ -256,8 +256,8 @@ public static double getReachDistance(LivingEntity livingEntity, double defaultR
* <a href = "https://github.com/JamiesWhiteShirt/reach-entity-attributes/blob/1.19/src/main/java/com/jamieswhiteshirt/reachentityattributes/ReachEntityAttributes.java#L32">ReachEntityAttributes Lines 32-35</a>
*/
@SuppressWarnings("unused")
public static double getSquaredReachDistance(LivingEntity livingEntity, double squareDefaultReachDistance) {
double reachDistance = getReachDistance(livingEntity, Math.sqrt(squareDefaultReachDistance));
public static double mcdw$getSquaredReachDistance(LivingEntity livingEntity, double squareDefaultReachDistance) {
double reachDistance = mcdw$getReachDistance(livingEntity, Math.sqrt(squareDefaultReachDistance));
return reachDistance * reachDistance;
}

Expand All @@ -281,7 +281,7 @@ public static double getSquaredReachDistance(LivingEntity livingEntity, double s
* The following code is from Reach Entity Attributes and can be found here:
* <a href = "https://github.com/JamiesWhiteShirt/reach-entity-attributes/blob/1.19/src/main/java/com/jamieswhiteshirt/reachentityattributes/ReachEntityAttributes.java#L37">ReachEntityAttributes Lines 37-40</a>
*/
public static double getAttackRange(LivingEntity livingEntity, double defaultAttackRange) {
public static double mcdw$getAttackRange(LivingEntity livingEntity, double defaultAttackRange) {
@Nullable
EntityAttributeInstance attackRange = livingEntity.getAttributeInstance(EntityAttributesRegistry.ATTACK_RANGE);
return (attackRange != null) ? (defaultAttackRange + attackRange.getValue()) : defaultAttackRange;
Expand All @@ -307,8 +307,8 @@ public static double getAttackRange(LivingEntity livingEntity, double defaultAtt
* The following code is from Reach Entity Attributes and can be found here:
* <a href = "https://github.com/JamiesWhiteShirt/reach-entity-attributes/blob/1.19/src/main/java/com/jamieswhiteshirt/reachentityattributes/ReachEntityAttributes.java#L42">ReachEntityAttributes Lines 42-45</a>
*/
public static double getSquaredAttackRange(LivingEntity livingEntity, double squareDefaultAttackRange) {
double attackRange = getAttackRange(livingEntity, Math.sqrt(squareDefaultAttackRange));
public static double mcdw$getSquaredAttackRange(LivingEntity livingEntity, double squareDefaultAttackRange) {
double attackRange = mcdw$getAttackRange(livingEntity, Math.sqrt(squareDefaultAttackRange));
return attackRange * attackRange;
}

Expand All @@ -333,8 +333,8 @@ public static double getSquaredAttackRange(LivingEntity livingEntity, double squ
* <a href = "https://github.com/JamiesWhiteShirt/reach-entity-attributes/blob/1.19/src/main/java/com/jamieswhiteshirt/reachentityattributes/ReachEntityAttributes.java#L47">ReachEntityAttributes Lines 47-49</a>
*/
@SuppressWarnings("unused")
public static List<PlayerEntity> getPlayerEntitiesWithinReach(World world, int x, int y, int z, double defaultReachDistance) {
return getPlayerEntitiesWithinReach(player -> true, world, x, y, z, defaultReachDistance);
public static List<PlayerEntity> mcdw$getPlayerEntitiesWithinReach(World world, int x, int y, int z, double defaultReachDistance) {
return mcdw$getPlayerEntitiesWithinReach(player -> true, world, x, y, z, defaultReachDistance);
}

/**
Expand All @@ -357,11 +357,11 @@ public static List<PlayerEntity> getPlayerEntitiesWithinReach(World world, int x
* The following code is from Reach Entity Attributes and can be found here:
* <a href = "https://github.com/JamiesWhiteShirt/reach-entity-attributes/blob/1.19/src/main/java/com/jamieswhiteshirt/reachentityattributes/ReachEntityAttributes.java#L51">ReachEntityAttributes Lines 51-65</a>
*/
public static List<PlayerEntity> getPlayerEntitiesWithinReach(Predicate<PlayerEntity> viewerPredicate, World world, int x, int y, int z, double defaultReachDistance) {
public static List<PlayerEntity> mcdw$getPlayerEntitiesWithinReach(Predicate<PlayerEntity> viewerPredicate, World world, int x, int y, int z, double defaultReachDistance) {
List<PlayerEntity> playerEntitiesWithinReach = new ArrayList<>();
for (PlayerEntity playerEntity : world.getPlayers()) {
if (viewerPredicate.test(playerEntity)) {
double reach = getReachDistance(playerEntity, defaultReachDistance);
double reach = mcdw$getReachDistance(playerEntity, defaultReachDistance);
double dx = (x + 0.5) - playerEntity.getX();
double dy = (y + 0.5) - playerEntity.getEyeY();
double dz = (z + 0.5) - playerEntity.getZ();
Expand Down Expand Up @@ -393,7 +393,7 @@ public static List<PlayerEntity> getPlayerEntitiesWithinReach(Predicate<PlayerEn
* The following code is from Reach Entity Attributes and can be found here:
* <a href = "https://github.com/JamiesWhiteShirt/reach-entity-attributes/blob/1.19/src/main/java/com/jamieswhiteshirt/reachentityattributes/ReachEntityAttributes.java#L67">ReachEntityAttributes Lines 67-69</a>
*/
public static boolean isEntityWithinAttackRange(PlayerEntity playerEntity, Entity entity) {
return playerEntity.squaredDistanceTo(entity) <= getSquaredAttackRange(playerEntity, 64);
public static boolean mcdw$isEntityWithinAttackRange(PlayerEntity playerEntity, Entity entity) {
return playerEntity.squaredDistanceTo(entity) <= mcdw$getSquaredAttackRange(playerEntity, 64);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@

public class ProjectileEffectHelper {

public static void spawnExtraArrows(LivingEntity owner, LivingEntity makeArrowFromMe, int numArrowsLimit, int distance, double bonusShotDamageMultiplier) {
List<LivingEntity> nearbyEntities = getSecondaryTargets(makeArrowFromMe, distance);
public static void mcdw$spawnExtraArrows(LivingEntity owner, LivingEntity makeArrowFromMe, int numArrowsLimit, int distance, double bonusShotDamageMultiplier) {
List<LivingEntity> nearbyEntities = mcdw$getSecondaryTargets(makeArrowFromMe, distance);
for (int i = 0; i < Math.min(numArrowsLimit, nearbyEntities.size()); i++) {
PersistentProjectileEntity arrowEntity = createProjectileEntityTowards(makeArrowFromMe, nearbyEntities.get(i));
PersistentProjectileEntity arrowEntity = mcdw$createProjectileEntityTowards(makeArrowFromMe, nearbyEntities.get(i));
arrowEntity.setDamage(arrowEntity.getDamage() * bonusShotDamageMultiplier);
arrowEntity.setOwner(owner);
makeArrowFromMe.getWorld().spawnEntity(arrowEntity);
}
}

public static PersistentProjectileEntity createAbstractArrow(LivingEntity attacker) {
public static PersistentProjectileEntity mcdw$createAbstractArrow(LivingEntity attacker) {
return ((ArrowItem) Items.ARROW).createArrow(attacker.getEntityWorld(), new ItemStack(Items.ARROW), attacker);
}

public static void fireChainReactionProjectileFromTarget(World world, LivingEntity attacker, LivingEntity target,
float v1, float v2) {
public static void mcdw$fireChainReactionProjectileFromTarget(World world, LivingEntity attacker, LivingEntity target,
float v1, float v2) {
if (!world.isClient) {
for (int i = 0 ; i < 4 ; i++) {
PersistentProjectileEntity projectile = createAbstractArrow(attacker);
PersistentProjectileEntity projectile = mcdw$createAbstractArrow(attacker);
if (attacker instanceof PlayerEntity) {
projectile.setCritical(true);
}
Expand All @@ -57,27 +57,27 @@ public static void fireChainReactionProjectileFromTarget(World world, LivingEnti
}
}

public static List<LivingEntity> getSecondaryTargets(LivingEntity source, double distance) {
public static List<LivingEntity> mcdw$getSecondaryTargets(LivingEntity source, double distance) {
List<LivingEntity> nearbyEntities = AOEHelper.getEntitiesByConfig(source, (float) distance);
if (nearbyEntities.size() < 2) return Collections.emptyList();

nearbyEntities.sort(Comparator.comparingDouble(livingEntity -> livingEntity.squaredDistanceTo(source)));
return nearbyEntities;
}

public static PersistentProjectileEntity createProjectileEntityTowards(LivingEntity source, LivingEntity target) {
PersistentProjectileEntity projectile = createAbstractArrow(source);
public static PersistentProjectileEntity mcdw$createProjectileEntityTowards(LivingEntity source, LivingEntity target) {
PersistentProjectileEntity projectile = mcdw$createAbstractArrow(source);
// borrowed from AbstractSkeletonEntity
double towardsX = target.getX() - source.getX();
double towardsZ = target.getZ() - source.getZ();
double euclideanDist = MathHelper.hypot(towardsX, towardsZ);
double towardsY = target.getBodyY(0.3333333333333333D) - projectile.getY() + euclideanDist * 0.2d;
setProjectileTowards(projectile, towardsX, towardsY, towardsZ);
mcdw$setProjectileTowards(projectile, towardsX, towardsY, towardsZ);
projectile.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
return projectile;
}

public static void setProjectileTowards(ProjectileEntity projectileEntity, double x, double y, double z) {
public static void mcdw$setProjectileTowards(ProjectileEntity projectileEntity, double x, double y, double z) {
Vec3d vec3d = new Vec3d(x, y, z).normalize();
projectileEntity.setVelocity(vec3d);
float f = MathHelper.sqrt((float) projectileEntity.squaredDistanceTo(vec3d));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ public static void applyChainReaction(LivingEntity shooter, LivingEntity target,
if (chainReactionLevel > 0) {

if (CleanlinessHelper.percentToOccur(CONFIG_CHANCE.get(EnchantmentsID.CHAIN_REACTION) * chainReactionLevel)){
ProjectileEffectHelper.fireChainReactionProjectileFromTarget(target.getEntityWorld(), target, shooter,
ProjectileEffectHelper.mcdw$fireChainReactionProjectileFromTarget(target.getEntityWorld(), target, shooter,
3.15F,1.0F);
}
}
Expand Down Expand Up @@ -756,7 +756,7 @@ public static void applyRicochet(LivingEntity shooter, LivingEntity target, Pers

float damageMultiplier = 0.03F + (ricochetLevel * 0.07F);
if (ppe.getVelocity().length() > 0.7F)
ProjectileEffectHelper.spawnExtraArrows(shooter, target, 1, 10, damageMultiplier);
ProjectileEffectHelper.mcdw$spawnExtraArrows(shooter, target, 1, 10, damageMultiplier);
}
}

Expand Down Expand Up @@ -818,7 +818,7 @@ public static void activateBurstBowstringOnJump(LivingEntity jumpingEntity) {
int availableArrows = Math.min(InventoryHelper.mcdw$countItem(attackingPlayer, Items.ARROW), burstBowstringLevel);
if (availableArrows < 1) return; //Avoid area lookup

ProjectileEffectHelper.spawnExtraArrows(jumpingEntity, jumpingEntity, availableArrows, 16, 0.4F);
ProjectileEffectHelper.mcdw$spawnExtraArrows(jumpingEntity, jumpingEntity, availableArrows, 16, 0.4F);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/chronosacaria/mcdw/mixin/mcdw/BowItemMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public void setLivingEntity(LivingEntity livingEntity){
float damageMultiplier = 0.03F + (bonusShotLevel * 0.07F);
float arrowVelocity = RangedAttackHelper.getVanillaOrModdedBowArrowVelocity(stack, remainingUseTicks);
if (arrowVelocity >= 0.1F){
ProjectileEffectHelper.spawnExtraArrows(user, user, 1, 10, damageMultiplier);
ProjectileEffectHelper.mcdw$spawnExtraArrows(user, user, 1, 10, damageMultiplier);
}
}
}
if (Mcdw.CONFIG.mcdwEnchantmentsConfig.ENABLE_ENCHANTMENTS.get(EnchantmentsID.MULTI_SHOT)) {
int multiShotLevel = EnchantmentHelper.getLevel(Enchantments.MULTISHOT, stack);
if (multiShotLevel > 0) {
PersistentProjectileEntity projectile = ProjectileEffectHelper.createAbstractArrow(user);
PersistentProjectileEntity projectile = ProjectileEffectHelper.mcdw$createAbstractArrow(user);
LivingEntity target = user.getAttacking();
if (target != null) { // \/\/ Taken from AbstractSkeletonEntity
double d = target.getX() - user.getX();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Mixin(net.minecraft.screen.CraftingScreenHandler.class)
public class CraftingScreenHandlerMixin {
@ModifyVariable(method = "updateResult", at = @At(value = "STORE"), ordinal = 1)
private static ItemStack innateItemStack(ItemStack itemStack) {
private static ItemStack mcdw$innateItemStack(ItemStack itemStack) {
if (itemStack.getItem() instanceof IInnateEnchantment innateEnchantedItem) {
Map<Enchantment, Integer> map = innateEnchantedItem.getInnateEnchantments();
if (map == null) return itemStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class CrossbowItemMixin {
float damageMultiplier = 0.1F + ((bonusShotLevel - 1) * 0.07F);

float arrowVelocity = RangedAttackHelper.getVanillaOrModdedCrossbowArrowVelocity(crossbow);
ProjectileEffectHelper.spawnExtraArrows(user, user, 1, 10, damageMultiplier);
ProjectileEffectHelper.mcdw$spawnExtraArrows(user, user, 1, 10, damageMultiplier);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@Mixin(EnchantmentHelper.class)
public class EnchantmentHelperMixin {
@Inject(method = "getPossibleEntries", at = @At("RETURN"))
private static void getPossibleEntries_RETURN_SpellEngine(int power, ItemStack stack, boolean treasureAllowed, CallbackInfoReturnable<List<EnchantmentLevelEntry>> cir) {
private static void mcdw$getPossibleEntries(int power, ItemStack stack, boolean treasureAllowed, CallbackInfoReturnable<List<EnchantmentLevelEntry>> cir) {
var currentEntries = cir.getReturnValue();

// 1. REMOVING ENCHANT ENTRIES ADDED INCORRECTLY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public LivingEntityMixin(EntityType<?> type, World world) {
}

@Inject(method = "applyDamage", at = @At("HEAD"))
private void onAttack(DamageSource source, float amount, CallbackInfo ci) {
private void mcdw$onAttack(DamageSource source, float amount, CallbackInfo ci) {
var attacker = source.getAttacker();
var target = (LivingEntity) ((Object)this);
if (target.isInvulnerableTo(source)) {
Expand Down Expand Up @@ -207,7 +207,7 @@ private void onAttack(DamageSource source, float amount, CallbackInfo ci) {
}

@Inject(method = "applyDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setHealth(F)V"))
public void applySharedPainDamage(DamageSource source, float amount, CallbackInfo ci) {
public void mcdw$applySharedPainDamage(DamageSource source, float amount, CallbackInfo ci) {
if (source.getSource() instanceof PlayerEntity player) {
int sharedPainLevel = EnchantmentEffects.mcdw$getEnchantmentLevel(EnchantsRegistry.SHARED_PAIN, player, false);
if (sharedPainLevel <= 0) return;
Expand Down
Loading

0 comments on commit 4dead3e

Please sign in to comment.