Advertisement
TNT_Block

GiveClass

Apr 16th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package de.TNT_Block_Unkown.modules;
  2.  
  3. import de.TNT_Block_Unkown.ChatManager;
  4. import de.TNT_Block_Unkown.Utils;
  5. import net.minecraft.item.ItemStack;
  6. import net.minecraft.nbt.JsonToNBT;
  7. import net.minecraft.util.ResourceLocation;
  8.  
  9. public class give {
  10. public static void execute(String[] args) {
  11. if (args.length == 1) {
  12. ChatManager.addMessage("#give <Item> [<Anzahl>] [<Meta>] [<NBT>]");
  13. }else {
  14. if (args.length == 2) {
  15. ItemStack itm = new ItemStack(Utils.getItem(new ResourceLocation(args[1])));
  16. Utils.giveItem(itm);
  17. }else {
  18. if (args.length == 3) {
  19. ItemStack itm = new ItemStack(Utils.getItem(new ResourceLocation(args[1])),Integer.valueOf(args[2]));
  20. Utils.giveItem(itm);
  21. }else {
  22. if (args.length == 4) {
  23. ItemStack itm = new ItemStack(Utils.getItem(new ResourceLocation(args[1])),Integer.valueOf(args[2]),Integer.valueOf(args[3]));
  24. Utils.giveItem(itm);
  25. }else {
  26. if (args.length >= 5) {
  27. String nbt = "";
  28. for(int i = 4; i < args.length; i++) {
  29. nbt += args[i];
  30. if(i != args.length - 1) {
  31. nbt += " ";
  32. }
  33. }
  34. ItemStack itm = new ItemStack(Utils.getItem(new ResourceLocation(args[1])),Integer.valueOf(args[2]),Integer.valueOf(args[3]));
  35. try {
  36. itm.setTagCompound(JsonToNBT.func_180713_a(nbt));
  37. Utils.giveItem(itm);
  38. }catch (Exception e) {
  39. ChatManager.addMessage("Ungültige NBT-Daten!");
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement