From aa6d9170ac4748c9d583fac21134a8975fe50199 Mon Sep 17 00:00:00 2001 From: "Ryan Fox (flewkey)" Date: Tue, 31 Dec 2019 00:33:18 +0000 Subject: [PATCH] Added /head command --- patches/net/minecraft/command/Commands.patch | 6 ++-- src/party/_2a03/mc/command/HeadCommand.java | 35 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/party/_2a03/mc/command/HeadCommand.java diff --git a/patches/net/minecraft/command/Commands.patch b/patches/net/minecraft/command/Commands.patch index b1f9d6f..b8fd059 100644 --- a/patches/net/minecraft/command/Commands.patch +++ b/patches/net/minecraft/command/Commands.patch @@ -1,22 +1,24 @@ --- a/net/minecraft/command/Commands.java +++ b/net/minecraft/command/Commands.java -@@ -96,6 +96,10 @@ +@@ -96,6 +96,11 @@ import net.minecraft.util.text.event.HoverEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import party._2a03.mc.command.SpawnCommand; //Patched +import party._2a03.mc.command.HomeCommand; //Patched ++import party._2a03.mc.command.HeadCommand; //Patched +import party._2a03.mc.command.HatCommand; //Patched +import party._2a03.mc.command.ConfigCommand; //Patched public class Commands { private static final Logger field_197061_a = LogManager.getLogger(); -@@ -156,6 +160,10 @@ +@@ -156,6 +161,11 @@ TriggerCommand.func_198852_a(this.field_197062_b); WeatherCommand.func_198862_a(this.field_197062_b); WorldBorderCommand.func_198894_a(this.field_197062_b); + SpawnCommand.register(this.field_197062_b); //Patched + HomeCommand.register(this.field_197062_b); //Patched ++ HeadCommand.register(this.field_197062_b); //Patched + HatCommand.register(this.field_197062_b); //Patched + ConfigCommand.register(this.field_197062_b); //Patched if (SharedConstants.field_206244_b) { diff --git a/src/party/_2a03/mc/command/HeadCommand.java b/src/party/_2a03/mc/command/HeadCommand.java new file mode 100644 index 0000000..685c565 --- /dev/null +++ b/src/party/_2a03/mc/command/HeadCommand.java @@ -0,0 +1,35 @@ +package party._2a03.mc.command; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.StringArgumentType; +import net.minecraft.block.Blocks; +import net.minecraft.command.Commands; +import net.minecraft.command.CommandSource; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.text.TranslationTextComponent; + +public class HeadCommand { + public static void register(CommandDispatcher dispatcher) { + dispatcher.register(Commands.func_197057_a("head").executes((source) -> { + return giveHead(source.getSource(), source.getSource().func_197035_h(), source.getSource().func_197037_c()); + }).then(Commands.func_197056_a("username", StringArgumentType.greedyString()).executes((source) -> { + return giveHead(source.getSource(), source.getSource().func_197035_h(), StringArgumentType.getString(source, "username")); + }))); + } + + private static int giveHead(CommandSource source, ServerPlayerEntity serverplayerentity, String skullowner) { + ItemStack itemstack = new ItemStack(Blocks.field_196710_eS.func_199767_j()); + CompoundNBT compoundnbt = new CompoundNBT(); + compoundnbt.func_74778_a("SkullOwner", skullowner); + itemstack.func_77982_d(compoundnbt); + ItemEntity itementity = serverplayerentity.func_71019_a(itemstack, false); + itementity.func_174868_q(); + itementity.func_200217_b(serverplayerentity.func_110124_au()); + source.func_197030_a(new TranslationTextComponent("Player head has been given"), false); + return 1; + } +}