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 ChainLogicCodeBlockUpdateTickProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, BlockState blockstate) {
		Direction blockDirection = Direction.NORTH;
		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, x, y, z, GetNBTLogicSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Back"), GetYOffsetSystemProcedure.execute(y, blockDirection, "Back"),
				GetZOffsetSystemProcedure.execute(z, blockDirection, "Back"), "logicCodeBlock"), "logicCodeBlock");
	}
}
