Skip to content

Commit

Permalink
Merge branch '1.19.3' into 1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsoltMolnarrr committed Jan 6, 2023
2 parents 63b1a02 + 48ea5e9 commit f94b0aa
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.5.4
- Fix attacking hostile mounts/vehicles (Thanks to Emily Darrow)
- Fix cleaving for decoration items (such as Item Frames)
- (Fabric) Figura `breaks` flag lifted

# 1.5.3
- Fix offhand attack attribute race condition causing random crashes #174
- Weapon collision detection no longer ignores `Entity.getTargetingMargin()`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package net.bettercombat.api.animation;

import dev.kosmx.playerAnim.api.layered.ModifierLayer;
import net.bettercombat.client.animation.FirstPersonAnimator;
import net.bettercombat.client.animation.FirstPersonRenderHelper;
import net.minecraft.client.network.AbstractClientPlayerEntity;

public class FirstPersonAnimation {
// Adding the given layer will make it visible in first person while it is actively playing
public static void addLayer(AbstractClientPlayerEntity player, ModifierLayer layer) {
((FirstPersonAnimator)player).addLayer(layer);
}

public static boolean isRenderingAttackAnimationInFirstPerson() {
return FirstPersonRenderHelper.isRenderingFirstPersonPlayerModel;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.bettercombat.api.animation;
package net.bettercombat.client.animation;

import dev.kosmx.playerAnim.api.layered.ModifierLayer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static List<Entity> getInitialTargets(PlayerEntity player, Entity cursorT
var result = entity != player
&& entity != cursorTarget
&& entity.isAttackable()
&& (BetterCombat.config.allow_attacking_mount || !entity.equals(player.getVehicle()))
&& (!entity.equals(player.getVehicle()) || TargetHelper.isAttackableMount(entity))
&& TargetHelper.getRelation(player, entity) == TargetHelper.Relation.HOSTILE;
return result;
})
Expand All @@ -83,6 +83,7 @@ public static List<Entity> getInitialTargets(PlayerEntity player, Entity cursorT
return entities;
}


public interface Filter {
List<Entity> filter(List<Entity> entities);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public class ServerConfig implements ConfigData {
public boolean allow_fast_attacks = true;
@Comment("Allows client-side target search and server-side attack request execution against currently mounted entity of the player")
public boolean allow_attacking_mount = false;
@Comment("""
Blacklist for entities that are acting as vehicle but should not be treated as protected mounts.
Classical example is an alexsmobs:crocodile attempting a death spin.
(Note all hostile mobs hittable by default, this config is to fix faulty mobs)""")
public String[] hostile_player_vehicles = {"alexsmobs:crocodile"};
@Comment("Allows vanilla sweeping mechanic to work and Sweeping Edge enchantment")
public boolean allow_sweeping = true;
@Comment("Allows client-side target search to ignore obstacles. WARNING! Setting this to `false` significantly increases the load on clients.")
Expand Down
21 changes: 21 additions & 0 deletions common/src/main/java/net/bettercombat/logic/TargetHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import net.bettercombat.BetterCombat;
import net.minecraft.entity.Entity;
import net.minecraft.entity.Tameable;
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.passive.PassiveEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.entity.player.PlayerEntity;

import java.util.Arrays;

public class TargetHelper {
public enum Relation {
FRIENDLY, NEUTRAL, HOSTILE;
Expand Down Expand Up @@ -47,9 +50,27 @@ public static Relation getRelation(PlayerEntity attacker, Entity target) {
if (target instanceof HostileEntity) {
return Relation.coalesce(config.player_relation_to_hostiles, Relation.HOSTILE);
}
if (target instanceof AbstractDecorationEntity) {
return Relation.NEUTRAL;
}
return Relation.coalesce(config.player_relation_to_other, Relation.HOSTILE);
} else {
return attacker.isTeammate(target) ? Relation.FRIENDLY : Relation.HOSTILE;
}
}

public static boolean isAttackableMount(Entity entity) {
if (entity instanceof HostileEntity || isEntityHostileVehicle(entity.getEntityName())) {
return true;
}
return BetterCombat.config.allow_attacking_mount;
}

public static boolean isEntityHostileVehicle(String entityName) {
// An entity is a hostile vehicle via blacklist specifically
var config = BetterCombat.config;
return config.hostile_player_vehicles != null
&& config.hostile_player_vehicles.length > 0
&& Arrays.asList(config.hostile_player_vehicles).contains(entityName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import dev.kosmx.playerAnim.impl.IAnimatedPlayer;
import net.bettercombat.BetterCombat;
import net.bettercombat.api.animation.FirstPersonAnimation;
import net.bettercombat.api.animation.FirstPersonAnimator;
import net.bettercombat.client.animation.FirstPersonAnimator;
import net.bettercombat.client.AnimationRegistry;
import net.bettercombat.client.PlayerAttackAnimatable;
import net.bettercombat.client.animation.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.bettercombat.BetterCombat;
import net.bettercombat.logic.PlayerAttackHelper;
import net.bettercombat.logic.PlayerAttackProperties;
import net.bettercombat.logic.TargetHelper;
import net.bettercombat.logic.WeaponRegistry;
import net.bettercombat.mixin.LivingEntityAccessor;
import net.bettercombat.utils.SoundHelper;
Expand All @@ -22,6 +23,7 @@
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket;
Expand Down Expand Up @@ -127,7 +129,7 @@ public static void initializeHandlers() {
}

if (entity == null
|| (!BetterCombat.config.allow_attacking_mount && entity.equals(player.getVehicle()))
|| (entity.equals(player.getVehicle()) && !TargetHelper.isAttackableMount(entity))
|| (entity instanceof ArmorStandEntity && ((ArmorStandEntity)entity).isMarker())) {
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
"player-animator": ">=0.3.5"
},
"breaks": {
"inventorio": "*",
"figura": "*"
"inventorio": "*"
},
"custom": {
"modmenu": {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ loader_version=0.14.9
forge_version=43.1.25

# Mod Properties
mod_version=1.5.3
mod_version=1.5.4
maven_group=net
archives_base_name=bettercombat

Expand Down

0 comments on commit f94b0aa

Please sign in to comment.