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.
Page data is saved in the pages
list. All item data that isn't the root id
, Damage
, Count
, or Slot
tags, must be placed within a single tag
compound.
As well, when testing for pre-existing data, you must test for it exactly as it's saved. Item IDs are saved with the namespace (defaulting to "minecraft"), so you have to specify that. The correct ID for a book an quill is "minecraft:writable_book". All tags are case-sensitive, so it would be "Damage" rather than "damage", though this value is not used with that item so does not need to be specified.
/testfor @a {Inventory:[{id:"minecraft:writable_book",tag:{pages:["abcdefg"]}}]}
Keep in mind that you cannot specify which page in the book to look at; it will instead look through every element on the target list for a match.
Best Answer
You are missing the data value before “replace.”