Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/src/main/java/net/combatroll/config/ClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ClientConfig implements ConfigData {
public boolean playCooldownSound = true;
public boolean playCooldownFlash = true;
public boolean playRollSound = true;
public boolean allowCharacterRotation = true;
@ConfigEntry.ColorPicker
public int hudArrowColor = 0x5488e3;
@ConfigEntry.BoundedDiscrete(min = 0, max = 100)
Expand All @@ -18,4 +19,6 @@ public class ClientConfig implements ConfigData {
public boolean showKeybinding = true;
public enum LabelPosition { TOP, LEFT }
public LabelPosition keybindingLabelPosition = LabelPosition.LEFT;


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import dev.kosmx.playerAnim.core.util.Vec3f;
import dev.kosmx.playerAnim.impl.IAnimatedPlayer;
import net.combatroll.CombatRoll;
import net.combatroll.client.CombatRollClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -40,7 +41,11 @@ public AbstractClientPlayerEntityMixin(World world, BlockPos pos, float yaw, Gam
@Inject(method = "<init>", at = @At("TAIL"))
private void postInit(ClientWorld world, GameProfile profile, CallbackInfo ci) {
var stack = ((IAnimatedPlayer) this).getAnimationStack();
base.addModifier(createAdjustmentModifier(), 0);

if (CombatRollClient.config.allowCharacterRotation){
base.addModifier(createAdjustmentModifier(), 0);
}

base.addModifier(speedModifier, 0);
speedModifier.speed = 1.2f;
stack.addAnimLayer(1000, base);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class MinecraftClientMixin implements MinecraftClientExtension {
@Shadow @Nullable public ClientPlayerEntity player;
@Shadow @Nullable public Screen currentScreen;
private RollManager rollManager = new RollManager();

public RollManager getRollManager() {
return rollManager;
}
Expand Down Expand Up @@ -122,10 +123,13 @@ private void tryRolling() {
} else {
direction = new Vec3d(sideways, 0, forward).normalize();
}

var RelativeDirection = direction; //We will use this later to determine which animation we have to play

direction = direction.rotateY((float) Math.toRadians((-1.0) * player.getYaw()));
var distance = 0.475 *
(EntityAttributes_CombatRoll.getAttributeValue(player, DISTANCE)
+ CombatRoll.config.additional_roll_distance);
+ CombatRoll.config.additional_roll_distance);
direction = direction.multiply(distance);

if (player.isTouchingWater()) {
Expand Down Expand Up @@ -153,7 +157,38 @@ private void tryRolling() {
player.addVelocity(direction.x, direction.y, direction.z);
rollManager.onRoll(player);

var rollVisuals = new RollEffect.Visuals(CombatRoll.MOD_ID + ":roll", PUFF);
var fwdDir = RelativeDirection.getZ();
var sideDir = RelativeDirection.getX();
var rollAngle = Math.toDegrees(Math.acos(fwdDir) * (sideDir >= 0 ? 1.0 : -1.0));

var animName = "";

if (rollAngle >= -22.5 && rollAngle <= 22.5) {
animName = "forwards";

} else if (rollAngle > 22.5 && rollAngle < 67.5) {
animName = "forwardsleft";

} else if (rollAngle >= 67.5 && rollAngle <= 112.5) {
animName = "left";

} else if (rollAngle > 112.5 && rollAngle < 157.5) {
animName = "backwardsleft";

} else if (rollAngle >= 157.5 && rollAngle <= 202.5) {
animName = "backwards";

} else if (rollAngle > -157.5 && rollAngle < -112.5) {
animName = "backwardsright";

} else if (rollAngle >= -112.5 && rollAngle <= -67.5) {
animName = "right";

} else {
animName = "forwardsright";
}

var rollVisuals = new RollEffect.Visuals(CombatRoll.MOD_ID + ":" + animName + "roll", PUFF);
ClientPlayNetworking.send(
Packets.RollPublish.ID,
new Packets.RollPublish(player.getId(), rollVisuals, direction).write());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"text.autoconfig.combatroll.option.client.playCooldownSound" : "Play cooldown ready sound",
"text.autoconfig.combatroll.option.client.playCooldownFlash": "Flash arrow when cooldown ready",
"text.autoconfig.combatroll.option.client.playRollSound" : "Play roll sound",
"text.autoconfig.combatroll.option.client.allowCharacterRotation" : "Change facing direction while rolling",
"text.autoconfig.combatroll.option.client.hudArrowColor" : "Arrow color",
"text.autoconfig.combatroll.option.client.hudBackgroundOpacity" : "Arrow background opacity",
"text.autoconfig.combatroll.option.client.showHUDInCreative" : "Show Arrow in Creative mode",
Expand Down
Loading