Skip to content
Merged
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
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ repositories {
includeGroup "dev.latvian.mods"
}
}

// TODO: Use Controlify from Modrinth maven once this PR is published: https://github.com/isXander/Controlify/pull/689
// and then remove this temporary Maven.
exclusiveContent {
forRepository { maven { url "https://echoellet.github.io/Controlify/" } }
filter { includeGroup "dev.echoellet" }
}
}

base {
Expand Down Expand Up @@ -156,6 +163,9 @@ dependencies {

compileOnly "curse.maven:shoulder-surfing-reloaded-243190:6993797" // API only (https://www.curseforge.com/minecraft/mc-mods/shoulder-surfing-reloaded/files/6993792)
//compileOnly "curse.maven:shoulder-surfing-reloaded-243190:6993795" // Actual mod file (for test)

// Change "compileOnly" to "implementation" for testing in-game.
compileOnly "dev.echoellet:controlify:2.4.2-1.21.1-neoforge"
}

var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import org.jetbrains.annotations.Nullable;
import yesman.epicfight.client.input.EpicFightKeyMappings;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

/**
* Represents a default set of input actions used in the Epic Fight mod.
Expand Down Expand Up @@ -136,4 +134,19 @@ public KeyMapping keyMapping() {
public static @Nullable EpicFightInputActions fromKeyMapping(@NotNull KeyMapping keyMapping) {
return BY_KEY_MAPPING.get(keyMapping);
}

/**
* Returns a set of all Epic Fight actions that are not part of the vanilla
* Minecraft key mappings.
*
* @return a set containing all non-vanilla {@link EpicFightInputActions}
* @see EpicFightInputActions#isVanilla
*/
public static @NotNull Set<EpicFightInputActions> nonVanillaActions() {
Set<EpicFightInputActions> result = EnumSet.noneOf(EpicFightInputActions.class);
for (EpicFightInputActions action : EpicFightInputActions.values()) {
if (!action.isVanilla()) result.add(action);
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ private static void consumeVanillaAttackKeyClicks() {
/**
* Previously used to temporarily disable the vanilla swap-offhand key while the player
* was performing an action or attacking, but this is now handled by
* {@link yesman.epicfight.mixin.client.MixinClientPacketListener#onBeforeSendPacket}.
* {@link yesman.epicfight.mixin.client.MixinClientCommonPacketListenerImpl#onBeforeSendPacket}.
* <p>
* This method now only decrements the internal counter of the vanilla {@link KeyMapping#clickCount}
* to prevent potential conflicts with other mods. It serves as a safety measure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javax.annotation.Nullable;

import net.minecraft.client.gui.components.*;
import org.joml.Matrix4f;

import com.google.common.collect.Lists;
Expand All @@ -18,13 +19,6 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.components.WidgetSprites;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.narration.NarrationElementOutput;
Expand Down Expand Up @@ -116,6 +110,7 @@ public static void registerIconItems() {
protected final AttributeIconList providingAttributesList;
protected final InteractionHand hand;
private double customScale;
public AbstractButton learnButton;

public SkillBookScreen(Player opener, ItemStack stack, @Nullable InteractionHand hand) {
this(opener, SkillBookItem.getContainSkill(stack).get().value(), hand, null);
Expand Down Expand Up @@ -217,7 +212,7 @@ protected void init() {
this.customScale = window.getGuiScale();
}

Button learnButton =
learnButton =
Button.builder(
Component.translatable(EpicFightMod.format("gui.%s") + (isUsing ? ".applied" : meetsCondition ? ".learn" : ".unusable")),
button -> {
Expand Down

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/main/java/yesman/epicfight/main/EpicFightMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

import net.minecraft.resources.ResourceLocation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -37,6 +38,7 @@
import net.neoforged.neoforge.event.AddReloadListenerEvent;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
import org.jetbrains.annotations.NotNull;
import yesman.epicfight.api.animation.AnimationManager;
import yesman.epicfight.api.animation.AnimationManager.AnimationRegistryEvent;
import yesman.epicfight.api.animation.LivingMotion;
Expand Down Expand Up @@ -276,6 +278,7 @@ private void constructMod(final FMLConstructModEvent event) {
event.enqueueWork(WeaponCategory.ENUM_MANAGER::loadEnum);
event.enqueueWork(Faction.ENUM_MANAGER::loadEnum);
event.enqueueWork(EntityPairingPacketType.ENUM_MANAGER::loadEnum);
event.enqueueWork(InputAction.ENUM_MANAGER::loadEnum);
event.enqueueWork(() -> {
AnimationManager.addNoWarningModId(EPICSKINS_MODID);
AnimationRegistryEvent animationregistryevent = new AnimationRegistryEvent();
Expand Down Expand Up @@ -409,4 +412,8 @@ private void buildCreativeTabWithSkillBooks(final BuildCreativeModeTabContentsEv
event.accept(stack);
});
}

public static @NotNull ResourceLocation rl(@NotNull String path) {
return ResourceLocation.fromNamespaceAndPath(MODID, path);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package yesman.epicfight.mixin.client;

import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import yesman.epicfight.client.events.engine.ControlEngine;

@Mixin(ClientCommonPacketListenerImpl.class)
public class MixinClientCommonPacketListenerImpl {
@Inject(
method = "send(Lnet/minecraft/network/protocol/Packet;)V",
at = @At("HEAD"),
cancellable = true
)
private void onBeforeSendPacket(Packet<?> packet, CallbackInfo ci) {
final boolean isSwapItemWithOffhand = packet instanceof ServerboundPlayerActionPacket actionPacket &&
actionPacket.getAction() == ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND;
if (isSwapItemWithOffhand && ControlEngine.shouldDisableSwapHandItems()) {
// Disables the swap offhand items while in action (e.g., attacking in Epic Fight mode).
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package yesman.epicfight.mixin.client;

import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -10,26 +8,11 @@
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.protocol.game.ClientboundRespawnPacket;
import yesman.epicfight.client.events.ClientEvents;
import yesman.epicfight.client.events.engine.ControlEngine;

@Mixin(value = ClientPacketListener.class)
public abstract class MixinClientPacketListener {
@Inject(at = @At(value = "HEAD"), method = "handleRespawn(Lnet/minecraft/network/protocol/game/ClientboundRespawnPacket;)V", cancellable = false)
private void epicfight_handleRespawn(ClientboundRespawnPacket clientboundRespawnPacket, CallbackInfo info) {
ClientEvents.packet = clientboundRespawnPacket;
}

@Inject(
method = "send(Lnet/minecraft/network/protocol/Packet;)V",
at = @At("HEAD"),
cancellable = true
)
private void onBeforeSendPacket(Packet<?> packet, CallbackInfo ci) {
final boolean isSwapItemWithOffhand = packet instanceof ServerboundPlayerActionPacket actionPacket &&
actionPacket.getAction() == ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND;
if (isSwapItemWithOffhand && ControlEngine.shouldDisableSwapHandItems()) {
// Disables the swap offhand items while in action (e.g., attacking in Epic Fight mode).
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yesman.epicfight.compat.controlify.ControlifyCompat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"defaults": {
"epicfight:attack": {
"axis": "controlify:axis/right_trigger"
},
"epicfight:weapon_innate_skill": {
"axis": "controlify:axis/right_trigger"
},
"epicfight:weapon_innate_skill_tooltip": {
"axis": "controlify:axis/left_trigger"
},
"epicfight:mobility": {
"button": "controlify:button/south"
},
"epicfight:guard": {
"axis": "controlify:axis/left_trigger"
},
"epicfight:dodge": {
"button": "controlify:button/east"
},
"epicfight:lock_on": {
"button": "controlify:button/left_stick"
}
}
}
12 changes: 12 additions & 0 deletions src/main/resources/assets/epicfight/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,18 @@
"key.epicfight.mover_skill": "Mobility Skill",
"key.epicfight.config": "Open Configuration Screen",
"key.epicfight.switch_vanilla_model_debug": "Switch Vanilla Model Debugging",

"key.epicfight.show_tooltip.description": "Displays the tooltip of your weapon's innate skill when the inventory screen is open",
"key.epicfight.switch_mode.description": "Switches between combat and mining modes",
"key.epicfight.attack.description": "Performs a basic attack with your equipped weapon",
"key.epicfight.weapon_innate_skill.description": "Activates the innate skill of your equipped weapon",
"key.epicfight.skill_gui.description": "Opens the skill editor GUI to customize your skills",
"key.epicfight.dodge.description": "Performs a dodge maneuver to avoid attacks",
"key.epicfight.guard.description": "Blocks incoming attacks with your weapon",
"key.epicfight.lock_on.description": "Locks onto the nearest target for easier combat",
"key.epicfight.mover_skill.description": "Uses a skill that enhances movement or mobility",
"key.epicfight.config.description": "Opens the mod configuration screen",
"key.epicfight.switch_vanilla_model_debug.description": "Toggles debugging for vanilla player models",

"skill.epicfight.dancing_edge": "Dancing Edge",
"skill.epicfight.dancing_edge.tooltip": "Cut down enemies with a lethal flourish! It strikes 3 times",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/epicfight.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"client.MixinAbstractContainerEventHandler",
"client.MixinAgeableListModel",
"client.MixinClientPacketListener",
"client.MixinClientCommonPacketListenerImpl",
"client.MixinCompositeRenderType",
"client.MixinEnderDragonRenderer",
"client.MixinEntityRenderer",
Expand Down