• 0

    posted a message on How to test for a scoreboard objective value in a function?

    You need to reset the "count" objective for all players after executing the test in your function (like I did). Otherwise, it won't work properly if there are 2 or more players on the server.


    I used the @r selector since that will probably be the least laggy, but I think it's fairly negligible. The idea is that it stores the "count" objective in a random player to allow it to be tested directly through a selector (and thus the "if" parameter in /function). Then, after that has been tested, the score needs to be reset for all players for the next time it is used.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How to test for a scoreboard objective value in a function?
    scoreboard players operation @r count = counter count 
    function Herbapou:MyFunction if @a[score_count_min=5,score_counter=5]
    scoreboard players set @a count 0 <-- Note that this does not affect "counter" as it isn't a real player.
    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on How to change between weapons when dropping them.
    Quote from ShelLuser»

    Or you can work this out on a more global scale; have a repeating command block test for Item entities of a certain type and when found make those entities summon the other and remove themselves. Something like this:


    testfor @e[type=Item] {Item:{id:"minecraft:wooden_sword"}}

    scoreboard players tag @e[type=Item,tag=!sword] add sword {Item:{id:"minecraft:wooden_sword"}}

    execute @e[type=Item,tag=sword] ~ ~ ~ summon Item ~ ~ ~ {Item:{id:bow,Count:1}}

    execute @e[type=Item,tag=sword] ~ ~ ~ kill @e[type=Item,tag=sword,r=5]


    first is a repeating command block, the rest are chain conditional command blocks.


    But that wouldn't take into account the player's selected item slot; for example, if the player was holding the weapon in the 5th slot, but the 3rd slot is free, the player would receive the item back in the 3rd slot.

    In that case, it would be better to replace the last two lines of your solution with the following:

    /execute @e[type=item,tag=sword] ~ ~ ~ replaceitem entity @p[r=1] slot.weapon.mainhand minecraft:bow 1
    /kill @e[type=item,tag=sword] (the /execute here is unnecessary)

    That way, it will replace the player's selected item slot with the bow upon throwing the sword. Then the same concept can be applied for the bow, which would replace the player's selected item slot with a sword.

    Posted in: Redstone Discussion and Mechanisms
  • 1

    posted a message on specifications

    Use either a scoreboard objective or a tag.

    -- RUN THIS ONCE --
    /scoreboard objectives add onGround dummy
    
    -- RUN THIS AS REQUIRED --
    /scoreboard players set @e[type=tnt] onGround 1 {OnGround:1b}
    /entitydata @e[type=tnt,score_onGround_min=1] {Fuse:0}
    /scoreboard players reset @e[type=tnt] onGround

    OR


    /scoreboard players tag @e[type=tnt] add onGround {OnGround:1b}
    /entitydata @e[type=tnt,tag=onGround] {Fuse:0}
    /scoreboard players tag @e[type=tnt] remove onGround
    Posted in: Redstone Discussion and Mechanisms
  • 1

    posted a message on is there a way to disable the redstone ore triggering?

    You could run a clock that constantly replaces the redstone ore, assuming that the ores have predefined positions.

    Posted in: Redstone Discussion and Mechanisms
  • 0

    posted a message on time freezing problems.

    For the sand, you could place a sand block, summon an armour stand and destroy the falling sand entity when time freezes, and then do the reverse when time unfreezes (summon falling sand, destroy the sand block and kill the armour stand). This would work if you do not mind the falling sand entity being solid while it is "frozen".


    As for the fireball, they have two additional tags which define their motion, namely "direction" and "power", so try setting those to 0. I don't really know what to do about the arrow; he is saying that you could use a barrier block to make the arrow stuck in an invisible block, but that would create an invisible solid block which could cause issues.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Nametags Visible When Under Effect of Invisibility Potion (Scoreboard)

    There are a couple of approaches to this; the easiest way would be to use a scoreboard objective that defines the player's team.

    /scoreboard objectives add team dummy


    When you assign players to a team, also set this scoreboard objective for that player to a certain value based on the team. Then use that objective to reassign the player to their appropriate team.


    Also, since you only have 4 teams, it might be worth considering making a separate "invisible" team for each of the original teams that you have. That way, even if the player is invisible, the color in their name will still retain.

    Posted in: Redstone Discussion and Mechanisms
  • 1

    posted a message on need help with /execute ... detect ... and /testforblock

    First, set up a dummy scoreboard objective (I called it "score").

    /scoreboard objectives add score dummy

    Then, run the following whenever you wish to execute the command.

    /scoreboard players set @a score 0
    /execute @a ~ ~ ~ detect ~ ~-1 ~1 minecraft:gold_block scoreboard players set @s score 1
    /execute @a[score_score=0] ~ ~ ~ detect ~ ~ -1 ~ minecraft:gold_block say hi
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Execute command relative to entity upon entity's death
    Quote from Flow_GD»

    I thought about doing that but I came across a better solution. I make the ghast summon an armor stand and then immediately kill it. (well actually the other way around but anyway). This way when the ghast dies the armor stand does not get killed.

    But that would only work for 1 ghast, and it's very finicky since you would need to constantly teleport the armour stand to the ghast. The custom drop solution is better since it is generalised and it will work much more easily with multiple ghasts.


    Alternatively, you may be able to assign an armour stand as a passenger for the ghast, that way when the ghast dies, the armor stand will still be present, and you don't need to worry about teleporting since the armour stand will always maintain the same position as the ghast. It will also work for multiple ghasts.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on New 1.12 Selector @s

    It is also important to consider that @p targets players only; @s will also target entities, the entity that executed the command. It also has better performance than using @p or @e[c=1] as the executor of the command is already known, and thus a distance calculation does not need to be applied to find the nearest entity (itself). Though as AngaBlue explained, its addition to the game is primarily associated with the implementation of functions.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on [Help] Command blocks not working in certain places?

    The issue could constitute from one of the following:

    • If you copy a repeating command block along with its power input to another location, then it won't work unless you deactivate and then reactivate its power input. This is also the case when using the "Always Active" feature (by toggling the option in the menu). In saying that, I have found the "Always Active" feature to be unreliable with repeating command blocks, and as such, I simply use a redstone block to power all my repeating command blocks.
    • Be sure that the command block is present in loaded chunks (i.e. spawn chunks, or chunks in which online players currently reside in). Though, you said that you experienced issues even if the command block was present a few blocks away; were you still in those chunks when you tested if the command block works?
    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Damaging A Player Rapidly

    A server would use plugins, though for vanilla /entitydata cannot target players unfortunately since it is possible to bypass the restriction with other entities by constantly setting the "HurtTime" tag to 0.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Nametags Visible When Under Effect of Invisibility Potion (Scoreboard)

    Version 1.8.9 is before they had chain and repeating command blocks right? Because the series of commands relies on them being executed in that exact order, which I don't think is possible prior to 1.9 without there being a small delay.


    Are you able to update your server? If not, then you can use the /fill command to create a 20Hz clock. Basically, the /fill command will create a line of redstone blocks, which come in contact with any command block you wish to execute, as well as the command block that executes the /fill command (so that it will execute the /fill command again, then again, then so on...).


    Take a look at this and scroll down to "Fill Clock".

    Posted in: Redstone Discussion and Mechanisms
  • 0

    posted a message on need help with /summon command

    Unfortunately, I don't think the solution is very simple, but it is possible to "scan" for iron blocks. First, set up a row of armor stands called "block_test", and summon multiple of them across the z-plane in which you want to test.

    /summon armor_stand <start-x> 0 <z> {CustomName:"block_test",CustomNameVisible:0b,Marker:1b,NoGravity:1b,Invisible:1b}

    Specify the x-value at which you want the scan to start. Now, add the scoreboard objective "blockFound":

    /scoreboard objectives add blockFound dummy

    Then run the following command on a clock:

    /execute @e[type=armor_stand,name=block_test] ~ ~ ~ function main:block_test
    /kill @e[type=armor_stand,name=block_test,x=<end x>]

    The function "main:block_test" should contain the following commands:

    /stats entity @s set SuccessCount @s blockFound
    /testforblock ~ ~ ~ minecraft:iron
    /execute @s[score_blockFound_min=1] ~ ~ ~ summon ... (your summon command)
    /stats entity @s clear SuccessCount
    /scoreboard players set @s blockTest 0
    /tp ~ ~1 ~
    /execute @s[y=256] ~1 0 ~

    The function file should be located under <your world>/data/functions/main/block_test.mcfunction.


    Basically, the row of armour stands will constantly scan for iron blocks, checking at its current location and being teleported up 1 y-value each tick. Once it reaches the maximum y-value, the armour stands are sent back to y=0 and are pushed 1 block in the x-direction. This process will continue until the armour stands reach the maximum x-value (end x) that you have specified. It's a slow and inefficient process, and it will not be dynamic across all blocks in your world nor will it occur instantly, but unfortunately I don't think there is any other way of doing this. Hope this helps.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Damaging A Player Rapidly

    Unfortunately, there is a limitation to how fast damage can be dealt to players due to the 8 tick or so invulnerability period every time a player takes damage (indicated by the red).


    The fastest you could probably do is to give the player an instant damage effect every tick, which would result to about every 8 ticks due to the invulnerability period.

    Posted in: Commands, Command Blocks and Functions
  • To post a comment, please or register a new account.