diff --git a/build.gradle b/build.gradle index 5025127..14b416c 100644 --- a/build.gradle +++ b/build.gradle @@ -77,6 +77,14 @@ repositories { } metadataSources { artifact() } } + ivy { + url = "https://github.com/ToufouMaster" + patternLayout { + artifact "[organisation]/releases/download/[revision]/[module]-[revision].jar" + m2compatible = true + } + metadataSources { artifact() } + } } dependencies { @@ -90,6 +98,7 @@ dependencies { // If you do not need Halplibe you can comment this line out or delete this line modImplementation "com.github.Turnip-Labs:bta-halplibe:${project.halplibe_version}" + modImplementation "BTWaila:btwaila:1.0.8-7.1" modImplementation "ModMenu:ModMenu:2.0.0" include modImplementation('com.mojang:brigadier:1.0.18') diff --git a/output/production/commander-bta.main/fabric.mod.json b/output/production/commander-bta.main/fabric.mod.json index 66cc0c1..55b182b 100644 --- a/output/production/commander-bta.main/fabric.mod.json +++ b/output/production/commander-bta.main/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "commander", - "version": "1.2.10", + "version": "1.2.11", "name": "Commander", "description": "This mod overhauls the command system.", diff --git a/output/production/commander-bta.main/lang/commander/en_US.lang b/output/production/commander-bta.main/lang/commander/en_US.lang index b401990..ec979f5 100644 --- a/output/production/commander-bta.main/lang/commander/en_US.lang +++ b/output/production/commander-bta.main/lang/commander/en_US.lang @@ -4,6 +4,7 @@ argument_types.commander.block.invalid_block=Invalid block ID argument_types.commander.item.invalid_item=Invalid item ID argument_types.commander.dimension.invalid_dimension=Invalid dimension ID argument_types.commander.biome.invalid_biome=Invalid biome ID +argument_types.commander.damage_type.invalid_damage_type=Invalid damage type ID argument_types.commander.gamerule.invalid_value=Invalid game rule value argument_types.commander.entity.invalid_selector.single_player_only=Selector includes more than one entity, but command only accepts a single player as an argument argument_types.commander.entity.invalid_selector.single_entity_only=Selector includes more than one entity, but command only accepts a single entity as an argument @@ -149,4 +150,8 @@ commands.commander.testfor.entity.none=No entities match the given selector commands.commander.testfor.entity.single=%s entity matches the given selector commands.commander.testfor.entity.plural=%s entities match the given selector commands.commander.testfor.block.success=The two blocks are equal -commands.commander.testfor.block.failure=The two blocks are not equal \ No newline at end of file +commands.commander.testfor.block.failure=The two blocks are not equal +commands.commander.damage.success_single=Damaged %s entity +commands.commander.damage.success_multiple=Damaged %s entities +commands.commander.heal.success_single=Healed %s entity +commands.commander.heal.success_multiple=Healed %s entities \ No newline at end of file diff --git a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderClientCommandSource.class b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderClientCommandSource.class index 0171c88..0a021ce 100644 Binary files a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderClientCommandSource.class and b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderClientCommandSource.class differ diff --git a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandManager.class b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandManager.class index 0a053c3..9db1433 100644 Binary files a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandManager.class and b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandManager.class differ diff --git a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandSource.class b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandSource.class index 6d471ed..7360c23 100644 Binary files a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandSource.class and b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandSource.class differ diff --git a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderConsoleCommandSource.class b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderConsoleCommandSource.class index b800e89..4f4e311 100644 Binary files a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderConsoleCommandSource.class and b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderConsoleCommandSource.class differ diff --git a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderServerCommandSource.class b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderServerCommandSource.class index 06746e6..dfd36df 100644 Binary files a/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderServerCommandSource.class and b/output/production/commander-bta.main/net/pedroricardo/commander/content/CommanderServerCommandSource.class differ diff --git a/src/main/java/net/pedroricardo/commander/content/CommanderCommandManager.java b/src/main/java/net/pedroricardo/commander/content/CommanderCommandManager.java index a95dd39..5a38c32 100644 --- a/src/main/java/net/pedroricardo/commander/content/CommanderCommandManager.java +++ b/src/main/java/net/pedroricardo/commander/content/CommanderCommandManager.java @@ -55,6 +55,7 @@ public void init() { TellRawCommand.register(DISPATCHER); TestForCommand.register(DISPATCHER); DamageCommand.register(DISPATCHER); + HealCommand.register(DISPATCHER); if (this.isServer) { StopCommand.register(DISPATCHER); diff --git a/src/main/java/net/pedroricardo/commander/content/commands/DamageCommand.java b/src/main/java/net/pedroricardo/commander/content/commands/DamageCommand.java index d03605f..22a5e5a 100644 --- a/src/main/java/net/pedroricardo/commander/content/commands/DamageCommand.java +++ b/src/main/java/net/pedroricardo/commander/content/commands/DamageCommand.java @@ -27,6 +27,7 @@ public static void register(CommandDispatcher dispatcher for (Entity entity : entities) { if (entity.hurt(null, amount, type)) ++entitiesAffected; } + c.getSource().sendTranslatableMessage("commands.commander.damage.success_" + (entitiesAffected == 1 ? "single" : "multiple"), entitiesAffected); return entitiesAffected; }))))); } diff --git a/src/main/java/net/pedroricardo/commander/content/commands/HealCommand.java b/src/main/java/net/pedroricardo/commander/content/commands/HealCommand.java new file mode 100644 index 0000000..e92f293 --- /dev/null +++ b/src/main/java/net/pedroricardo/commander/content/commands/HealCommand.java @@ -0,0 +1,44 @@ +package net.pedroricardo.commander.content.commands; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.builder.RequiredArgumentBuilder; +import net.minecraft.core.entity.Entity; +import net.minecraft.core.entity.EntityLiving; +import net.minecraft.core.util.helper.MathHelper; +import net.minecraft.core.world.World; +import net.pedroricardo.commander.content.CommanderCommandSource; +import net.pedroricardo.commander.content.arguments.EntityArgumentType; +import net.pedroricardo.commander.content.helpers.EntitySelector; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +public class HealCommand { + public static void register(CommandDispatcher dispatcher) { + dispatcher.register(LiteralArgumentBuilder.literal("heal") + .then(RequiredArgumentBuilder.argument("entities", EntityArgumentType.entities()) + .then(RequiredArgumentBuilder.argument("amount", IntegerArgumentType.integer(0, 32768)) + .executes(c -> { + List entities = c.getArgument("entities", EntitySelector.class).get(c.getSource()); + int amount = c.getArgument("amount", Integer.class); + + int entitiesAffected = 0; + for (Entity entity : entities) { + if (entity instanceof EntityLiving) { + int maxHealth = 20; + try { + maxHealth = ((EntityLiving)entity.getClass().getConstructor(World.class).newInstance(c.getSource().getWorld())).health; + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException ignored) { + } + int originalHealth = ((EntityLiving)entity).health; + ((EntityLiving)entity).health = MathHelper.clamp(((EntityLiving)entity).health + amount, 0, maxHealth); + if (((EntityLiving)entity).health != originalHealth) ++entitiesAffected; + } + } + c.getSource().sendTranslatableMessage("commands.commander.heal.success_" + (entitiesAffected == 1 ? "single" : "multiple"), entitiesAffected); + return entitiesAffected; + })))); + } +} diff --git a/src/main/resources/lang/commander/en_US.lang b/src/main/resources/lang/commander/en_US.lang index d80f5f7..ec979f5 100644 --- a/src/main/resources/lang/commander/en_US.lang +++ b/src/main/resources/lang/commander/en_US.lang @@ -150,4 +150,8 @@ commands.commander.testfor.entity.none=No entities match the given selector commands.commander.testfor.entity.single=%s entity matches the given selector commands.commander.testfor.entity.plural=%s entities match the given selector commands.commander.testfor.block.success=The two blocks are equal -commands.commander.testfor.block.failure=The two blocks are not equal \ No newline at end of file +commands.commander.testfor.block.failure=The two blocks are not equal +commands.commander.damage.success_single=Damaged %s entity +commands.commander.damage.success_multiple=Damaged %s entities +commands.commander.heal.success_single=Healed %s entity +commands.commander.heal.success_multiple=Healed %s entities \ No newline at end of file