Commmand Block Discussion

  1. 7 years ago

    Some of you know that i have been making a serious attempt to get my head around command blocks. I have been setting myself various challenges which i implement on a local server. The one i am working on at the minute is a back system that takes you back to where you die iff (this is not a spelling mistake) you wish to.

    To my surprise, not because of my coding, which is fine, but due to the fact that chunks actually take a little while to unload the system works quite well, even handling more than one player, as long as you are quick about it. I am happy for it to be time limited but it currently only gives you about 40 seconds and if you dont get back in time the place marker wont despawn. I need to keep the chunk loaded for a little while longer. Anyway there appear to be two commonly used methods of forcing a chunk to remain one with arrows and another with the spread command. (The hopper one is not practical in this instance)

    I was wondering if anyone had any bettter ideas for keeping a chunk alive. Obviously it would still have to be for a limited time. I also have a notion that the Crafty Mynes control room is split between two places and would be interested to know what method @CraftyMyner uses.

    Look forward to hearing your thoughts on this.

  2. Cool! I'm guessing you're using some sort of marker entity (armour stand?) to tp the player back to the death location. I'm guessing you know that Minecraft tries to unload all chunks every 45 seconds which will be your time limit at the moment, since you can't target entities in unloaded chunks.
    Thinking about this has also got me wondering how the warps on the server work, since you should be able to apply the same principle here (Boss Man?).
    For your needs you could permanently load the chunk (well not permanently but you know what I mean) but that doesn't seem viable for saving warp locations on a server because of how these could accumulate over time.

    I vaguely remember seeing a video a while back where someone tp'd an entity back and forth across the world border to somehow detect the coordinates of a player and store it as a scoreboard objective or something. I'll see if I can find it, although there's probably better ways of doing it.

    Oh and I know bugger all about command blocks so you probably ignore everything I just wrote.

    P.S. I spotted a typo

    @Tez1010 iff

    :P

  3. Edited 7 years ago by Tez1010

    Hi @NutjobBob

    Thanks for your thoughts on this. Yes I am using a marker, but not an armour stand. These though good have been upstaged by the area effect cloud used by minecraft to handle lingering potions. They don't take up space, have no hit box, and have a duration you can set. For those who are interested, the tricky bit is how you make them distinct markers for different people and how you then access them again.

    The 45 seconds you mentioned does tally with what i found by experiment and I would ideally like it to be about 5 mins that you get an option to go back.

    The warps are indeed very interesting as to how to implement and this is next on my list of challenges. With so many players it would not be acceptable to permanently load warps. Suceeding in the warps will as you say solve the problem with back, which is effectively a warp. I will have a look at what i can find on setting warps/waypoints.

    All the methods I have found so far use entities/items that need to look to see if another chunk is involved in their behaviour and to implemement would be adding more stuff to the chunk you would then have to clear up afterwards. Not absolutely sure if that applies to using the spread command but i havent familiarised myself with that yet.

    For the non mathematicians, as I suspect NJB knows perfectly well, iff = if and only if.

  4. Edited 7 years ago by NutjobBob

    @NutjobBob I vaguely remember seeing a video a while back

    Found it!

    Click!

    I can't help but think there must be a better way to do this, but this method is pretty neat! (assuming it still works). Skip to 2:40 to see the bit about finding the coords of players.

    Edit:

    @Tez1010 upstaged by the area effect cloud

    Hey thats pretty cool! Didn't realise they could be use like that. I assume you can't name them like armour stands though, hence the trouble with making them distinct.

  5. Thanks very much.

  6. You might find this video helpful for understanding chuck unloading better:

  7. You can name them and tag them in the same way but if the same command triggers it will name them all the same whether they are clouds or armour stands. And you dont want to test on each players name separately. You have to look to the scoreboard.

  8. Thanks @pand1024 that is interesting.

    It wont help me for just keeping a chunk open for a short time as i dont want to have to put a load of stuff down that i then have to remove. It will be useful if i want to add command room further out from spawn. Of course the alternative is to save the back coords which is essentially a saveable warp.

    @NutjobBob essentially this works out how far the border is by moving an entity recording and improving the approximation as you go. I am not sure whether that will force chunks on the way to be created which would be an issue for me with limited map storage. I dont think you need to use chests to store the save though - I think you can use the scoreboard and deduct amounts in the same way to go back. (If you tp the player will they see what is on the way or die in lava etc?) Quite a challenge to say the least. I also have a memory @CraftyMyner said there were over 200 blocks in the warp system though that includes vote credit charging and tests for team to see if a charge applies.

  9. Just properly tried using commands for the first time!
    I found some interesting things you might find useful:

    Firstly the method in the video I showed is no longer possible because you don't seem to be able to teleport entities outside of the worldborder any more. I'm pretty sure you can still find coordinates using something similar to this by testing if a series of relative tp commands succeed/fail, since they will fail if they try to tp an entity outside the worldborder.

    Secondly you can tp a mob around unloaded and ungenerated chunks just fine. I only tested this by tping it out once and then back. There might be a limit on how many times you can tp it around unloaded chunks before the game can't find it any more. Strangely, I checked using MCedit and found that this doesn't load or generate the chunk (so no memory problems!).

    No idea if this is remotely useful or not, but I had fun playing with it!

  10. Hi there @NutjobBob

    I can find the coordinates ok now but you raise some very interesting stuff and I will probably adjust my method. What I had found was that by setting the volume values test appropriately you can check whether the border has been passed. This would have to be adjusted if you change the world border.

    Slightly puzzled as I actually found you can tp entities outside the world border or at least a world border you have set yourself.

    It may be that you cant set it beyond the default of 60million he refers to. He also refers to an operation you cant do only when you are outside the border to test whether you are outside the border. I cant find this - only ones that always work or always don't.

    If you are referring to the default border and it wont let you past, then actually my thinking is this will make it much easier as you can just try reducing steps until you can't move anymore recording as you go along. No need for backwards and forwards. The fact that you found from MCEdit that it doesn't create chunks getting there means I can use it without worrying about file size. (Phew)

    As far as loading the chunks is concerned I did find a video that shows there are various levels of loading. I think there is a bare minimum load state as I found I could tp to the entity for a similar time window as for the back command referred to earlier.

  11. Nice, good to hear you're making progress!

    @Tez1010 It may be that you cant set it beyond the default of 60million he refers to.

    Yes sorry I meant you can't tp a mob outside the default +/- 30million border because the game won't let you tp to values that exceed +/- 30million. Even when using relative coordinates. I guess a border you set yourself works differently. I did also think this might make finding the coordinates of a player much easier.

    @Tez1010 He also refers to an operation you cant do only when you are outside the border to test whether you are outside the border. I cant find this - only ones that always work or always don't.

    I think this got fixed a while back, I couldn't get it to work either. Seems like any command you try to run using coordinates beyond +/- 30million fails now.

    The fact that tping back and forth through unloaded chunks won't load them if you use a mob is really strange to me, but convenient for file sizes. Just bear in mind that if you use a player I'm pretty sure they will cause the chunks to generate (haven't tested it though).

    Regarding the types of loaded chunks, not sure what you mean. Are you talking about the difference between entity-processing (or fully loaded) and non-entity processing (lazy chunks)? If it is I don't think that's something you need to worry about because commands like spreadplayers will load the chunk to be entity-processing. If you can tp to the entity it's in a entity-processing chunk.

    If you're interested you can easily tell if a chunk is entity-processing or not by setting up two command blocks with /say in them. Attach one to a redstone clock, and attach the other to a detector rail with a minecart on a looped track. If the chunk is entity-processing both command blocks will work, if not only the redstone clock one will.

    @Tez1010 I could tp to the entity for a similar time window as for the back command referred to earlier.

    This time window is actually linked to the autosave. When the game autosaves every 45 seconds it also tries to unload all the chunks it can. This runs like a clock, so you'll actually find the period of time you're able to tp to the entity is variable depending on when in the clock cycle the chunk was last loaded.
    If you want a visualisation of this Wout came up with an autosave detector a while back:
    https://www.youtube.com/watch?v=oGzQzqtCNY0
    It works because any artificially loaded chunk (e.g. with hoppers) will be unloaded for one tick as the game autosaves before the chunk loaded loads it again.

    I need a rest after typing all that...

  12. Edited 7 years ago by Tez1010

    Yes the video i saw showed all that with the hopper and the minecart. Tping an entity to a chunk does seem to have some interesting properties - you can tp the selected entitiy out again and you can tp to it albeit briefly but you cant run /execute at the entity. It is not a lazy chunk - as the mc edit shows it doesnt exist as such. A pre creation state maybe, which is 'unloaded' when other chunks are unloaded. Or is it just that if you leave the entity there long enough it will create the chunk and thus it is just being unloaded.

    Im sure you are right that if you use the player it will create the chunk in the file even when just passing through.

  13. This is all very weird. I was able to tp an entity to an unloaded chunk (whether generated or not) and the @e selector seemed to be able to find it indefinitely. I could wait as long as I wanted to bring it back as long as the chunk it was in didn't get loaded loaded during that time. I also didn't have any problems running /execute at the entity for as long as I wanted.
    Even stranger if I tpd myself to the entity it was there, but if I reloaded the world and then did the same it wasn't there (or anywhere in fact).

    I also realised that getting the coordinates of a player as a scoreboard value isn't at all helpful for what you want, because you can't use scoreboard values as variables.

  14. Not sure about the execute and entity selection. I may have made a mistake there, needs further investigation I think.

    The vanishing may be something to do with the persistent setting. Just an idea.

    Getting coordinates on the scoreboard is definitely useful as you can effectively reverse the process. Haven't implemented it yet but pretty confident it will work.

  15. If anyone else is reading please feel free to add your comments and queries about commands and command blocks.

  16. I realised just after I posted this that you could use the scoreboard value like that, had a blonde moment.

    @Tez1010 What I had found was that by setting the volume values test appropriately you can check whether the border has been passed.

    I don't understand what you mean by this, would you mind elaborating a bit for stupid me.

    I think the entity vanishing might actually be because the chunks it is in aren't loaded when I exit the game, so they don't get saved at any point after the entity is teleported there.

  17. Edited 7 years ago by Tez1010

    @e(x=0,y=0,z=0,dx=m,dy=n,dz=p) will tell you if an entity is in a box m by n by p with the north west corner at (0,0,0) I called this test the volume values test which was not a great name for it, sorry.

    If you set (x, y, z) at the most negative point on your world, and dx, dy and dz to the size of the world in the respective directions then you can use this to check if the entity is inside the world border.

  18. Edited 7 years ago by PlesleronTepryos

    I need help to make a lever that can only be activated by a certain player. I'm aware of data tags that make a chest openable when holding an item:

    /blockdata [x] [y] [z] {Lock:"Item Name"}

    But how do i make it player specific, not a particular item.

  19. @Tez1010 Me again. I though that might have been what you meant, but couldn't figure out the syntax of spaces and commas. Got there now.

    Regarding tping entities yet again: whether or not you can target the entitiy indefinitely in unloaded chunks seems to depend on the status of where you tp it from. So if you tp it from a chunk that then becomes unloaded the game looses it. But if you tp it from spawn chunks which never get unloaded (unless the server restarts) you can target it to your hearts content.

    The reason why I'm still harping on about this is that you can use it to make a very simple /back command, if the world border is something less than 15million.
    When someone dies summon a marker entity inside the spawn chunks, and then execute /teleport (not tp) for the player, using relative coordinates and adding the diameter of the world border to either the x or z coordinate. You then have a marker a known number of blocks away from the players death location, that never despawns and can be targeted until the server closes. You can then just execute another /teleport command at the marker entity, reverse the relative coordinates and hey presto the player is back where they died. No need to mess around with finding coordinates.
    I did this on SP, not sure if it works on MP - I don't quite understand if you could create a different marker entity for each player that died or not.

    @PlesleronTepryos I don't think that you can. From what I can tell the best you can do test if a specific player is in a certain radius.

  20. Thanks for your thoughts on this. I have done some further investigation.

    I now summon the marker entity by the command block in spawn. It seems if I then tp or teleport that entity to a specific place whether using relative coordinates or not it will stay available. If I tp it to the player that has died it doesn't stay available even though I summon it in spawn. Tp or teleport doesn't seem to make any difference to persistence if you use coordinates. This is true whether entered by command block or directly.

    -----------------------------------------------------------------------
    This is what I think you were suggesting and if I do it

    /execute @a[score_HasDied_min=1] ~ ~ ~ /teleport @e[name=Back,tag=AddID] ~ ~ ~

    it doesn't stay available, although it does take you to the right place. I have tried adding in an offset but that makes no difference.

    ---------------------------------------------
    if I do
    execute @a[score_HasDied_min=1] ~ ~ ~ tp @e[name=Back,tag=AddID] @a[score_HasDied_min=1]

    brings the marker out successfully but it doesn't stay available so I may as well not bother with the execute at the beginning.
    ------------------------------------------------------------
    and if I do

    execute @a[score_HasDied_min=1] ~ ~ ~ tp @e[name=Back,tag=AddID] x y z

    it would stay but I don't know x y z.
    -----------------------------------------------------

    Any further thoughts. My next idea is to just keep teleporting the marker to itself and see if that keeps it available, though I have run out of time to 'work' on it today.

  21. Newer ›

or Sign Up to reply!