Ok, no more MC api.
This commit is contained in:
parent
895b20bcd5
commit
c2ee6331c5
1 changed files with 12 additions and 3 deletions
|
@ -1,17 +1,26 @@
|
|||
package arzumify.cursedenergy.api;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SearchForNeighbours {
|
||||
private static final Vec3i[] directions = new Vec3i[]{
|
||||
new Vec3i(1, 0, 0),
|
||||
new Vec3i(-1, 0, 0),
|
||||
new Vec3i(0, 1, 0),
|
||||
new Vec3i(0, -1, 0),
|
||||
new Vec3i(0, 0, 1),
|
||||
new Vec3i(0, 0, -1)
|
||||
};
|
||||
|
||||
public static Set<EnergyBlock> searchForNeighbours(World world, BlockPos pos) {
|
||||
var neighbours = new HashSet<EnergyBlock>();
|
||||
for (var direction : Direction.values()) {
|
||||
var entity = world.getBlockEntity(pos.offset(direction));
|
||||
for (var direction : directions) {
|
||||
var entity = world.getBlockEntity(pos.add(direction));
|
||||
if (entity instanceof EnergyBlock) {
|
||||
neighbours.add((EnergyBlock) entity);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue