3

I am trying to create a system that when you break any block on a tree, the whole thing will break. I successfully made that part, but ran into an error. I have it so the tree is relative to a bat named Tree1, so anywhere there's a bat named Tree1, there will be a tree. What I am having a problem with is that when ever I break a block on one tree, it affects all of the other trees. I need to know how to have the same bat under each tree(no differences what so ever), then somehow change the bat once it's tree gets chopped down. I could set it so that the player receives a scoreboard point when their holding an axe, and the tree would only fall when that player is in a certain range, but that might get messy around tress that are clumped together, and I also want to keep it as compact as possible. Here is the code:

Spawning the bat:

/summon Bat X Y Z {NoAI:1,Silent:1,CustomName:"Tree1"}

Setting the scoreboard:

/scoreboard objectives add Tree1 dummy Tree1

/scoreboard players set @e[type=Bat] Tree1 1 {CustomName:"Tree1"} (on a setblock clock)

Spawning the tree:

/execute @e[type=Bat,score_Tree1_min=1] ~ ~ ~ /fill ~ ~2 ~ ~ ~7 ~ log /execute @e[type=Bat,score_Tree1_min=1] ~ ~ ~ /fill ~-1 ~4 ~-1 ~1 ~8 ~1 leaves 1 replace air

Testing to see if a block is broken:

/execute @e[type=Bat,score_Tree1_min=1] ~ ~ ~ /testforblock ~ ~3 ~ air (on a setblock clock)

Using a comparator to remove the tree:

/execute @e[type=Bat,score_Tree1_min=1] ~ ~ ~ /fill ~-1 ~2 ~-1 ~1 ~8 ~1 air

Spawning the dropped items:

/execute @e[type=Bat,score_Tree1_min=1] ~ ~ ~ /summon Item ~ ~2 ~ {Item:{Count:4,id:log,tag:{display:{Name:Wooden Log}}}}

Any help would be useful. Thanks.

1 Answer 1

3

Rather than having a testforblock leading onto a fill command via a comparator, you can use the detect function of execute on a clock, which will allow the same bat that detects the air to execute the fill. E.G:

execute @e[type=Bat,score_Tree1_min=1] ~ ~ ~ detect ~ ~3 ~ air 0 fill ~-1 ~2 ~-1 ~1 ~8 ~1 air

Similar thing for spawning the dropped item:

execute @e[type=Bat,score_Tree1_min=1] ~ ~ ~ detect ~ ~3 ~ air 0 summon Item ~ ~2 ~ {Item:{Count:4,id:log,tag:{display:{Name:Wooden Log}}}}

Few sidenotes:

1. You can make the bat invulnerable and invisible like so:

/summon Bat X Y Z {NoAI:1,Silent:1,CustomName:"Tree1",Invulnerable:1b,ActiveEffects:[{Id:14,Amplifier:0,Duration:2147483647,ShowParticles:0b}]}

2. Players can use a nametag to name a bat "Tree1" themselves. Exploiting this, a player could destroy bedrock or clear large areas. Thus, you may want to set the Tree1 score based off of something other than the bat's name.

3. You'll probably want to kill the bat or set its score to 0 after it has been used, otherwise they'll accumulate and keep causing lag.

3
  • The bat is underground, and the players will probably be in adventure mode. Though it wouldn't hurt to do this. I'm mainly doing this to challenge myself to see what all I can recreate inside of minecraft, and might never go public :/. Also, when the tree is destroyed, the command block doesn't produce a redstone signal, is there a way around this or am I going to have to find another way to spawn the logs/kill the bat? Well, I guess I could have it destroy the logs, but that would drop the leaves too... hmm... Any ideas? Thanks again, I had forgotten about the detect function.
    – thezi3
    Oct 16, 2015 at 23:48
  • @thezi3 You can use another execute detect to kill the bat; put this on the clock after the other execute detects: execute @e[type=Bat,score_Tree1_min=1] ~ ~ ~ detect ~ ~3 ~ air 0 kill @e[c=1,r=0]. Comparators are generally slow, laggy, and too limited for things like this.
    – SirBenet
    Oct 16, 2015 at 23:53
  • Why didn't I think of that? Must be getting late. Once again, thank you for all of your help.
    – thezi3
    Oct 16, 2015 at 23:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .