generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42d3fdd
commit 0c6803f
Showing
12 changed files
with
164 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/portingdeadmods/modjam/content/commands/GetAugmentCooldownCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.portingdeadmods.modjam.content.commands; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import com.portingdeadmods.modjam.content.commands.arguments.AugmentSlotArgumentType; | ||
import com.portingdeadmods.modjam.utils.AugmentHelper; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.Commands; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
// /modjam augments get <slot> | ||
public class GetAugmentCooldownCommand { | ||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) { | ||
dispatcher.register(Commands.literal(ModJam.MODID) | ||
.then(Commands.literal("augments") | ||
.then(Commands.literal("cooldown") | ||
.then(Commands.literal("get") | ||
.then(Commands.argument("slot", AugmentSlotArgumentType.getInstance()) | ||
.executes(GetAugmentCooldownCommand::execute)))))); | ||
} | ||
|
||
private static int execute(CommandContext<CommandSourceStack> ctx) { | ||
Player player = ctx.getSource().getPlayer(); | ||
AugmentSlot augmentSlot = ctx.getArgument("slot", AugmentSlot.class); | ||
Augment augmentBySlot = AugmentHelper.getAugmentBySlot(player, augmentSlot); | ||
int cooldown = 0; | ||
if (augmentBySlot != null) { | ||
cooldown = augmentBySlot.getCooldown(); | ||
player.sendSystemMessage(Component.literal("Augment cooldown for slot '" + augmentSlot.getName() + "': " + cooldown)); | ||
} | ||
return 1; | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
src/main/java/com/portingdeadmods/modjam/content/commands/SetAugmentCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/portingdeadmods/modjam/content/commands/SetAugmentCooldownCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.portingdeadmods.modjam.content.commands; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.arguments.IntegerArgumentType; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import com.portingdeadmods.modjam.content.commands.arguments.AugmentSlotArgumentType; | ||
import com.portingdeadmods.modjam.content.commands.arguments.AugmentTypeArgumentType; | ||
import com.portingdeadmods.modjam.utils.AugmentHelper; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.Commands; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
// /modjam augments set <slot> <augment> | ||
|
||
// TODO: Only set augments for slots that support them | ||
public class SetAugmentCooldownCommand { | ||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) { | ||
dispatcher.register(Commands.literal(ModJam.MODID) | ||
.then(Commands.literal("augments") | ||
.then(Commands.literal("cooldown") | ||
.then(Commands.literal("set") | ||
.then(Commands.argument("slot", AugmentSlotArgumentType.getInstance()) | ||
.then(Commands.argument("cooldown", IntegerArgumentType.integer()) | ||
.executes(SetAugmentCooldownCommand::execute))))))); | ||
} | ||
|
||
private static int execute(CommandContext<CommandSourceStack> ctx) { | ||
Player player = ctx.getSource().getPlayer(); | ||
AugmentSlot slot = ctx.getArgument("slot", AugmentSlot.class); | ||
int cooldown = ctx.getArgument("cooldown", int.class); | ||
Augment augmentBySlot = AugmentHelper.getAugmentBySlot(player, slot); | ||
if (augmentBySlot != null) { | ||
augmentBySlot.setCooldown(cooldown); | ||
player.sendSystemMessage(Component.literal("Set augment cooldown in slot '" + slot.getName() + "' to: " + cooldown)); | ||
} | ||
return 1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...ent/commands/AugmentTypeArgumentType.java → ...ds/arguments/AugmentTypeArgumentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
src/main/java/com/portingdeadmods/modjam/registries/MJArgumentTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters