Changing slime's size (packets)

Discussion in 'Plugin Development' started by ArthurMaker, Feb 15, 2014.

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

    ArthurMaker

    I want to spawn a slime with size 1, but I don't know how to set its size.
    I have this at the moment:

    Code:java
    1. @SuppressWarnings("deprecation")
    2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    3. Player player = (Player) sender;
    4.  
    5. if(cmd.getName().equalsIgnoreCase("teste2")){
    6. PacketPlayOutSpawnEntityLiving jairo = new PacketPlayOutSpawnEntityLiving();
    7. try {
    8. Field a = jairo.getClass().getDeclaredField("a");
    9. a.setAccessible(true); // allows us to access the field
    10. a.set(jairo, 12345);
    11.  
    12. Field b = jairo.getClass().getDeclaredField("b");
    13. b.setAccessible(true); // allows us to access the field
    14. b.set(jairo, (byte) EntityType.SLIME.getTypeId());
    15.  
    16. Field c = jairo.getClass().getDeclaredField("c");
    17. c.setAccessible(true); // allows us to access the field
    18. c.set(jairo, (int) Math.floor(player.getLocation().getBlockX() + 0.5 * 32.0D));
    19.  
    20. Field d = jairo.getClass().getDeclaredField("d");
    21. d.setAccessible(true); // allows us to access the field
    22. d.set(jairo, (int) Math.floor(player.getLocation().getBlockY() * 32.0D));
    23.  
    24. Field e = jairo.getClass().getDeclaredField("e");
    25. e.setAccessible(true); // allows us to access the field
    26. e.set(jairo, (int) Math.floor(player.getLocation().getBlockZ() + 0.5 * 32.0D));
    27.  
    28.  
    29. } catch(Exception x) {
    30. x.printStackTrace();
    31. }
    32. DataWatcher watcher = getWatcher("Jairo");
    33. try{
    34. Field w = PacketPlayOutSpawnEntityLiving.class.getDeclaredField("l");
    35. w.setAccessible(true);
    36. w.set(jairo, watcher);
    37. } catch(Exception ex){
    38. ex.printStackTrace();
    39. }
    40. ((CraftPlayer)player).getHandle().playerConnection.sendPacket(jairo);
    41. player.sendMessage("Bem-vindo, Jairo!");
    42. }
    43.  
    44. return false;
    45. }
    46.  
    47. public static DataWatcher getWatcher(String text) {
    48. DataWatcher watcher = new DataWatcher(null);
    49.  
    50. watcher.a(0, (Byte) (byte) 0x20); // Flags, 0x20 = invisible
    51. watcher.a(10, (String) text); // Entity name
    52. watcher.a(11, (Byte) (byte) 1); // Show name, 1 = show, 0 = don't show
    53. // watcher.a(16, (Integer) (int) health); //Wither health, 300 = full
    54. // health
    55.  
    56. return watcher;
    57. }
     
  2. Offline

    sgavster

    You cant use
    Slime s = (Slime) world.spawn(blah);
    s.setSize(1);
    ?
     
  3. Offline

    ArthurMaker


    I want to spawn the slime via packets.
    Using your code, the slime will move and jump, even with negative jump effect and max slowness...
     
  4. Offline

    sgavster

  5. Offline

    ArthurMaker


    Np.

    Up!

    @DevRosemberg

    Can you help me here?

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

    xTrollxDudex

    ArthurMaker
    Jeez, so much code.
    PHP:
    EntitySlime entity = (EntitySlime) ((CraftLivingEntityworld.spawn(player.getLocation(), Slime.class).getHandle();
    entity.setSize(/* Slime size */);
    PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(entity);
     
  7. Offline

    ArthurMaker


    It doesn't work. e-e
     
  8. Offline

    xTrollxDudex

  9. Offline

    ArthurMaker


    Your code. It doesn't do what I want e-e
    I want to spawn a slime that can't move or jump and with a custom name.
     
Thread Status:
Not open for further replies.

Share This Page