# Solved Block location next to block in all directions?

Discussion in 'Skript' started by JustADev, Sep 12, 2017.

Thread Status:
Not open for further replies.
1. ### JustADev Well-Known Member

Joined:
Apr 8, 2017
Messages:
380
Likes Received:
9
Plugins:
SkQuery
Skript 2.2
SkDragon
Umbaska

Version;
Spigot 1.8

Question:
How do I make it so that when emerald ore is placed in a cross like this:
Key: x = air o = ore
xox
ooo
xox
that the blocks are removed and an enderchest spawns in the middle?

#1
2. Best Answer:
Post #3 by ShaneBee, Sep 12, 2017
3. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,181
Likes Received:
220
With a little bit of brain.

A pinch of logic.

A slice of hard work

And too top it all of, cooked in a hot pre-heated oven at 200 degrees, it'll indeed produce what you're looking for.

#2
• Like x 1
4. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,181
Likes Received:
220
I think it can be smaller but i couldn't it works tho

Code (Skript):
1. function middlecheck(loc: location) :: boolean:
2.     set {_found} to 0
3.     loop all blocks in radius 1 around {_loc}:
4.         loop-block is emerald ore
5.         if y-coordinate of loop-block = y-coordinate of {_loc}:
6.             add 1 to {_found}
7.     if {_found} = 5:
8.         loop all blocks in radius 1 around {_loc}:
9.             loop-block is emerald ore
10.             if y-coordinate of loop-block = y-coordinate of {_loc}:
11.                 set loop-block to air
12.         set block at {_loc} to a ender chest
13.         return true
14.     else:
15.         return false
16.
17. on place of emerald ore:
18.     set {_check} to middlecheck(location of event-block)
19.     if {_check} is true:
20.         stop
21.     if block north of event-block is emerald ore:
22.         set {_check} to middlecheck(location of block north of event-block)
23.         if {_check} is true:
24.             stop
25.     if block east of event-block is emerald ore:
26.         set {_check} to middlecheck(location of block east of event-block)
27.         if {_check} is true:
28.             stop
29.     if block south of event-block is emerald ore:
30.         set {_check} to middlecheck(location of block south of event-block)
31.         if {_check} is true:
32.             stop
33.     if block west of event-block is emerald ore:
34.         set {_check} to middlecheck(location of block west of event-block)
35.         if {_check} is true:
36.             stop

#3
Thread Status:
Not open for further replies.

• ### About Us

Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.
• ### Support skUnity

The staff team works very hard to make sure the community is running its best. This means constantly performing upgrades to systems and other features. This does cost a bit of money to keep doing. Donating to skUnity would allow the server to keep running smoothly for years to come!

Support Us!
• ### Join our Discord

Discord is an all-in-one voice and text chat for gamers thatâ€™s free, secure, and works on both your desktop and phone.