Util Holograms

Discussion in 'Resources' started by Ultimate_n00b, Feb 25, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Ultimate_n00b

    What would that error be?
     
  2. Offline

    Ape101

    Code:
    02.03 00:23:42 [Server] INFO at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    02.03 00:23:42 [Server] INFO at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    02.03 00:23:42 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:234)
    02.03 00:23:42 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:441)
    02.03 00:23:42 [Server] INFO Caused by: java.lang.ClassNotFoundException: net.minecraft.server.v1_7_R1.World
    02.03 00:23:42 [Server] INFO ... 15 more
    02.03 00:23:42 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    02.03 00:23:42 [Server] INFO at com.beasttech.core.commands.CommandTest.onCommand(CommandTest.java:19)
    02.03 00:23:42 [Server] INFO Caused by: java.lang.NoClassDefFoundError: net/minecraft/server/v1_7_R1/World
    02.03 00:23:42 [Server] INFO at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
    02.03 00:23:42 [Server] INFO at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:663)
    02.03 00:23:42 [Server] INFO at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:781)
    02.03 00:23:42 [Server] INFO at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:330)
    02.03 00:23:42 [Server] INFO at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:914)
    02.03 00:23:42 [Server] INFO at net.minecraft.server.dedicated.DedicatedServerListenThread.func_71747_b(DedicatedServerListenThread.java:34)
    02.03 00:23:42 [Server] INFO at net.minecraft.network.NetworkListenThread.func_71747_b(NetworkListenThread.java:54)
    02.03 00:23:42 [Server] INFO at net.minecraft.network.NetServerHandler.func_72570_d(NetServerHandler.java:233)
    02.03 00:23:42 [Server] INFO at net.minecraft.network.TcpConnection.func_74428_b(TcpConnection.java:470)
    02.03 00:23:42 [Server] INFO at net.minecraft.network.packet.Packet3Chat.func_73279_a(Packet3Chat.java:68)
    02.03 00:23:42 [Server] INFO at net.minecraft.network.NetServerHandler.func_72481_a(NetServerHandler.java:1201)
    02.03 00:23:42 [Server] INFO at net.minecraft.network.NetServerHandler.chat(NetServerHandler.java:1269)
    02.03 00:23:42 [Server] INFO at net.minecraft.network.NetServerHandler.func_72566_d(NetServerHandler.java:1405)
    02.03 00:23:42 [Server] INFO at org.bukkit.craftbukkit.v1_6_R3.CraftServer.dispatchCommand(CraftServer.java:532)
    02.03 00:23:42 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:192)
    02.03 00:23:42 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
    02.03 00:23:42 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin Test v1.0
     
  3. Offline

    Squid_Boss

    Alright. :)
     
  4. Offline

    Desle

    Ape101

    I think you imported world wrong
     
  5. Offline

    Gamecube762

    Looks cool, would be nice if the OP-Post has more info on what it does for the people who haven't heard of it till now(like me).

    Well, Time to have some fun and give my players yet another mind f***. =P

    Edit: So I already made a few good uses for it within what ever some minutes I created this post. XD 2 uses so far is a Local chat system and a "Goodbye" message left behind when a player leaves.
     
    wiedzmin137 likes this.
  6. Offline

    Deleted user

    Gamecube762 Nice WeepCraft tho.

    I'm sure you're getting banned on all servers who's owners read BukkitForums ;)
     
    Goblom likes this.
  7. Offline

    Ape101

    Figured out my problem :p i was using it on my tekkit server which is 1.6.4, any way of doing this in 1.6.4?
     
  8. Offline

    Ultimate_n00b

    Ape101 There is, you would have to convert the packets though.
     
  9. Offline

    Desle

    Gamecube762
    Cant move the text smoothly to follow a player though..
     
  10. Offline

    Gamecube762

    Well since it's a Horse riding a wither skull that is handled by packets, I was going to have it send packets of PacketPlayOutRelEntityMove and PacketPlayOutEntityTeleport relative to the player's movement. It should move as much as you see other players moving.

    Or another idea is to make the Hologram riding the player that it's designed for.
     
  11. Offline

    DevRosemberg

    Hey Paul, is it possible to detect when a player right clicks the Nametag and get the text value? Like for example when he right clicks it open a menu.
     
  12. Offline

    DarkBladee12

    DevRosemberg I don't think that's possible since the nametag is not an entity.
     
  13. Offline

    Gamecube762

    DevRosemberg You can try getting the Entity that was clicked on and check if its the horse/WitherSkull that is used to make the text.
     
  14. Offline

    DevRosemberg

    DarkBladee12 Comphenix told me it was but he also told me it wouldnt be easy.
     
  15. Offline

    DarkBladee12

    Gamecube762 he wants to detect if a player clicks directly on it, but the horse and the witherskull are spawned very high...

    DevRosemberg ah ok, didn't know that because I don't see any classes which are created for handling those nametags in NMS and OBC.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  16. Offline

    Goblom

    DevRosemberg It currently is possible :)

    You can use get getLineOfSight and some other stuff to do so, but getting the EXACT selection would be difficult.
     
  17. Offline

    Ultimate_n00b

    You're clicking on a packet. While the packet is sent from the client, the only way to check for it is to.. catch the packet. AKA ProtocolLib.

    http://wiki.vg/Protocol#Use_Entity
     
  18. Offline

    Gamecube762

    Rather than being spawned very high, it looks the client might see them as very tall. My client(mentioned by someone else above) allows me to see hit-boxes and size of entities. When looking at the code and the size, the code looks to add 55 to the Y location(about the sizes of the boxes I'm seeing).
    pictures (open)
    [​IMG][​IMG][​IMG]
     
  19. Offline

    maxben34

    H4xor
     
  20. Offline

    Gamecube762

    I'm a White Hat, not a Black Hat...
     
  21. Offline

    DevRosemberg

    I was told that this can be achieved with BlockIterators, Loops and .distance
     
  22. Offline

    Ultimate_n00b

    Well yeah. Just about the laggiest way to do it.
     
  23. Offline

    DevRosemberg

  24. Offline

    creepers84

    How did you manage to get the tag to appear on top of the players head?
     
  25. Offline

    Gamecube762

    creepers84 use the player's location, add 1 to it's Y value, should be fine. It doesn't follow the player, but I'm working on making it into a local chat plugin. Just haven't had time to work on it.
     
  26. Offline

    lx3krypticx

    Do you have any idea why the 'hologram' might be falling?
     
  27. Offline

    Ultimate_n00b

    A video and code of what you're doing would be helpful in answering your question.
     
  28. Offline

    lx3krypticx

    Code:java
    1. import java.util.ArrayList;
    2. import java.util.Arrays;
    3. import java.util.List;
    4.  
    5. import net.minecraft.server.v1_7_R1.EntityHorse;
    6. import net.minecraft.server.v1_7_R1.EntityPlayer;
    7. import net.minecraft.server.v1_7_R1.EntityWitherSkull;
    8. import net.minecraft.server.v1_7_R1.PacketPlayOutAttachEntity;
    9. import net.minecraft.server.v1_7_R1.PacketPlayOutEntityDestroy;
    10. import net.minecraft.server.v1_7_R1.PacketPlayOutSpawnEntityLiving;
    11. import net.minecraft.server.v1_7_R1.WorldServer;
    12.  
    13. import org.bukkit.Bukkit;
    14. import org.bukkit.Location;
    15. import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
    16. import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
    17. import org.bukkit.entity.Player;
    18. import org.bukkit.scheduler.BukkitRunnable;
    19.  
    20. public class Hologram {
    21. gCommon pl = gCommon.instance;
    22.  
    23. private static final double distance = 0.23;
    24. private List<String> lines = new ArrayList<String>();
    25. private List<Integer> ids = new ArrayList<Integer>();
    26. private boolean showing = false;
    27. private Location location;
    28.  
    29. public Hologram(String... lines) {
    30. this.lines.addAll(Arrays.asList(lines));
    31. }
    32.  
    33. public void change(String... lines) {
    34. destroy();
    35. this.lines = Arrays.asList(lines);
    36. show(this.location);
    37. }
    38.  
    39. public void show(Location loc) {
    40. if (showing == true) {
    41. try {
    42. throw new Exception("Is already showing!");
    43. } catch (Exception e) {
    44. e.printStackTrace();
    45. }
    46. }
    47. Location first = loc.clone().add(0, (this.lines.size() / 2) * distance, 0);
    48. for (int i = 0; i < this.lines.size(); i++) {
    49. ids.addAll(showLine(first.clone(), this.lines.get(i)));
    50. first.subtract(0, distance, 0);
    51. }
    52. showing = true;
    53. this.location = loc;
    54. }
    55.  
    56. public void show(Player player, Location loc) {
    57. if (showing == true) {
    58. try {
    59. throw new Exception("Is already showing!");
    60. } catch (Exception e) {
    61. e.printStackTrace();
    62. }
    63. }
    64. Location first = loc.clone().add(0, (this.lines.size() / 2) * distance, 0);
    65. for (int i = 0; i < this.lines.size(); i++) {
    66. ids.addAll(showLine(player, first.clone(), this.lines.get(i)));
    67. first.subtract(0, distance, 0);
    68. }
    69. showing = true;
    70. this.location = loc;
    71. }
    72.  
    73. public void show(Location loc, long ticks) {
    74. show(loc);
    75. new BukkitRunnable() {
    76. @Override
    77. public void run() {
    78. destroy();
    79. }
    80. }.runTaskLater(pl, ticks);
    81. }
    82.  
    83. public void destroy() {
    84. if (showing == false) {
    85. try {
    86. throw new Exception("Isn't showing!");
    87. } catch (Exception e) {
    88. e.printStackTrace();
    89. }
    90. }
    91. int[] ints = new int[this.ids.size()];
    92. for (int j = 0; j < ints.length; j++) {
    93. ints[j] = ids.get(j);
    94. }
    95. PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ints);
    96. for (Player player : Bukkit.getOnlinePlayers()) {
    97. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
    98. }
    99. showing = false;
    100. this.location = null;
    101. }
    102.  
    103. private static List<Integer> showLine(Location loc, String text) {
    104. WorldServer world = ((CraftWorld) loc.getWorld()).getHandle();
    105. EntityWitherSkull skull = new EntityWitherSkull(world);
    106. skull.setLocation(loc.getX(), loc.getY() + 1 + 55, loc.getZ(), 0, 0);
    107. ((CraftWorld) loc.getWorld()).getHandle().addEntity(skull);
    108.  
    109. EntityHorse horse = new EntityHorse(world);
    110. horse.setLocation(loc.getX(), loc.getY() + 55, loc.getZ(), 0, 0);
    111. horse.setAge(-1700000);
    112. horse.setCustomName(text);
    113. horse.setCustomNameVisible(true);
    114. PacketPlayOutSpawnEntityLiving packedt = new PacketPlayOutSpawnEntityLiving(horse);
    115. for (Player player : loc.getWorld().getPlayers()) {
    116. EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    117. nmsPlayer.playerConnection.sendPacket(packedt);
    118.  
    119. PacketPlayOutAttachEntity pa = new PacketPlayOutAttachEntity(0, horse, skull);
    120. nmsPlayer.playerConnection.sendPacket(pa);
    121. }
    122. return Arrays.asList(skull.getId(), horse.getId());
    123. }
    124.  
    125. private static List<Integer> showLine(Player player, Location loc, String text) {
    126. WorldServer world = ((CraftWorld) loc.getWorld()).getHandle();
    127. EntityWitherSkull skull = new EntityWitherSkull(world);
    128. skull.setLocation(loc.getX(), loc.getY() + 1 + 55, loc.getZ(), 0, 0);
    129. ((CraftWorld) loc.getWorld()).getHandle().addEntity(skull);
    130.  
    131. EntityHorse horse = new EntityHorse(world);
    132. horse.setLocation(loc.getX(), loc.getY() + 55, loc.getZ(), 0, 0);
    133. horse.setAge(-1700000);
    134. horse.setCustomName(text);
    135. horse.setCustomNameVisible(true);
    136. PacketPlayOutSpawnEntityLiving packedt = new PacketPlayOutSpawnEntityLiving(horse);
    137. EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    138. nmsPlayer.playerConnection.sendPacket(packedt);
    139.  
    140. PacketPlayOutAttachEntity pa = new PacketPlayOutAttachEntity(0, horse, skull);
    141. nmsPlayer.playerConnection.sendPacket(pa);
    142.  
    143. return Arrays.asList(skull.getId(), horse.getId());
    144. }
    145.  
    146. }
    147.  


    Where I 'do' it
    Code:java
    1. @EventHandler
    2. public void onJoinShowHologram(final PlayerJoinEvent event){
    3. if(pl.optionsC.contains("rulesloc")){
    4. final Hologram h = new Hologram(ChatColor.RED + "" + ChatColor.BOLD + "Rules", ChatColor.GOLD + "1. " + ChatColor.GREEN + "No ddos talk.", ChatColor.GOLD + "2. " + ChatColor.GREEN + "Be respectful to all players.", ChatColor.GOLD + "3. " + ChatColor.GREEN + "No unsafe links.");
    5. h.show(event.getPlayer(), pl.getRulesLocation());
    6. }
    7.  
    8. if(pl.optionsC.contains("rules2loc")){
    9. final Hologram h = new Hologram(ChatColor.RED + "" + ChatColor.BOLD + "Rules", ChatColor.GOLD + "4. " + ChatColor.GREEN + "No hacking.", ChatColor.GOLD + "5. " + ChatColor.GREEN + "No spamming.", ChatColor.GOLD + "6. " + ChatColor.GREEN + "No pornographic links");
    10. h.show(event.getPlayer(), pl.getRules2Location());
    11. }
    12. // final Hologram h = new Hologram(ChatColor.RED + "" + ChatColor.BOLD + "Rules", ChatColor.GOLD + "4. " + ChatColor.GREEN + "No hacking.", ChatColor.GOLD + "5. " + ChatColor.GREEN + "No spamming.", ChatColor.GOLD + "6. " + ChatColor.GREEN + "No pornographic links");
    13. // final Hologram h = new Hologram(ChatColor.RED + "" + ChatColor.BOLD + "Rules", ChatColor.GOLD + "1. " + ChatColor.GREEN + "No ddos talk.", ChatColor.GOLD + "2. " + ChatColor.GREEN + "Be respectful to all players.", ChatColor.GOLD + "3. " + ChatColor.GREEN + "No unsafe links.");
    14. }
     
  29. Offline

    Ultimate_n00b

    lx3krypticx Small thing, due to where the PlayerJoinEvent is called it won't work like that. You're gonna have to schedule a BukkitRunnable for a few ticks after the event happens.
     
  30. Offline

    lx3krypticx

    Oh my lord. I changed the ticks like 2 down. I had a bukkit runnable before. Anyways, for anyone having this problem schedule it for 5 ticks ahead.
     
Thread Status:
Not open for further replies.

Share This Page