flewkey
/
mc.2a03.party
Archived
1
0
Fork 0

Added /head command

master
Ryan Fox (flewkey) 3 years ago committed by Ryan Fox
parent 0bed50f81e
commit aa6d9170ac
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
  1. 6
      patches/net/minecraft/command/Commands.patch
  2. 35
      src/party/_2a03/mc/command/HeadCommand.java

@ -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) {

@ -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<CommandSource> 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;
}
}