package net.mcreator.puzzle_code.procedures;

import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.core.Direction;

public class EqualPositionCodeBlockOnTickUpdateProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, BlockState blockstate) {
		Direction blockDirection = Direction.NORTH;
		double getX = 0;
		double getY = 0;
		double getZ = 0;
		blockDirection = new Object() {
			public Direction getDirection(BlockState _bs) {
				Property<?> _prop = _bs.getBlock().getStateDefinition().getProperty("facing");
				if (_prop instanceof DirectionProperty _dp)
					return _bs.getValue(_dp);
				_prop = _bs.getBlock().getStateDefinition().getProperty("axis");
				return _prop instanceof EnumProperty _ep && _ep.getPossibleValues().toArray()[0] instanceof Direction.Axis ? Direction.fromAxisAndDirection((Direction.Axis) _bs.getValue(_ep), Direction.AxisDirection.POSITIVE) : Direction.NORTH;
			}
		}.getDirection(blockstate);
		SetNBTLogicSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Front"), GetYOffsetSystemProcedure.execute(y, blockDirection, "Front"), GetZOffsetSystemProcedure.execute(z, blockDirection, "Front"),
				GetNBTNumberSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Left"), GetYOffsetSystemProcedure.execute(y, blockDirection, "Left"), GetZOffsetSystemProcedure.execute(z, blockDirection, "Left"),
						"xPositionCodeBlock") == GetNBTNumberSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Right"), GetYOffsetSystemProcedure.execute(y, blockDirection, "Right"),
								GetZOffsetSystemProcedure.execute(z, blockDirection, "Right"), "xPositionCodeBlock")
						&& GetNBTNumberSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Left"), GetYOffsetSystemProcedure.execute(y, blockDirection, "Left"),
								GetZOffsetSystemProcedure.execute(z, blockDirection, "Left"), "yPositionCodeBlock") == GetNBTNumberSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Right"),
										GetYOffsetSystemProcedure.execute(y, blockDirection, "Right"), GetZOffsetSystemProcedure.execute(z, blockDirection, "Right"), "yPositionCodeBlock")
						&& GetNBTNumberSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Left"), GetYOffsetSystemProcedure.execute(y, blockDirection, "Left"),
								GetZOffsetSystemProcedure.execute(z, blockDirection, "Left"), "zPositionCodeBlock") == GetNBTNumberSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Right"),
										GetYOffsetSystemProcedure.execute(y, blockDirection, "Right"), GetZOffsetSystemProcedure.execute(z, blockDirection, "Right"), "zPositionCodeBlock"),
				"logicCodeBlock");
	}
}
