Fix attack cooldown bar showing when out of reach of target. Closes #8639 (#8640)

This commit is contained in:
Brennan Ward authored and GitHub committed 2022-05-31 11:07:22 -07:00
1 parent 8d14797416
commit 03c43cf3da
2 files changed
+20

No files matched your search

@@ -1,5 +1,13 @@
--- a/net/minecraft/client/gui/Gui.java
+++ b/net/minecraft/client/gui/Gui.java
@@ -411,6 +_,7 @@
if (this.f_92986_.f_91076_ != null && this.f_92986_.f_91076_ instanceof LivingEntity && f >= 1.0F) {
flag = this.f_92986_.f_91074_.m_36333_() > 5.0F;
flag &= this.f_92986_.f_91076_.m_6084_();
+ flag &= this.f_92986_.f_91074_.canHit(this.f_92986_.f_91076_, 0);
}
int j = this.f_92978_ / 2 - 7 + 16;
@@ -463,6 +_,10 @@
for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) {
@@ -23,6 +23,8 @@ import net.minecraftforge.common.crafting.DifferenceIngredient;
import net.minecraftforge.common.crafting.IntersectionIngredient;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.common.data.ForgeFluidTagsProvider;
import net.minecraftforge.common.extensions.IForgeEntity;
import net.minecraftforge.common.extensions.IForgePlayer;
import net.minecraftforge.common.loot.CanToolPerformAction;
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
import net.minecraftforge.common.loot.LootTableIdCondition;
@@ -94,13 +96,23 @@ public class ForgeMod
/**
* Reach Distance represents the distance at which a player may interact with the world. The default is 4.5 blocks. Players in creative mode have an additional 0.5 blocks of reach distance.
* @see IForgePlayer#getReachDistance()
* @see IForgePlayer#canInteractWith(BlockPos, double)
* @see IForgePlayer#canInteractWith(Entity, double)
*/
public static final RegistryObject<Attribute> REACH_DISTANCE = ATTRIBUTES.register("reach_distance", () -> new RangedAttribute("generic.reachDistance", 4.5D, 0.0D, 1024.0D).setSyncable(true));
/**
* Attack Range represents the distance at which a player may attack an entity. The default is 3 blocks. Players in creative mode have an additional 3 blocks of attack reach.
* @see IForgePlayer#getAttackRange()
* @see IForgePlayer#canHit(Entity, double)
*/
public static final RegistryObject<Attribute> ATTACK_RANGE = ATTRIBUTES.register("attack_range", () -> new RangedAttribute("generic.attack_range", 3.0D, 0.0D, 1024.0D).setSyncable(true));
/**
* Step Height Addition modifies the amount of blocks an entity may walk up without jumping.
* @see IForgeEntity#getStepHeight()
*/
public static final RegistryObject<Attribute> STEP_HEIGHT_ADDITION = ATTRIBUTES.register("step_height_addition", () -> new RangedAttribute("forge.stepHeight", 0.0D, -512.0D, 512.0D).setSyncable(true));