[Lib] Beacon Creator

Discussion in 'Resources' started by Goblom, Oct 2, 2013.

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

    Goblom

    Edit: I do believe that this is the first one out there. Tell me i'm pretty.
    I was looking around the forums and didn't see anything that did this so i decided to make one. Its in the early stages and only does one row of the pyramid.

    The main point of the code is to create the beacon beam. As i have been told that it is impossible to create the beacon beam without the pyramid.

    Code:java
    1. public static void createBeacon(Location location) {
    2. int x = location.getBlockX();
    3. int y = location.getBlockY() - 30;
    4. int z = location.getBlockZ();
    5.  
    6. World world = location.getWorld();
    7.  
    8. world.getBlockAt(x, y, z).setType(Material.BEACON);
    9. for (int i = 0; i <= 29; ++i) world.getBlockAt(x, (y + 1) + i, z).setType(Material.GLASS);
    10. for (int xPoint = x-1; xPoint <= x+1 ; xPoint++) {
    11. for (int zPoint = z-1 ; zPoint <= z+1; zPoint++) {
    12. world.getBlockAt(xPoint, y-1, zPoint).setType(Material.IRON_BLOCK);
    13. }
    14. }
    15. }

    This code will create a beacon 30 blocks below the location. Create glass all the way up to the location and shoot a beam into the sky.
    Code:java
    1. /**
    2. * Creates beacon 30 blocks down from location
    3. */
    4. int y = location.getBlockY() - 30;
    Code:java
    1. /**
    2. * Creates glass all the way up to location
    3. */
    4. for (int i = 0; i <= 30; ++i) world.getBlockAt(x, (y + 1) + i, z).setType(Material.GLASS);

    Code:java
    1. /**
    2. * Creates the Pyramid Rows
    3. */
    4. for (int xPoint = x-1; xPoint <= x+1 ; xPoint++) {
    5. for (int zPoint = z-1 ; zPoint <= z+1; zPoint++) {
    6. world.getBlockAt(xPoint, y-1, zPoint).setType(Material.IRON_BLOCK);
    7. }
    8. }


    Please note this is my first attempt at this and in later versions it will be more compact using for each and also allow for multiple rows and custom pyramid blocks.

    Updates

    October 2, 2013
    • Project Posted. Code was bloated and not appealing
    • Later that day. Pyramid code updated to for each loops. Code now compressed.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
    1 person likes this.
  2. Offline

    Garris0n

    It's surely not impossible[to turn on the beacon without a pyramid], just probably requires some painful nms and/or server modification.
    I'm really bored, so I'm gonna go look through the nms for it now...
     
  3. Offline

    chasechocolate

  4. Offline

    Garris0n

    Hm, it might be but that seems like it'd be a waste to recalculate every time the client saw a beacon...

    Edit: So while looking through the source I was beginning to suspect the boolean 'd' in TileEntityBeacon was responsible for it being activated. And then I found this while searching for whether it was clientsided or not:
    https://github.com/SocialCraft/Pret...stirante/PrettyScaryLib/BeaconHelper.java#L59

    So I think it is possible...but I'd have to do some testing and see what you can mess with :p

    Edit again: That is probably only responsible for potions, not the beam, but I'm still bored so I'll look for stuff anyway.

    Looking through it it definitely doesn't appear that the server is telling the client to turn it on and off. Oh well.

    Another edit:
    It does send nbt data with the following values in the update packet for the tile entity:
    -Primary
    -Secondary
    -Levels
    Levels is the integer e, which appears to in fact be the height of the pyramid calculated every time the server recalculates the pyramid. The question is: does the client calculate the beam based on the tile entity data or by checking the blocks under it?

    Edit again: I checked the protocol just to make sure it did what I thought it did, and it appears to. The packet is 132(0x84). Anybody want to mess with it and see if they can get the client to display a beam incorrectly?
    https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/Packet132TileEntityData.java
    https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/TileEntityBeacon.java
     
  5. Offline

    Goblom

    Garris0n The only other way i can think of to create a beacon beam without the actual pyramid is to send packets to the player and fake the pyramid.
     
  6. Offline

    Cybermaxke

    Garris0n I have tested it but the levels tag isn't working for the beam, it's only used by the gui.
     
  7. Offline

    Ultimate_n00b

    Actually, I have seen something which makes the actual beacon. Now let me see if I can find it..
     
  8. Guys stop trying; de beam is completly client side, yes each time there is a pyramid the client calculates it. Thats how it is, nothing todo about it.
     
    KingFaris11 likes this.
  9. Offline

    Ultimate_n00b

    Hm. Well, I got a slight solution. What about faking the pyramid blocks with reflection?
     
  10. Ultimate_n00b The client would still see them; You have to send the block changes to the client so he knows there is a pyramid + beacon and therefor it will create the beam. Sorry there is no magic way around it, it's the way how _jeb wanted Minecraft to be :/
     
  11. Offline

    Ultimate_n00b

    Huh? I never said the blocks wouldn't show up. I was just suggesting an idea involving only a beacon, and some packets.
     
  12. Ultimate_n00b Oh so you mean the blocks get never placed server-side?

    Edit: I just read your comment again and realize how stupid I am... Sorry about that :p
     
    Ultimate_n00b likes this.
  13. Offline

    Garris0n

    Well yeah you could just .sendBlockChange, no nms/reflection needed, but the client still sees the blocks.
     
  14. Garris0n Ofcourse thats what I've been telling all the time.
     
  15. Offline

    Ivan

    Are you sure the beam is completely clientside? I had blocklag once and the been kept shining its beam with a block above
     
  16. Offline

    Ultimate_n00b

    Deprecated, it'll be gone when 1.7 comes.
     
  17. Offline

    Garris0n

    They would obviously add some replacement before removing it entirely...
     
  18. Offline

    Ultimate_n00b

    Would they?
     
  19. Offline

    Garris0n

    They deprecated everything that uses item ids or damage values with no replacements...stuff from sendBlockChange to getLineOfSight. There's no way they'd remove it all without creating a replacement first.
     
  20. Garris0n I think the id's are gone for the mod support, like modname:item, (like how the texture stuff for mods is currently used) and for minecraft items it would be something like: MC:itemname or minecraft:itemname...

    My guess is Item Id's are dead.

    But let's not get too far off-topic. Anyways, good job Goblom.
     
  21. Offline

    Ultimate_n00b

    It's minecraft:itemname
    Honestly, does no one follow Dinnerbone anymore?
     
  22. Offline

    Goblom

  23. Offline

    Garris0n

    To point it out, I'm pretty sure he meant on twitter.

    Yes, that's exactly why. Magic numbers are bad.
     
    Ultimate_n00b likes this.
  24. Offline

    AndyMcB1

    timtower - have a read of ^^

    Haven't gone through it in detail so not sure if they were able to get it working or not.
     
  25. Offline

    timtower Administrator Administrator Moderator

    Random tahg :p
     
  26. Offline

    Garris0n

    Everybody knows timtower - the unofficial moderator of the plugin requests section :p
     
  27. Offline

    timtower Administrator Administrator Moderator

    But but but: This is the development resources section :p
     
  28. Indeed. Go back where you belong. :D
     
    timtower likes this.
  29. Offline

    chrisman0091

    Very nice resource, thanks! Looks like it'll still work with 1.7 too, woohoo!
     
    Goblom likes this.
Thread Status:
Not open for further replies.

Share This Page