Advertisement
TNT_Block

TNTMod-Utils

Apr 15th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. package de.TNT_Block_Unkown;
  2. import java.awt.Color;
  3. import java.util.Random;
  4.  
  5. import io.netty.util.internal.ThreadLocalRandom;
  6. import net.minecraft.client.Minecraft;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.network.play.client.C10PacketCreativeInventoryAction;
  10. import net.minecraft.util.ResourceLocation;
  11.  
  12. public class Utils {
  13. public static Boolean isFastPlace = false;
  14. public static Item getItem(ResourceLocation loc) {
  15. return (Item)Item.itemRegistry.getObject(loc);
  16. }
  17. public static Boolean isInt(String i) {
  18. Boolean isI = false;
  19. try {
  20. Integer.parseInt(i);
  21. isI = true;
  22. }
  23. catch(Exception e) {
  24. isI = false;
  25. }
  26. return isI;
  27. }
  28. public static Boolean isDouble(String d) {
  29. Boolean isD = false;
  30. try {
  31. Double.parseDouble(d);
  32. isD = true;
  33. }
  34. catch(Exception e) {
  35. isD = false;
  36. }
  37. return isD;
  38. }
  39. public static void giveItem(ItemStack stack) {
  40. Integer errorint = 0;
  41. for (int i = 0; i < 9; i++) {
  42. if (Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(i) == null)
  43. {
  44. Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C10PacketCreativeInventoryAction(36 + i, stack));
  45. return;
  46. }else {
  47. if (errorint==8) {
  48. ChatManager.addMessage("Bitte mache deine Schnellzugriffsleiste frei!");
  49. }else {
  50. errorint = errorint + 1;
  51. }
  52.  
  53. }
  54. }
  55. }
  56. public static void onTick() {
  57. if (de.TNT_Block_Unkown.ChatManager.flybypass) {
  58. Minecraft.getMinecraft().thePlayer.setPosition(Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posY + 1, Minecraft.getMinecraft().thePlayer.posZ);
  59.  
  60. Minecraft.getMinecraft().thePlayer.setPosition(Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posY - 1, Minecraft.getMinecraft().thePlayer.posZ);
  61. }
  62. if (de.TNT_Block_Unkown.ChatManager.isVulkan) {
  63. Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C10PacketCreativeInventoryAction(36, de.TNT_Block_Unkown.modules.Vulkan.generateVulkanItem(de.TNT_Block_Unkown.ChatManager.posVulkan[0], de.TNT_Block_Unkown.ChatManager.posVulkan[1], de.TNT_Block_Unkown.ChatManager.posVulkan[2], random(-1.0,1.0), 0.9, random(-1.0,1.0), generateRandomColor())));
  64. }
  65. }
  66. public static Double random(Double min, Double max) {
  67. return ThreadLocalRandom.current().nextDouble(min, max);
  68. }
  69. public static Color generateRandomColor() {
  70. Random randomGenerator = new Random();
  71. int red = randomGenerator.nextInt(255);
  72. int green = randomGenerator.nextInt(255);
  73. int blue = randomGenerator.nextInt(255);
  74. Color randomColour = new Color(red,green,blue);
  75. return randomColour;
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement